Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cofniecie sie K3s do starszej wersji #196

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 44 additions & 26 deletions scripts/chce_k3s.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
#!/bin/bash
# instalacja k3s (lLghtweight Kubernetes) na mikrusie
# Maciej Loper @2023.05

# ustawienia
SERVICE_FILE="/etc/systemd/system/k3s.service"
SERVICE_NAME="k3s"

# zaintaluj wg dokumentacji
# https://docs.k3s.io/quick-start
curl -sfL https://get.k3s.io | sh -

# zatrzymanie uslugi
/bin/systemctl disable --now "$SERVICE_NAME"

# kopia zapasowa
cp "$SERVICE_FILE" "${SERVICE_FILE}.bak"

# dodanie poprawki do pliku
sed -i '$d' "$SERVICE_FILE"
cat <<EOF >>"$SERVICE_FILE"
# Autor: Maciej Loper @2023.05
# Edytowane przez: Andrzej Szczepaniak @2023.11
# Edytowane, ze wzgledu na to, ze dual-stack nie dziala na najnowszej wersji K3s

# pobranie binarki K3s w wersji 1.27.6+k3s1
wget -O /usr/local/bin/k3s https://github.com/k3s-io/k3s/releases/download/v1.27.6%2Bk3s1/k3s

# nadanie uprawnien binarce k3s
chmod +x /usr/local/bin/k3s

# przygotowanie serwisu k3s
cat <<EOF >"/etc/systemd/system/k3s.service"
[Unit]
Description=Lightweight Kubernetes
Documentation=https://k3s.io
Wants=network-online.target
After=network-online.target

[Install]
WantedBy=multi-user.target

[Service]
Type=notify
EnvironmentFile=-/etc/default/%N
EnvironmentFile=-/etc/sysconfig/%N
EnvironmentFile=-/etc/systemd/system/k3s.service.env
KillMode=process
Delegate=yes
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=1048576
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
TimeoutStartSec=0
Restart=always
RestartSec=5s
ExecStartPre=/bin/sh -xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service'
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/k3s \\
server \\
--cluster-cidr=10.42.0.0/16,2001:cafe:42:0::/56 \\
--service-cidr=10.43.0.0/16,2001:cafe:42:1::/112 \\
--kubelet-arg=feature-gates=KubeletInUserNamespace=true \\
Expand All @@ -30,12 +53,7 @@ EOF
# odswiezenie systemd
/bin/systemctl daemon-reload

# uruchamienie uslugi + dodanie do autostartu
/bin/systemctl enable --now "$SERVICE_NAME"
# wlaczenie serwisu k3s oraz start uslugi k3s
systemctl enable --now k3s.service

exit

# rollback
/bin/systemctl disable --now k3s
cp /etc/systemd/system/k3s.service.bak /etc/systemd/system/k3s.service
/usr/local/bin/k3s-uninstall.sh
Loading