feat: add spegel support for k0s (#1178)

* feat: add spegel support for k0s

Signed-off-by: Devin Buhl <devin@buhl.casa>

* chore: add spegel to e2e tests

Signed-off-by: Devin Buhl <devin@buhl.casa>

* fix: update containerd file paths and run apply from k0s-config dir

Signed-off-by: Devin Buhl <devin@buhl.casa>

* fix: move containerd files after upload

Signed-off-by: Devin Buhl <devin@buhl.casa>

---------

Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
Devin Buhl authored and GitHub committed 2024-01-17 16:00:28 -05:00
1 parent edbcf28139
commit ca9d1818fc
13 files changed
+138 -13

No files matched your search

@@ -8,3 +8,6 @@ resources:
- ./coredns/ks.yaml
#% endif %#
- ./metrics-server/ks.yaml
#% if bootstrap_distribution == "k0s" and spegel.enabled | default(false) %#
- ./spegel/ks.yaml
#% endif %#
@@ -0,0 +1,37 @@
#% if bootstrap_distribution == "k0s" and spegel.enabled | default(false) %#
---
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
name: spegel
spec:
interval: 30m
chart:
spec:
chart: spegel
version: v0.0.17
sourceRef:
kind: HelmRepository
name: xenitab
namespace: flux-system
install:
remediation:
retries: 3
upgrade:
cleanupOnFail: true
remediation:
retries: 3
uninstall:
keepHistory: false
values:
spegel:
#% if bootstrap_distribution == "k0s" %#
containerdSock: /run/k0s/containerd.sock
containerdRegistryConfigPath: /var/lib/k0s/containerd/certs.d
#% endif %#
service:
registry:
hostPort: 29999
serviceMonitor:
enabled: true
#% endif %#
@@ -0,0 +1,7 @@
#% if bootstrap_distribution == "k0s" and spegel.enabled | default(false) %#
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./helmrelease.yaml
#% endif %#
@@ -0,0 +1,22 @@
#% if bootstrap_distribution == "k0s" and spegel.enabled | default(false) %#
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: &app spegel
namespace: flux-system
spec:
targetNamespace: kube-system
commonMetadata:
labels:
app.kubernetes.io/name: *app
path: ./kubernetes/apps/kube-system/spegel/app
prune: true
sourceRef:
kind: GitRepository
name: home-kubernetes
wait: false
interval: 30m
retryInterval: 1m
timeout: 5m
#% endif %#
@@ -21,3 +21,4 @@ resources:
- ./prometheus-community.yaml
- ./stakater.yaml
- ./weave-gitops.yaml
- ./xenitab.yaml
@@ -0,0 +1,10 @@
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: xenitab
namespace: flux-system
spec:
type: oci
interval: 5m
url: oci://ghcr.io/xenitab/helm-charts
@@ -0,0 +1,157 @@
#% if bootstrap_distribution == 'k0s' %#
---
apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster
metadata:
name: k0s-cluster
spec:
hosts:
#% for item in bootstrap_nodes.master %#
- role: "#{ item.role | default('controller+worker') }#"
ssh:
address: "#{ item.address }#"
user: "#{ item.username }#"
installFlags:
- --disable-components=metrics-server
#% if item.role | default('') == 'controller+worker' %#
- --no-taints
#% endif %#
files:
- name: containerd-config
src: resources/containerd/
perm: 0644
user: root
group: root
hooks:
apply:
before:
#% if spegel.enabled | default(false) %#
- sudo mv ~/spegel.toml /etc/k0s/containerd.d/spegel.toml
#% endif %#
- sudo mv ~/unprivileged-ports.toml /etc/k0s/containerd.d/unprivileged-ports.toml
#% endfor %#
#% if bootstrap_nodes.worker | default([]) | length > 0 %#
#% for item in bootstrap_nodes.worker %#
- role: worker
ssh:
address: "#{ item.address }#"
user: "#{ item.username }#"
files:
- name: containerd-config
src: resources/containerd/
perm: 0644
user: root
group: root
hooks:
apply:
before:
#% if spegel.enabled | default(false) %#
- sudo mv ~/spegel.toml /etc/k0s/containerd.d/spegel.toml
#% endif %#
- sudo mv ~/unprivileged-ports.toml /etc/k0s/containerd.d/unprivileged-ports.toml
#% endfor %#
#% endif %#
k0s:
# renovate: datasource=github-releases depName=k0sproject/k0s
version: "v1.28.5+k0s.0"
dynamicConfig: false
config:
spec:
telemetry:
enabled: false
controllerManager:
extraArgs:
# Required to monitor kube-controller-manager with kube-prometheus-stack
bind-address: "0.0.0.0"
scheduler:
extraArgs:
# Required to monitor kube-scheduler with kube-prometheus-stack
bind-address: "0.0.0.0"
api:
sans:
- "#{ bootstrap_kube_api_addr }#"
#% if bootstrap_kube_api_hostname | default('') %#
- "#{ bootstrap_kube_api_hostname }#"
#% endif %#
#% for item in bootstrap_nodes.master %#
#% if item.address != bootstrap_kube_api_addr %#
- "#{ item.address }#"
#% endif %#
#% if (not bootstrap_kube_api_hostname | default('')) or (item.name != bootstrap_kube_api_hostname | default('')) %#
- "#{ item.name }#"
#% endif %#
#% endfor %#
network:
kubeProxy:
disabled: true
#% if bootstrap_nodes.master | length > 1 %#
nodeLocalLoadBalancing:
enabled: true
type: EnvoyProxy
#% endif %#
provider: custom
extensions:
helm:
repositories:
- name: cilium
url: https://helm.cilium.io
charts:
- name: cilium
chartname: cilium/cilium
# renovate: datasource=github-releases depName=cilium/cilium
version: "1.14.5"
namespace: kube-system
values: |2
autoDirectNodeRoutes: true
bpf:
masquerade: true
bgp:
enabled: false
cluster:
name: home-cluster
id: 1
containerRuntime:
integration: containerd
socketPath: /var/run/k0s/containerd.sock
endpointRoutes:
enabled: true
hubble:
enabled: false
ipam:
mode: kubernetes
ipv4NativeRoutingCIDR: "#{ bootstrap_cluster_cidr }#"
#% if bootstrap_ipv6_enabled | default(false) %#
ipv6NativeRoutingCIDR: "#{ bootstrap_cluster_cidr_v6 }#"
ipv6:
enabled: true
#% endif %#
#% if bootstrap_nodes.master | length > 1 or bootstrap_kube_api_addr | default('') %#
k8sServiceHost: "#{ bootstrap_kube_api_addr }#"
#% else %#
k8sServiceHost: "#{ bootstrap_nodes.master[0].address }#"
#% endif %#
k8sServicePort: 6443
kubeProxyReplacement: true
kubeProxyReplacementHealthzBindAddr: 0.0.0.0:10256
l2announcements:
#% if bootstrap_ipv6_enabled | default(false) %#
enabled: false
#% else %#
enabled: true
# https://github.com/cilium/cilium/issues/26586
leaseDuration: 120s
leaseRenewDeadline: 60s
leaseRetryPeriod: 1s
#% endif %#
loadBalancer:
algorithm: maglev
mode: "#{ bootstrap_cilium_loadbalancer_mode | default('dsr', true) }#"
localRedirectPolicy: true
operator:
replicas: 1
rollOutPods: true
rollOutCiliumPods: true
routingMode: native
securityContext:
privileged: true
#% endif %#
@@ -0,0 +1,6 @@
#% if bootstrap_distribution == 'k0s' and spegel.enabled | default(false) %#
[plugins."io.containerd.grpc.v1.cri".containerd]
discard_unpacked_layers = false
[plugins."io.containerd.grpc.v1.cri".registry]
config_path = "/var/lib/k0s/containerd/certs.d"
#% endif %#
@@ -0,0 +1,5 @@
#% if bootstrap_distribution == 'k0s' and spegel.enabled | default(false) %#
[plugins."io.containerd.grpc.v1.cri"]
enable_unprivileged_ports = true
enable_unprivileged_icmp = true
#% endif %#