feat(k0s): unsupport it (#1291)

Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
Devin Buhl authored and GitHub committed 2024-02-02 18:02:14 -05:00
1 parent 3e0fb233b6
commit eab63476b7
48 files changed
+22 -505

No files matched your search

@@ -8,7 +8,7 @@ resources:
- ./kubelet-csr-approver/ks.yaml
{% endif %}
- ./metrics-server/ks.yaml
{% if distribution.type in ["k0s", "talos"] %}
{% if distribution.type in ["talos"] %}
- ./spegel/ks.yaml
{% endif %}
- ./reloader/ks.yaml
@@ -1 +1 @@
main = lambda data: data.get("distribution", {}).get("type", "k3s") in ["k0s", "talos"]
main = lambda data: data.get("distribution", {}).get("type", "k3s") in ["talos"]
@@ -24,13 +24,8 @@ spec:
keepHistory: false
values:
spegel:
{% if distribution.type in ["k0s"] %}
containerdSock: /run/k0s/containerd.sock
containerdRegistryConfigPath: /var/lib/k0s/containerd/certs.d
{% elif distribution.type in ["talos"] %}
containerdSock: /run/containerd/containerd.sock
containerdRegistryConfigPath: /etc/cri/conf.d/hosts
{% endif %}
service:
registry:
hostPort: 29999
@@ -1 +0,0 @@
main = lambda data: data.get("distribution", {}).get("type", "k3s") in ["k0s"]
@@ -1,5 +0,0 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./plan.yaml
@@ -1,25 +0,0 @@
---
apiVersion: autopilot.k0sproject.io/v1beta2
kind: Plan
metadata:
name: autopilot
spec:
id: not-used
timestamp: not-used
commands:
- k0supdate:
version: "${KUBE_VERSION}"
platforms:
linux-amd64:
url: "https://get.k0sproject.io/${KUBE_VERSION}/k0s-${KUBE_VERSION}-amd64"
linux-arm64:
url: "https://get.k0sproject.io/${KUBE_VERSION}/k0s-${KUBE_VERSION}-arm64"
targets:
controllers:
discovery:
selector: {}
{% if nodes.inventory | selectattr('controller', 'equalto', False) | list | length %}
workers:
discovery:
selector: {}
{% endif %}
@@ -1,24 +0,0 @@
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: &app system-upgrade-k0s
namespace: flux-system
spec:
targetNamespace: system-upgrade
commonMetadata:
labels:
app.kubernetes.io/name: *app
path: ./kubernetes/apps/system-upgrade/k0s/app
prune: true
sourceRef:
kind: GitRepository
name: home-kubernetes
wait: false
interval: 30m
retryInterval: 1m
timeout: 5m
postBuild:
substitute:
# renovate: datasource=github-releases depName=k0sproject/k0s
KUBE_VERSION: v1.29.1+k0s.0
@@ -6,9 +6,6 @@ resources:
{% if distribution.type in ['k3s', 'talos'] %}
- ./system-upgrade-controller/ks.yaml
{% endif %}
{% if distribution.type in ["k0s"] %}
- ./k0s/ks.yaml
{% endif %}
{% if distribution.type in ["k3s"] %}
- ./k3s/ks.yaml
{% endif %}
@@ -16,6 +16,6 @@ resources:
- ./postfinance.yaml
{% endif %}
- ./stakater.yaml
{% if distribution.type in ["k0s", "talos"] %}
{% if distribution.type in ["talos"] %}
- ./xenitab.yaml
{% endif %}
@@ -1,4 +1,4 @@
{% if distribution.type in ["k0s", "talos"] %}
{% if distribution.type in ["talos"] %}
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
@@ -1 +0,0 @@
main = lambda data: data.get("distribution", {}).get("type", "k3s") in ["k0s"]
@@ -1,97 +0,0 @@
---
apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster
metadata:
name: home-kubernetes
spec:
hosts:
{% for item in nodes.inventory %}
{% if item.controller %}
- role: controller+worker
{% else %}
- role: worker
{% endif %}
ssh:
address: "{{ item.address }}"
user: "{{ item.ssh_username }}"
installFlags:
{% if item.controller %}
- --disable-components=metrics-server
- --no-taints
{% endif %}
- --kubelet-extra-args="--image-gc-low-threshold=50 --image-gc-high-threshold=60"
files:
- name: bootstrap-scripts
src: scripts
hooks:
apply:
before:
- bash ~/apply-system.sh "{{ item.name }}"
{% if item.controller %}
- bash ~/apply-kube-vip.sh
{% endif %}
reset:
before:
- bash ~/reset-cilium.sh
after:
- bash ~/reset-system.sh
{% endfor %}
k0s:
# renovate: datasource=github-releases depName=k0sproject/k0s
version: v1.29.1+k0s.0
config:
apiVersion: k0s.k0sproject.io/v1beta1
kind: ClusterConfig
metadata:
name: home-kubernetes
spec:
telemetry:
enabled: false
controllerManager:
extraArgs:
bind-address: "0.0.0.0"
scheduler:
extraArgs:
bind-address: "0.0.0.0"
storage:
etcd:
extraArgs:
listen-metrics-urls: http://0.0.0.0:2381
api:
sans:
{% if cluster.endpoint_vip %}
- "{{ cluster.endpoint_vip }}"
{% endif %}
{% for item in cluster.tls_sans %}
- "{{ item }}"
{% endfor %}
{% for item in controllers %}
{% if item.controller %}
- "{{ item.address }}"
- "{{ item.name }}"
{% endif %}
{% endfor %}
network:
podCIDR: "{{ cluster.pod_network.split(',')[0] }}"
serviceCIDR: "{{ cluster.service_network.split(',')[0] }}"
provider: custom
kubeProxy:
disabled: true
nodeLocalLoadBalancing:
enabled: true
type: EnvoyProxy
extensions:
helm:
repositories:
- name: cilium
url: https://helm.cilium.io
charts:
- name: cilium
chartname: cilium/cilium
# renovate: datasource=helm depName=cilium repository=https://helm.cilium.io
version: 1.15.0
namespace: kube-system
values: |2
{% filter indent(width=18, first=True) %}
{% include 'partials/cilium-values-init.partial.yaml.j2' %}
{% endfilter %}
@@ -1,18 +0,0 @@
#!/usr/bin/env bash
set -e
set -o noglob
[ $(id -u) -eq 0 ] || exec sudo $0 $@
# Create kube-vip directory
mkdir -p /var/lib/k0s/manifests/kube-vip
# Create kube-vip rbac
cat <<EOF > /var/lib/k0s/manifests/kube-vip/rbac.yaml
{% include 'partials/kube-vip-rbac.partial.yaml.j2' %}
EOF
# Create kube-vip daemonset
cat <<EOF > /var/lib/k0s/manifests/kube-vip/ds.yaml
{% include 'partials/kube-vip-ds.partial.yaml.j2' %}
EOF
@@ -1,81 +0,0 @@
#!/usr/bin/env bash
set -e
set -o noglob
[ $(id -u) -eq 0 ] || exec sudo $0 $@
K0S_HOSTNAME="$1"
# Prepare
sudo apt-get update -y
# Hostname
if [ -n "${K0S_HOSTNAME}" ] && [ "$(hostnamectl hostname)" != "${K0S_HOSTNAME}" ]; then
hostnamectl set-hostname "${K0S_HOSTNAME}"
cat >/etc/hosts <<EOF
127.0.0.1 localhost
127.0.1.1 $K0S_HOSTNAME
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF
fi
# Timezone
timedatectl set-timezone "{{ timezone }}"
# Install Packages
apt-get install -y --no-install-recommends \
apt-transport-https ca-certificates conntrack curl dirmngr gdisk gnupg hdparm htop \
iptables iputils-ping ipvsadm libseccomp2 lm-sensors net-tools nfs-common \
nvme-cli open-iscsi parted psmisc python3 python3-apt python3-kubernetes python3-yaml \
smartmontools socat software-properties-common unzip util-linux
# Update DNS
chattr -i /etc/resolv.conf
rm -f /etc/resolv.conf
cat <<EOF > /etc/resolv.conf
search {{ nodes.search_domain|default('.', true) }}
{% for item in nodes.dns_servers | default(['1.1.1.1', '1.0.0.1']) %}
nameserver {{ item }}
{% endfor %}
EOF
chattr +i /etc/resolv.conf
# Kernel Modules
for module in br_netfilter ceph ip_vs ip_vs_rr nbd overlay rbd; do
if ! test -f /etc/modules-load.d/$module.conf; then
echo $module > /etc/modules-load.d/$module.conf
fi
done
systemctl restart systemd-modules-load.service
# Sysctls
cat <<EOF > /etc/sysctl.d/99-kubernetes.conf
fs.inotify.max_queued_events = 65536
fs.inotify.max_user_watches = 524288
fs.inotify.max_user_instances = 8192
EOF
sysctl -p /etc/sysctl.d/99-kubernetes.conf
# Disable swap
swapoff -a
# Disable AppArmor
if systemctl is-enabled apparmor.service; then
systemctl mask apparmor.service
fi
# Create containerd config
mkdir -p /etc/k0s/containerd.d
cat <<EOF > /etc/k0s/containerd.d/default.toml
[plugins."io.containerd.grpc.v1.cri"]
enable_unprivileged_ports = true
enable_unprivileged_icmp = true
[plugins."io.containerd.grpc.v1.cri".registry]
config_path = "/var/lib/k0s/containerd/certs.d"
[plugins."io.containerd.grpc.v1.cri".containerd]
discard_unpacked_layers = false
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
discard_unpacked_layers = false
EOF
@@ -1,40 +0,0 @@
#!/usr/bin/env bash
set -e
set -o noglob
[ $(id -u) -eq 0 ] || exec sudo $0 $@
remove_interfaces() {
ip link show 2>/dev/null | grep 'cilium' | while read ignore iface ignore; do
iface=${iface%%@*}
[ -z "$iface" ] || (ip link delete $iface || true)
done
}
reset_iptables() {
iptables -t nat -F
iptables -t mangle -F
iptables -t filter -F
iptables -t raw -F
iptables -X
ip6tables -t nat -F
ip6tables -t mangle -F
ip6tables -t filter -F
ip6tables -t raw -F
ip6tables -X
}
do_unmount_and_remove() {
set +x
while read -r _ path _; do
case "$path" in $1*) echo "$path" ;; esac
done < /proc/self/mounts | sort -r | xargs -r -t -n 1 sh -c 'umount -f "$0" && rm -rf "$0"'
set -x
}
do_unmount_and_remove '/run/netns/cni-'
ip netns show 2>/dev/null | grep cni- | xargs -r -t -n 1 ip netns delete
remove_interfaces
reset_iptables
rm -rf /var/lib/cni
rm -rf /etc/cni/net.d
@@ -1,14 +0,0 @@
#!/usr/bin/env bash
set -e
set -o noglob
[ $(id -u) -eq 0 ] || exec sudo $0 $@
# Remove containerd config
rm -rf /etc/k0s/containerd.d
# Remove local storage data
rm -rf /var/openebs/local
# Reboot
(sleep 30 && systemctl reboot)&