fix: remove local hostpath and cilium lb vars and update k0s (#1261)
Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
1 parent
95b0e2b0d8
commit
4ac206aef5
11 files changed
+32
-56
No files matched your search
@@ -0,0 +1,18 @@
|
||||
#!/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 >/var/lib/k0s/manifests/kube-vip/kube-vip-rbac.yaml <<EOF
|
||||
#% include 'partials/kube-vip-rbac.partial.yaml.j2' %#
|
||||
EOF
|
||||
|
||||
# Create kube-vip daemonset
|
||||
cat >/var/lib/k0s/manifests/kube-vip/kube-vip-ds.yaml <<EOF
|
||||
#% include 'partials/kube-vip-ds.partial.yaml.j2' %#
|
||||
EOF
|
||||
@@ -0,0 +1,81 @@
|
||||
#!/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 "#{ bootstrap_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
|
||||
|
||||
#% if bootstrap_advanced_flags.update_resolv_conf|default(true) %#
|
||||
# Update DNS
|
||||
chattr -i /etc/resolv.conf
|
||||
rm -f /etc/resolv.conf
|
||||
cat >/etc/resolv.conf <<EOF
|
||||
search .
|
||||
nameserver #{ bootstrap_dns_server }#
|
||||
EOF
|
||||
chattr +i /etc/resolv.conf
|
||||
#% endif %#
|
||||
|
||||
# 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 >/etc/sysctl.d/99-kubernetes.conf <<EOF
|
||||
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 >/etc/k0s/containerd.d/default.toml <<EOF
|
||||
[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
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/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
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/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 10 && systemctl reboot)&
|
||||
Reference in new issue
Block a user