Last active
July 18, 2023 05:26
-
-
Save saiyam1814/03700751b8d1068c18c942cf768ea26f to your computer and use it in GitHub Desktop.
kubernetes1.26.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B53DC80D13EDEF05 | |
echo "step1" | |
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list | |
echo "kubeadm install" | |
sudo apt update -y | |
sudo apt -y install vim git curl wget kubelet=1.26.1-00 kubeadm=1.26.1-00 kubectl=1.26.1-00 | |
echo "memory swapoff" | |
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab | |
sudo swapoff -a | |
sudo modprobe overlay | |
sudo modprobe br_netfilter | |
sudo tee /etc/modules-load.d/containerd.conf <<EOF | |
overlay | |
br_netfilter | |
EOF | |
sudo tee /etc/sysctl.d/kubernetes.conf<<EOF | |
net.bridge.bridge-nf-call-ip6tables = 1 | |
net.bridge.bridge-nf-call-iptables = 1 | |
net.ipv4.ip_forward = 1 | |
EOF | |
sysctl --system | |
if (systemctl -q is-active containerd) | |
then | |
echo "containerd is still running." | |
rm /etc/containerd/config.toml | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt update | |
sudo apt install -y containerd.io | |
mkdir -p /etc/containerd | |
containerd config default > /etc/containerd/config.toml | |
sudo systemctl restart containerd | |
sudo systemctl enable containerd | |
else | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt update | |
sudo apt install -y containerd.io | |
mkdir -p /etc/containerd | |
containerd config default > /etc/containerd/config.toml | |
sudo systemctl restart containerd | |
sudo systemctl enable containerd | |
fi | |
sudo systemctl enable kubelet | |
sudo kubeadm config images pull --cri-socket unix:///run/containerd/containerd.sock --kubernetes-version v1.26.1 | |
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --upload-certs --kubernetes-version=v1.26.1 --control-plane-endpoint=$(hostname) --ignore-preflight-errors=all --cri-socket unix:///run/containerd/containerd.sock | |
mkdir -p $HOME/.kube | |
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | |
sudo chown $(id -u):$(id -g) $HOME/.kube/config | |
export KUBECONFIG=/etc/kubernetes/admin.conf | |
kubectl apply -f https://github.com/coreos/flannel/raw/master/Documentation/kube-flannel.yml | |
kubectl taint node $(hostname) node-role.kubernetes.io/control-plane:NoSchedule- | |
kubectl taint node $(hostname) node-role.kubernetes.io/master:NoSchedule- | |
wget https://get.helm.sh/helm-v3.7.2-linux-amd64.tar.gz | |
tar -xvf helm-v3.7.2-linux-amd64.tar.gz | |
mv linux-amd64/helm /usr/local/bin/ |
Can you try these two commands ?
kubectl taint node $(hostname) node-role.kubernetes.io/control-plane:NoSchedule-
kubectl taint node $(hostname) node-role.kubernetes.io/master:NoSchedule-
Make sure to change the hostname
also run this to enable systemdcgroup (mandatory if its ubuntu 22.04)
sudo sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/g' /etc/containerd/config.toml
how does this setup behave on reboot?
It should work! @jessequinn
Just tested that as well
Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "aa14a9a310688b10221a9c64bd38d909a42da2e7f5432aaaafacaaf0bbf8e081": plugin type="loopback" failed (add): failed to find plugin "loopback │
│ " in path [/opt/cni/bin]
Are you installing the CNI plugins at any point?
Line number 53 installs flannel
Also make sure to do
sudo sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/g' /etc/containerd/config.toml
systemctl restart containerd
for me, i needed to do the following otherwise coredns would not run:
curl -fsSLo cni-plugins-linux-amd64-v1.1.1.tgz https://github.com/containernetworking/plugins/releases/download/v1.1.1/cni-plugins-linux-amd64-v1.1.1.tgz
sudo mkdir -p /opt/cni/bin
sudo tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.1.1.tgz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice work bro I have used it,
but its 4th time i am facing an issue regarding my coredns pods they are not starting due to tainat issue ,
Note : I am making my personal ubuntu as manager, I dont have any worker