├── lugh.sh ├── vulcan.sh ├── nemesis.sh ├── beta ├── README.md └── Containerd-v2-02-k8s.sh ├── thoth.sh ├── README.md ├── legacy ├── Ubuntu2004-K8s_1_28-containerd-flannel.sh ├── Ubuntu2004-K8s_1_23-dockershim-calico.sh ├── Ubuntu2204-K8s_1_28-containerd-flannel.sh ├── Ubuntu2004-K8s_1_24-containerd-flannel.sh ├── Ubuntu2204-K8s_1_23-containerd-flannel.sh ├── Ubuntu2004-K8s_1_23-dockershim-flannel.sh ├── Ubuntu2204-K8s_v1-31-containerd-Cillum-multus.sh └── Ubuntu2404-K8s_1_33-containerd-flannel.sh ├── latest ├── Rocky_Linux-K8s_latest-containerd-flannel.sh ├── Unified-K8s_latest-containerd-flannel.sh └── Ubuntu-K8s_latest-containerd-flannel.sh └── LICENSE /lugh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[info] Running lugh for tool installations." 4 | -------------------------------------------------------------------------------- /vulcan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[info] Running vulcan for k8s installaion." 4 | #KAIS_SAVEINSTALLATIONFILES=n 5 | #KAIS_VERBOSELEVEL=5 6 | #KAIS_NEWBIEMODE=n 7 | echo ${KAIS_SAVEINSTALLATIONFILES} 8 | echo ${KAIS_VERBOSELEVEL} 9 | echo ${KAIS_NEWBIEMODE} 10 | -------------------------------------------------------------------------------- /nemesis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo kubeadm reset -f 4 | rm -rf ~/.kube 5 | sudo apt remove -y --allow-change-held-packages kubelet kubectl kubeadm 6 | sudo apt autoremove -y 7 | 8 | sudo systemctl stop docker.socket 9 | sudo systemctl stop docker.service 10 | sudo dpkg --purge docker-ce-cli docker-ce containerd.io 11 | 12 | sudo rm -rf /var/lib/docker /etc/docker 13 | sudo rm /etc/apparmor.d/docker 14 | sudo groupdel docker 15 | sudo rm -rf /var/run/docker.sock 16 | 17 | sudo systemctl stop containerd 18 | sudo dpkg --purge containerd.io 19 | sudo dpkg --purge containerd 20 | sudo rm -rf /var/lib/containerd/ 21 | -------------------------------------------------------------------------------- /beta/README.md: -------------------------------------------------------------------------------- 1 | # Script to install newest containerd (v2.0.2) 2 | **you can run the script to install containerd,runc and cni-plugin** 3 | 4 | **since containerd.io(which maintain by docker) and apt package only support until 1.7.25-1** 5 | 6 | **docker-ce will not be installed with this version** 7 | 8 | **you can run the script to install** 9 | 10 | ```bash= 11 | sudo bash Containerd-v2-02-k8s.sh 12 | # or 13 | curl https://raw.githubusercontent.com/kanic1111/KAIS/main/beta/Containerd-v2-02-k8s.sh | bash 14 | ``` 15 | 16 | >[!Note] 17 | > **The Script has been test to work with Ubuntu22.04 and kubernetes v1.31.5 and should be able to work on ubuntu24.04** 18 | 19 | **if you want to have similar enviroment like docker you can already install [nerdctl](https://github.com/containerd/nerdctl) which provide command like docker but are for containrd** 20 | ```bash= 21 | wget https://github.com/containerd/nerdctl/releases/download/v2.0.3/nerdctl-2.0.3-linux-amd64.tar.gz 22 | tar Cxzvvf /usr/local nerdctl-2.0.3-linux-amd64.tar.gz 23 | ``` 24 | -------------------------------------------------------------------------------- /thoth.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "[info] running preflight checks!" 4 | 5 | os_detect() { 6 | arch=$(uname -m) 7 | echo "${arch}" 8 | 9 | case "${arch}" in 10 | x86_64) 11 | echo "amd64" 12 | ;; 13 | arm64) 14 | echo "arm64" 15 | ;; 16 | aarch64) 17 | echo "arm64" 18 | ;; 19 | *) 20 | echo "unknow arch" 21 | ;; 22 | esac 23 | 24 | # Platform Detection 25 | # ref: https://stackoverflow.com/questions/394230/how-to-detect-the-os-from-a-bash-script 26 | if [[ "$OSTYPE" == "linux-gnu"* ]]; then 27 | echo "On linux" 28 | elif [[ "$OSTYPE" == "darwin"* ]]; then 29 | echo "On macOS" 30 | elif [[ "$OSTYPE" == "cygwin" ]]; then 31 | echo "A computer is like air conditioning – it becomes useless when you open..." 32 | elif [[ "$OSTYPE" == "msys" ]]; then 33 | echo "A computer is like air conditioning – it becomes useless when you open..." 34 | elif [[ "$OSTYPE" == "win32" ]]; then 35 | echo "A computer is like air conditioning – it becomes useless when you open..." 36 | elif [[ "$OSTYPE" == "freebsd"* ]]; then 37 | echo "On freebsd" 38 | else 39 | echo "Not supported OS?" 40 | fi 41 | 42 | # TDL: distro detection 43 | } 44 | 45 | os_detect 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KAIS 2 | ## 介紹 / Intro 3 | KAIS 是 `Kubernete 自動安裝腳本` 的簡稱,其目標為提供新手更簡易建立叢集的方式,並在過程中保持可以調整不同設置的彈性。
4 | KAIS is short for `Kubernetes Auto Install Script`, it is made for a more easy way for newbies to install kubernetes while keeping the flexibility to have different choice for setting up the cluster. 5 | 6 | 目前支援環境\ 7 | Current Supported ENVs 8 | |OS \ Arch|amd64(x86_64)|arm64(aarch64)|其他 (other)|最後驗證版本 (Last Verified Version)| 9 | |-|:-:|:-:|:-:|:-:| 10 | |Ubuntu|✅|✅|❌|24@250808| 11 | |Rocky Linux|✅|✅|❌|10@250808| 12 | |RHEL|✅|✅|❌|10@250808| 13 | |Debian|✅|✅|❌|12@250808| 14 | |Arch|To be added|To be added|❌|N/A| 15 | 16 | 17 | ## 使用方式 / Usage 18 | ### 裝環境 / Setting up 19 | `latest` 為 `最新版` 安裝方式,腳本命名邏輯為 `$發行版-K8s_latest-$CRI-$CNI`\ 20 | `latest` folder is for `latest version` of installations, script naming follows the pattern of `$Disto-K8s_latest-$CRI-$CNI` 21 | 22 | 快速部署(最新版本) / Deploy in one line(latest version)\ 23 | 24 | 如果你懶得找特定的發行版,跑這隻通用安裝腳本 / If you are lazy finding you distro info, run this unified install script 25 | ``` 26 | curl https://raw.githubusercontent.com/vincent5753/KAIS/main/latest/Unified-K8s_latest-containerd-flannel.sh | bash 27 | ``` 28 | 29 | 作業系統 / OS: `Ubuntu / Debian (amd64/arm64)` 30 | ``` 31 | curl https://raw.githubusercontent.com/vincent5753/KAIS/main/latest/Ubuntu-K8s_latest-containerd-flannel.sh | bash 32 | ``` 33 | 34 | 作業系統 / OS: `Rocky Linux / RHEL (amd64/arm64)` 35 | ``` 36 | curl https://raw.githubusercontent.com/vincent5753/KAIS/refs/heads/main/latest/Rocky_Linux-K8s_latest-containerd-flannel.sh | bash 37 | ``` 38 | 39 | `legacy` 為 `舊版` 安裝方式,腳本命名邏輯為 `$發行版-K8s-$K8s_版本-$CRI-$CNI`\ 40 | `legacy` folder is for `old-way` installations, script naming follows the pattern of `$Disto-K8s-$K8s_Version-$CRI-$CNI` 41 | 42 | 如果你想安裝特定的舊版本\ 43 | If you want to install an specifc older version. 44 | ``` 45 | curl https://raw.githubusercontent.com/vincent5753/KAIS/main/legacy/Ubuntu2404-K8s_1_33-containerd-flannel.sh | bash 46 | ``` 47 | 48 | ### 拆環境 / Clean up 49 | 快速拆除 / Clean up in one line 50 | ``` 51 | curl https://raw.githubusercontent.com/vincent5753/KAIS/main/nemesis.sh | bash 52 | ``` 53 | 54 | ## 待辦 / TDL 55 | + 環境偵測(Preflight Detects) 56 | + 依據參數部署(Deploy using args) 57 | + 解耦部署(Decoupled Deployment) 58 | + 自我部署(Self Deploying) 59 | -------------------------------------------------------------------------------- /legacy/Ubuntu2004-K8s_1_28-containerd-flannel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # By VP@23.08.17 3 | 4 | # Install bacsic packages 5 | sudo apt-get install -y apt-transport-https ca-certificates curl gnupg 6 | 7 | # Install Docker From Docker Official 8 | curl -Ol https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/containerd.io_1.6.22-1_amd64.deb 9 | curl -Ol https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce_24.0.5-1~ubuntu.20.04~focal_amd64.deb 10 | curl -Ol https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-cli_24.0.5-1~ubuntu.20.04~focal_amd64.deb 11 | sudo dpkg -i *.deb 12 | rm *.deb 13 | sudo usermod -aG docker $USER 14 | sudo systemctl start docker 15 | sudo systemctl enable docker 16 | sudo docker version 17 | 18 | sudo mkdir -p /etc/containerd 19 | sudo containerd config default | sudo tee /etc/containerd/config.toml 20 | sudo sed -i "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml 21 | grep SystemdCgroup /etc/containerd/config.toml 22 | sudo systemctl restart containerd 23 | 24 | # change docker cgroup driver to systemd 25 | cat <> ~/.bashrc 70 | 71 | # Init cluster 72 | sudo kubeadm init --pod-network-cidr=192.168.0.0/16 73 | ## Copy Config 74 | mkdir -p $HOME/.kube 75 | sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config 76 | sudo chown $(id -u):$(id -g) $HOME/.kube/config 77 | 78 | ### calico CNI 79 | kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.24.1/manifests/tigera-operator.yaml 80 | kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.24.1/manifests/custom-resources.yaml 81 | 82 | ## Waiting until Ready 83 | kubectl cluster-info 84 | watch -n 1 kubectl get nodes 85 | watch kubectl get pods -n calico-system 86 | 87 | ## Taint(if needed) 88 | kubectl taint nodes --all node-role.kubernetes.io/master- 89 | #kubectl taint nodes --all node-role.kubernetes.io/control-plane- node-role.kubernetes.io/master- 90 | -------------------------------------------------------------------------------- /legacy/Ubuntu2204-K8s_1_28-containerd-flannel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # By VP@23.08.17 3 | 4 | # Install bacsic packages 5 | sudo apt-get install -y apt-transport-https ca-certificates curl gnupg 6 | 7 | # Install Docker From Docker Official 8 | curl -Ol https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/containerd.io_1.6.22-1_amd64.deb 9 | curl -Ol https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce_24.0.5-1~ubuntu.20.04~focal_amd64.deb 10 | curl -Ol https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-cli_24.0.5-1~ubuntu.20.04~focal_amd64.deb 11 | sudo dpkg -i *.deb 12 | rm *.deb 13 | sudo usermod -aG docker $USER 14 | sudo systemctl start docker 15 | sudo systemctl enable docker 16 | sudo docker version 17 | 18 | sudo mkdir -p /etc/containerd 19 | sudo containerd config default | sudo tee /etc/containerd/config.toml 20 | sudo sed -i "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml 21 | grep SystemdCgroup /etc/containerd/config.toml 22 | sudo systemctl restart containerd 23 | 24 | # change docker cgroup driver to systemd 25 | cat <> /etc/sysctl.conf' 52 | sudo bash -c 'echo net.bridge.bridge-nf-call-iptables=1 >> /etc/sysctl.conf' 53 | sudo bash -c 'echo net.ipv4.ip_forward=1 >> /etc/sysctl.conf' 54 | sudo bash -c 'echo vm.swappiness=0 >> /etc/sysctl.conf' 55 | sudo sysctl -p 56 | 57 | sudo sed -i 's/sandbox_image = "k8s.gcr.io\/pause:3.6"/sandbox_image = "registry.k8s.io\/pause:3.6"/g' /etc/containerd/config.toml 58 | sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml 59 | 60 | sudo systemctl --no-pager --full restart containerd 61 | systemctl status containerd --no-pager 62 | kubeadm config images list --image-repository=registry.k8s.io --kubernetes-version=v1.24.17 63 | kubeadm config images pull --image-repository=registry.k8s.io --kubernetes-version=v1.24.17 64 | sudo kubeadm init --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16 --image-repository=registry.k8s.io --v=6 65 | 66 | mkdir -p $HOME/.kube 67 | sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config 68 | sudo chown $(id -u):$(id -g) $HOME/.kube/config 69 | 70 | kubectl taint nodes --all node-role.kubernetes.io/master- 71 | kubectl taint nodes --all node-role.kubernetes.io/control-plane- 72 | kubectl apply -f https://github.com/flannel-io/flannel/releases/download/v0.24.4/kube-flannel.yml 73 | watch -n 5 kubectl get po -A -o wide 74 | -------------------------------------------------------------------------------- /legacy/Ubuntu2204-K8s_1_23-containerd-flannel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Install basic packages 4 | sudo apt-get update -y 5 | sudo apt-get install -y apt-transport-https ca-certificates curl gnupg 6 | 7 | # Install Docker From Docker Official 8 | DOCKER_DEB=( 9 | containerd.io_1.5.10-1_amd64.deb \ 10 | docker-ce-cli_20.10.9~3-0~ubuntu-focal_amd64.deb \ 11 | docker-ce_20.10.9~3-0~ubuntu-focal_amd64.deb 12 | ) 13 | for DEB in ${DOCKER_DEB[@]} 14 | do 15 | curl -s --create-dirs -o /tmp/docker_debs/$DEB https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/$DEB 16 | sudo dpkg -i /tmp/docker_debs/$DEB 17 | sudo rm -rf /tmp/docker_debs 18 | done 19 | 20 | sudo usermod -aG docker $USER 21 | sudo systemctl enable docker --now 22 | sudo docker version 23 | 24 | # change docker cgroup driver to systemd 25 | cat <> ~/.bashrc 67 | 68 | # Pre-Pull Kubernetes Component Image 69 | # sudo docker pull registry.k8s.io/kube-apiserver-amd64:v1.23.17 70 | # sudo docker pull registry.k8s.io/kube-controller-manager-amd64:v1.23.17 71 | # sudo docker pull registry.k8s.io/kube-scheduler-amd64:v1.23.17 72 | # sudo docker pull registry.k8s.io/kube-proxy-amd64:v1.23.17 73 | # sudo docker pull registry.k8s.io/pause:3.6 74 | # sudo docker pull registry.k8s.io/etcd:3.5.1-0 75 | # sudo docker pull registry.k8s.io/coredns/coredns:v1.8.6 76 | # https://kubernetes.io/docs/reference/setup-tools/kubeadm/generated/kubeadm_config_images_pull/ 77 | kubeadm config images list --image-repository=registry.k8s.io --kubernetes-version=v1.23.17 78 | kubeadm config images pull --image-repository=registry.k8s.io --kubernetes-version=v1.23.17 79 | 80 | # Init cluster 81 | sudo kubeadm init --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16 --v=6 82 | ## Copy Config 83 | mkdir -p $HOME/.kube 84 | sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config 85 | sudo chown $(id -u):$(id -g) $HOME/.kube/config 86 | 87 | ## Flannel CNI 88 | kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml 89 | 90 | ## Waiting until Ready 91 | kubectl cluster-info 92 | watch -n 1 kubectl get nodes -o wide 93 | 94 | ## Taint(if needed) 95 | kubectl taint nodes --all node-role.kubernetes.io/master- 96 | -------------------------------------------------------------------------------- /beta/Containerd-v2-02-k8s.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get install -y apt-transport-https ca-certificates curl gnupg 2 | 3 | # Install containerd v2.0.2 4 | wget https://github.com/containerd/containerd/releases/download/v2.0.2/containerd-2.0.2-linux-amd64.tar.gz 5 | curl -Ol https://raw.githubusercontent.com/containerd/containerd/main/containerd.service 6 | sudo tar Cxzvf /usr/local containerd-2.0.2-linux-amd64.tar.gz 7 | 8 | # Set Containerd to start via systemd 9 | sudo mv containerd.service /lib/systemd/system/containerd.service 10 | sudo systemctl daemon-reload 11 | sudo systemctl enable --now containerd 12 | 13 | # install runc 14 | wget https://github.com/opencontainers/runc/releases/download/v1.2.4/runc.amd64 15 | sudo install -m 755 runc.amd64 /usr/local/sbin/runc 16 | 17 | # install containderd CNI plugin 18 | wget https://github.com/containernetworking/plugins/releases/download/v1.6.2/cni-plugins-linux-amd64-v1.6.2.tgz 19 | sudo mkdir -p /opt/cni/bin 20 | sudo tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.6.2.tgz 21 | 22 | # remove file after installed 23 | sudo rm *.tar.gz runc.amd64 *.tgz 24 | 25 | 26 | # Set SystemCgroup 27 | sudo mkdir -p /etc/containerd 28 | sudo containerd config default | sudo tee /etc/containerd/config.toml 29 | sudo sed -i "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml 30 | grep SystemdCgroup /etc/containerd/config.toml 31 | sudo systemctl restart containerd 32 | 33 | 34 | # download kubernetes keyring 35 | curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg 36 | echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list 37 | sudo apt-get update 38 | 39 | # Essential Tweaks 40 | sudo swapoff -a 41 | cat << EOF | sudo tee /etc/modules-load.d/k8s.conf 42 | overlay 43 | br_netfilter 44 | EOF 45 | sudo modprobe overlay 46 | sudo modprobe br_netfilter 47 | cat <> ~/.bashrc 71 | sudo crictl config runtime-endpoint unix:///var/run/containerd/containerd.sock 72 | # Install cillum-cli 73 | CILIUM_CLI_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt) 74 | CLI_ARCH=amd64 75 | if [ "$(uname -m)" = "aarch64" ]; then CLI_ARCH=arm64; fi 76 | curl -L --fail --remote-name-all https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum} 77 | sha256sum --check cilium-linux-${CLI_ARCH}.tar.gz.sha256sum 78 | sudo tar xzvfC cilium-linux-${CLI_ARCH}.tar.gz /usr/local/bin 79 | rm cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum} 80 | 81 | # install cillum with cni-exclusive OFF 82 | cilium install --version 1.16.5 --set cni.exclusive=false 83 | -------------------------------------------------------------------------------- /legacy/Ubuntu2004-K8s_1_23-dockershim-flannel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Verified by VP@22.04.03 02:45:44(+8) ( also playing Elden Ring :) ) 3 | 4 | # Install basic packages 5 | sudo apt-get update -y 6 | sudo apt-get install -y apt-transport-https ca-certificates curl gnupg 7 | 8 | # Install Docker From Docker Official 9 | DOCKER_DEB=( 10 | containerd.io_1.5.10-1_amd64.deb \ 11 | docker-ce-cli_20.10.9~3-0~ubuntu-focal_amd64.deb \ 12 | docker-ce_20.10.9~3-0~ubuntu-focal_amd64.deb 13 | ) 14 | for DEB in ${DOCKER_DEB[@]} 15 | do 16 | curl -s --create-dirs -o /tmp/docker_debs/$DEB https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/$DEB 17 | sudo dpkg -i /tmp/docker_debs/$DEB 18 | sudo rm -rf /tmp/docker_debs 19 | done 20 | 21 | sudo usermod -aG docker $USER 22 | sudo systemctl enable docker --now 23 | sudo docker version 24 | 25 | # change docker cgroup driver to systemd 26 | cat <> ~/.bashrc 71 | 72 | # Pre-Pull Kubernetes Component Image 73 | # sudo docker pull registry.k8s.io/kube-apiserver-amd64:v1.23.17 74 | # sudo docker pull registry.k8s.io/kube-controller-manager-amd64:v1.23.17 75 | # sudo docker pull registry.k8s.io/kube-scheduler-amd64:v1.23.17 76 | # sudo docker pull registry.k8s.io/kube-proxy-amd64:v1.23.17 77 | # sudo docker pull registry.k8s.io/pause:3.6 78 | # sudo docker pull registry.k8s.io/etcd:3.5.1-0 79 | # sudo docker pull registry.k8s.io/coredns/coredns:v1.8.6 80 | # https://kubernetes.io/docs/reference/setup-tools/kubeadm/generated/kubeadm_config_images_pull/ 81 | sudo kubeadm config images list --image-repository=registry.k8s.io --kubernetes-version=v1.23.17 82 | sudo kubeadm config images pull --image-repository=registry.k8s.io --kubernetes-version=v1.23.17 83 | 84 | # Init cluster 85 | sudo kubeadm init --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16 --v=6 86 | 87 | ## Copy Config 88 | mkdir -p $HOME/.kube 89 | sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config 90 | sudo chown $(id -u):$(id -g) $HOME/.kube/config 91 | 92 | ## Flannel CNI 93 | kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml 94 | 95 | ## Waiting until Ready 96 | kubectl cluster-info 97 | watch -n 1 kubectl get nodes -o wide 98 | 99 | ## Taint(if needed) 100 | kubectl taint nodes --all node-role.kubernetes.io/master- 101 | -------------------------------------------------------------------------------- /legacy/Ubuntu2204-K8s_v1-31-containerd-Cillum-multus.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get install -y apt-transport-https ca-certificates curl gnupg 2 | 3 | # Install Docker From Docker Official 4 | curl -Ol https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/containerd.io_1.7.25-1_amd64.deb 5 | curl -Ol https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce_27.5.1-1~ubuntu.22.04~jammy_amd64.deb 6 | curl -Ol https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce-rootless-extras_27.5.1-1~ubuntu.22.04~jammy_amd64.deb 7 | curl -Ol https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce-cli_27.5.1-1~ubuntu.22.04~jammy_amd64.deb 8 | 9 | sudo dpkg -i *.deb 10 | rm *.deb 11 | sudo usermod -aG docker $USER 12 | sudo systemctl start docker 13 | sudo systemctl enable docker 14 | sudo docker version 15 | 16 | sudo mkdir -p /etc/containerd 17 | sudo containerd config default | sudo tee /etc/containerd/config.toml 18 | sudo sed -i "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml 19 | grep SystemdCgroup /etc/containerd/config.toml 20 | sudo systemctl restart containerd 21 | 22 | # change docker cgroup driver to systemd 23 | cat <> ~/.bashrc 80 | sudo crictl config runtime-endpoint unix:///var/run/containerd/containerd.sock 81 | # Install cillum-cli 82 | CILIUM_CLI_VERSION=$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt) 83 | CLI_ARCH=amd64 84 | if [ "$(uname -m)" = "aarch64" ]; then CLI_ARCH=arm64; fi 85 | curl -L --fail --remote-name-all https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum} 86 | sha256sum --check cilium-linux-${CLI_ARCH}.tar.gz.sha256sum 87 | sudo tar xzvfC cilium-linux-${CLI_ARCH}.tar.gz /usr/local/bin 88 | rm cilium-linux-${CLI_ARCH}.tar.gz{,.sha256sum} 89 | 90 | # install cillum with cni-exclusive OFF 91 | cilium install --version 1.16.5 --set cni.exclusive=false 92 | -------------------------------------------------------------------------------- /latest/Rocky_Linux-K8s_latest-containerd-flannel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | K8S_CONTROL_PLANE_PACKAGE=( 6 | kubelet 7 | kubeadm 8 | kubectl 9 | ) 10 | 11 | K8S_WORKER_NODE_PACKAGE=( 12 | kubelet 13 | kubeadm 14 | ) 15 | 16 | 17 | 18 | _info(){ 19 | echo "[INFO] $1" 20 | } 21 | 22 | 23 | _error(){ 24 | echo "[ERROR] $1" 25 | } 26 | 27 | 28 | 29 | check_command_available(){ 30 | 31 | local command_name="$1" 32 | 33 | which "${command_name}" > /dev/null 2>&1 34 | 35 | if [ $? -eq 0 ] 36 | then 37 | return 0 38 | else 39 | return 1 40 | fi 41 | 42 | } 43 | 44 | 45 | get_k8s_relaese_version(){ 46 | 47 | local K8S_RELEASE_URL="https://dl.k8s.io/release/stable.txt" 48 | 49 | _info "Fetching latest stable Kubernetes version..." 50 | 51 | K8S_FULL_VERSION=$(curl -Ls "${K8S_RELEASE_URL}") 52 | 53 | if [ -z "$K8S_FULL_VERSION" ]; then 54 | _error "Could not fetch Kubernetes version from ${K8S_RELEASE_URL}" 55 | exit 1 56 | fi 57 | 58 | K8S_VERSION_NO_V=$(echo "$K8S_FULL_VERSION" | sed 's/^v//') 59 | K8S_MAJOR_MINOR_VERSION=$(echo "$K8S_VERSION_NO_V" | cut -d'.' -f1,2) 60 | 61 | # _info "Latest Kubernetes Full Version: ${K8S_FULL_VERSION}" 62 | # _info "Latest Kubernetes Version: ${K8S_VERSION_NO_V}" 63 | _info "Latest Kubernetes MAJOR_MINOR Version: ${K8S_MAJOR_MINOR_VERSION}" 64 | 65 | } 66 | 67 | 68 | disable_selinux(){ 69 | 70 | sudo setenforce 0 71 | sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config 72 | 73 | } 74 | 75 | 76 | add_yum_repo(){ 77 | 78 | sudo yum-config-manager --add-repo "$1" 79 | 80 | } 81 | 82 | 83 | install_dnf_packages(){ 84 | 85 | if [ "$#" -eq 0 ]; then 86 | _error "Please provide at least one package name to install." 87 | return 1 88 | fi 89 | 90 | _info "Updating package lists..." 91 | sudo dnf check-update -y 92 | 93 | _info "Installing specified packages..." 94 | for package in "$@"; do 95 | _info "Checking if ${package} is already callable..." 96 | if check_command_available "${package}"; then 97 | _info "${package} is already callable. Skipping installation." 98 | else 99 | _info "Attempting to install: ${package}" 100 | sudo dnf install -y "${package}" 101 | if [ $? -eq 0 ]; then 102 | _info "${package} installed successfully." 103 | else 104 | _error "Failed to install ${package}. Please check the package name or your internet connection." 105 | fi 106 | fi 107 | done 108 | 109 | } 110 | 111 | 112 | change_containerd_to_cgroup_driver(){ 113 | 114 | _info "Setting up containerd to use cgroup driver" 115 | sudo mkdir -p /etc/containerd 116 | sudo containerd config default | sudo tee /etc/containerd/config.toml 117 | sudo sed -i "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml 118 | sudo systemctl restart containerd 119 | 120 | } 121 | 122 | 123 | add_k8s_yum_repo(){ 124 | 125 | cat < /dev/null 2>&1 98 | 99 | if [ $? -eq 0 ] 100 | then 101 | return 0 102 | else 103 | return 1 104 | fi 105 | 106 | } 107 | 108 | 109 | install_apt_packages(){ 110 | 111 | if [ "$#" -eq 0 ]; then 112 | _error "Please provide at least one package name to install." 113 | return 1 114 | fi 115 | 116 | _info "Updating package lists..." 117 | sudo apt-get update -y 118 | 119 | _info "Installing specified packages..." 120 | for package in "$@"; do 121 | _info "Checking if ${package} is already callable..." 122 | if check_command_available "${package}"; then 123 | _info "${package} is already callable. Skipping installation." 124 | else 125 | _info "Attempting to install: ${package}" 126 | sudo apt-get install -y "${package}" 127 | if [ $? -eq 0 ]; then 128 | _info "${package} installed successfully." 129 | else 130 | _error "Failed to install ${package}. Please check the package name or your internet connection." 131 | fi 132 | fi 133 | done 134 | 135 | _info "Package installation process completed." 136 | 137 | } 138 | 139 | 140 | mark_apt_packages(){ 141 | 142 | if [ "$#" -eq 0 ]; then 143 | _error "Please provide at least one package name to mark." 144 | return 1 145 | fi 146 | 147 | sudo apt-mark hold "$@" 148 | 149 | } 150 | 151 | 152 | install_docker_runtime(){ 153 | 154 | _info "Checking if iptables is installed" 155 | if check_command_available "iptables" 156 | then 157 | _info "iptables is installed." 158 | else 159 | _info "iptables is NOT installed, installing it cuz docker-ce needs it." 160 | install_apt_packages iptables 161 | fi 162 | 163 | base_url="https://download.docker.com/linux/ubuntu/dists/${OS_CODE_NAME}/pool/stable/${CPU_ARCH}" 164 | 165 | _info "Download and installing debs from docker" 166 | for DEB in ${DOCKER_DEB[@]} 167 | do 168 | _info "Download and installing ${DEB}" 169 | curl -s --create-dirs -o "${TEMP_DIR}/docker_debs/${DEB}" "${base_url}/$DEB" 170 | sudo dpkg -i "${TEMP_DIR}/docker_debs/${DEB}" 171 | done 172 | 173 | # containerd 174 | _info "Setting up containerd" 175 | sudo mkdir -p /etc/containerd 176 | sudo containerd config default | sudo tee /etc/containerd/config.toml 177 | sudo sed -i "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml 178 | grep SystemdCgroup /etc/containerd/config.toml 179 | sudo systemctl restart containerd 180 | 181 | _info "Changing docker cgroup driver to systemd" 182 | cat < /dev/null 2>&1 44 | 45 | if [ $? -eq 0 ] 46 | then 47 | return 0 48 | else 49 | return 1 50 | fi 51 | 52 | } 53 | 54 | disable_selinux(){ 55 | 56 | _info "Disabling SELinux..." 57 | sudo setenforce 0 58 | sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config 59 | 60 | } 61 | 62 | 63 | add_yum_repo(){ 64 | 65 | sudo yum-config-manager --add-repo "$1" 66 | 67 | } 68 | 69 | 70 | install_dnf_packages(){ 71 | 72 | if [ "$#" -eq 0 ]; then 73 | _error "Please provide at least one package name to install." 74 | return 1 75 | fi 76 | 77 | _info "Updating package lists..." 78 | sudo dnf check-update -y 79 | 80 | _info "Installing specified packages..." 81 | for package in "$@"; do 82 | _info "Checking if ${package} is already callable..." 83 | if check_command_available "${package}"; then 84 | _info "${package} is already callable. Skipping installation." 85 | else 86 | _info "Attempting to install: ${package}" 87 | sudo dnf install -y "${package}" 88 | if [ $? -eq 0 ]; then 89 | _info "${package} installed successfully." 90 | else 91 | _error "Failed to install ${package}. Please check the package name or your internet connection." 92 | fi 93 | fi 94 | done 95 | 96 | } 97 | 98 | add_k8s_yum_repo(){ 99 | 100 | cat < /dev/null 302 | sudo apt-get update 303 | install_apt_packages "containerd.io" 304 | sudo systemctl enable containerd 305 | change_containerd_to_cgroup_driver 306 | add_k8s_apt_repo 307 | do_k8s_tweaks 308 | K8S_PACKAGES=( 309 | kubelet 310 | kubeadm 311 | kubectl 312 | ) 313 | install_apt_packages "${K8S_PACKAGES[@]}" 314 | mark_apt_packages "${K8S_PACKAGES[@]}" 315 | else 316 | _error "Unsupported OS family: $OS_FAMILY" 317 | exit 1 318 | fi 319 | 320 | sudo systemctl enable --now kubelet 321 | sudo kubeadm init --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16 --image-repository=registry.k8s.io --v=6 322 | copy_kube_config 323 | remove_node_taint 324 | kubectl apply -f https://github.com/flannel-io/flannel/releases/download/${FLANNEL_VERSION}/kube-flannel.yml 325 | 326 | } 327 | 328 | main 329 | -------------------------------------------------------------------------------- /latest/Ubuntu-K8s_latest-containerd-flannel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | TEMP_DIR="/tmp/kais" 6 | 7 | PACKAGES_TO_INSTALL=( 8 | apt-transport-https 9 | ca-certificates 10 | curl 11 | gpg 12 | ) 13 | 14 | K8S_CONTROL_PLANE_PACKAGE=( 15 | kubelet 16 | kubeadm 17 | kubectl 18 | ) 19 | 20 | K8S_WORKER_NODE_PACKAGE=( 21 | kubelet 22 | kubeadm 23 | ) 24 | 25 | 26 | 27 | _mk_tmp_dir(){ 28 | mkdir "${TEMP_DIR}" 29 | } 30 | 31 | 32 | _clean_up(){ 33 | 34 | sudo rm -rf "${TEMP_DIR}" 35 | 36 | } 37 | 38 | 39 | _info(){ 40 | echo "[INFO] $1" 41 | } 42 | 43 | 44 | _error(){ 45 | echo "[ERROR] $1" 46 | } 47 | 48 | 49 | _get_latest_docker_version(){ 50 | 51 | local request_result 52 | request_result=$(curl https://download.docker.com/linux/${OS_ID}/dists/${OS_CODE_NAME}/pool/stable/${CPU_ARCH}/) 53 | 54 | for package in docker-ce docker-ce-cli containerd.io 55 | do 56 | 57 | package_version=$(echo "${request_result}" | grep "${package}_" | sed -n "s/.*${package}_\([^_]*\)_${CPU_ARCH}\.deb.*/\1/p" | sort -V | tail -n 1 | cut -d'~' -f1) 58 | 59 | case "${package}" in 60 | 61 | docker-ce) 62 | dockerce_version="${package_version}" 63 | ;; 64 | 65 | docker-ce-cli) 66 | dockercecli_version="${package_version}" 67 | ;; 68 | 69 | containerd.io) 70 | containerd_version="${package_version}" 71 | ;; 72 | 73 | *) 74 | _error "Unexpected package." 75 | ;; 76 | esac 77 | 78 | done 79 | 80 | } 81 | 82 | 83 | 84 | check_command_available(){ 85 | 86 | local command_name="$1" 87 | 88 | which "${command_name}" > /dev/null 2>&1 89 | 90 | if [ $? -eq 0 ] 91 | then 92 | return 0 93 | else 94 | return 1 95 | fi 96 | 97 | } 98 | 99 | 100 | get_os_info(){ 101 | 102 | OS_RELESE_VER=$(lsb_release -r -s 2>/dev/null) 103 | OS_CODE_NAME=$(lsb_release -c -s 2>/dev/null) 104 | OS_ID=$(lsb_release -i -s 2>/dev/null) 105 | 106 | case "${OS_ID}" in 107 | 108 | Debian) 109 | OS_ID="debian" 110 | ;; 111 | 112 | Ubuntu) 113 | OS_ID="ubuntu" 114 | ;; 115 | 116 | *) 117 | _error "Unexpected Distro ID." 118 | exit 1 119 | ;; 120 | esac 121 | _info "Detected OS_ID: ${OS_ID}" 122 | _info "Detected OS_CODE_NAME: ${OS_CODE_NAME}" 123 | _info "Detected OS_RELESE_VER: ${OS_RELESE_VER}" 124 | 125 | CPU_ARCH=$(uname -m) 126 | 127 | 128 | case "${CPU_ARCH}" in 129 | 130 | x86_64) 131 | CPU_ARCH="amd64" 132 | ;; 133 | 134 | amd64) 135 | CPU_ARCH="amd64" 136 | ;; 137 | 138 | aarch64) 139 | CPU_ARCH="arm64" 140 | ;; 141 | 142 | arm64) 143 | CPU_ARCH="arm64" 144 | ;; 145 | 146 | *) 147 | _error "Unexpected CPU ARCH." 148 | exit 1 149 | ;; 150 | esac 151 | 152 | _info "Detected CPU_ARCH: ${CPU_ARCH}" 153 | 154 | } 155 | 156 | 157 | get_k8s_relaese_version(){ 158 | 159 | local K8S_RELEASE_URL="https://dl.k8s.io/release/stable.txt" 160 | 161 | _info "Fetching latest stable Kubernetes version..." 162 | 163 | K8S_FULL_VERSION=$(curl -Ls "${K8S_RELEASE_URL}") 164 | 165 | if [ -z "$K8S_FULL_VERSION" ]; then 166 | _error "Could not fetch Kubernetes version from ${K8S_RELEASE_URL}" 167 | exit 1 168 | fi 169 | 170 | K8S_VERSION_NO_V=$(echo "$K8S_FULL_VERSION" | sed 's/^v//') 171 | K8S_MAJOR_MINOR_VERSION=$(echo "$K8S_VERSION_NO_V" | cut -d'.' -f1,2) 172 | 173 | # _info "Latest Kubernetes Full Version: ${K8S_FULL_VERSION}" 174 | # _info "Latest Kubernetes Version: ${K8S_VERSION_NO_V}" 175 | _info "Latest Kubernetes MAJOR_MINOR Version: ${K8S_MAJOR_MINOR_VERSION}" 176 | 177 | } 178 | 179 | 180 | install_apt_packages(){ 181 | 182 | if [ "$#" -eq 0 ]; then 183 | _error "Please provide at least one package name to install." 184 | return 1 185 | fi 186 | 187 | _info "Updating package lists..." 188 | sudo apt-get update -y 189 | 190 | _info "Installing specified packages..." 191 | for package in "$@"; do 192 | _info "Checking if ${package} is already callable..." 193 | if check_command_available "${package}"; then 194 | _info "${package} is already callable. Skipping installation." 195 | else 196 | _info "Attempting to install: ${package}" 197 | sudo apt-get install -y "${package}" 198 | if [ $? -eq 0 ]; then 199 | _info "${package} installed successfully." 200 | else 201 | _error "Failed to install ${package}. Please check the package name or your internet connection." 202 | fi 203 | fi 204 | done 205 | 206 | _info "Package installation process completed." 207 | 208 | } 209 | 210 | 211 | mark_apt_packages(){ 212 | 213 | if [ "$#" -eq 0 ]; then 214 | _error "Please provide at least one package name to mark." 215 | return 1 216 | fi 217 | 218 | sudo apt-mark hold "$@" 219 | 220 | } 221 | 222 | 223 | install_docker_runtime(){ 224 | 225 | _info "Checking if iptables is installed" 226 | if check_command_available "iptables" 227 | then 228 | _info "iptables is installed." 229 | else 230 | _info "iptables is NOT installed, installing it cuz docker-ce needs it." 231 | install_apt_packages iptables 232 | fi 233 | 234 | base_url="https://download.docker.com/linux/${OS_ID}/dists/${OS_CODE_NAME}/pool/stable/${CPU_ARCH}" 235 | 236 | _info "Download and installing debs from docker" 237 | for DEB in ${DOCKER_DEB[@]} 238 | do 239 | _info "Download and installing ${DEB}" 240 | curl -s --create-dirs -o "${TEMP_DIR}/docker_debs/${DEB}" "${base_url}/$DEB" 241 | sudo dpkg -i "${TEMP_DIR}/docker_debs/${DEB}" 242 | done 243 | 244 | # containerd 245 | _info "Setting up containerd" 246 | sudo mkdir -p /etc/containerd 247 | sudo containerd config default | sudo tee /etc/containerd/config.toml 248 | sudo sed -i "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml 249 | grep SystemdCgroup /etc/containerd/config.toml 250 | sudo systemctl restart containerd 251 | 252 | _info "Changing docker cgroup driver to systemd" 253 | cat < 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------