Last active
October 30, 2023 11:41
-
-
Save mohammad76/4138103c8b699e076b497f5307d4c664 to your computer and use it in GitHub Desktop.
install kubernetes 1.25.9
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
#!/bin/bash | |
host_ip=$(hostname -i) | |
# Color | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
YELLOW='\033[0;33m' | |
NC='\033[0m' # No Color | |
echo -e "${GREEN}disable systemd resolved ...${NC}" | |
systemctl disable systemd-resolved.service | |
systemctl stop systemd-resolved | |
echo -e "${GREEN}add base dns ...${NC}" | |
rm /etc/resolv.conf | |
cat >/etc/resolv.conf <<EOF | |
nameserver 8.8.8.8 | |
nameserver 1.1.1.1 | |
EOF | |
echo -e "${GREEN}change server repo ...${NC}" | |
sed -i 's/archive.ubuntu.com/mirror.arvancloud.ir/g' /etc/apt/sources.list | |
sed -i 's/ir.mirror.arvancloud.ir/mirror.arvancloud.ir/g' /etc/apt/sources.list | |
sed -i 's/us.mirror.arvancloud.ir/mirror.arvancloud.ir/g' /etc/apt/sources.list | |
echo -e "${GREEN}updating os ...${NC}" | |
apt update -y && upgrade -y | |
echo -e "${GREEN}disable ipv6 ...${NC}" | |
sysctl -w net.ipv6.conf.all.disable_ipv6=1 | |
sysctl -w net.ipv6.conf.default.disable_ipv6=1 | |
sysctl -w net.ipv6.conf.lo.disable_ipv6=1 | |
sysctl -p | |
sed -i '/swap/s/^\(.*\)$/#\1/g' /etc/fstab | |
swapoff -a | |
modprobe overlay | |
modprobe br_netfilter | |
wget https://public-chabok.s3.ir-thr-at1.arvanstorage.com/kubernetes/containerd-1.6.2-linux-amd64.tar.gz | |
tar Czxvf /usr/local containerd-1.6.2-linux-amd64.tar.gz | |
wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service | |
mv containerd.service /usr/lib/systemd/system/ | |
systemctl daemon-reload | |
systemctl enable --now containerd | |
wget https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64 | |
install -m 755 runc.amd64 /usr/local/sbin/runc | |
mkdir -p /etc/containerd/ | |
containerd config default | sudo tee /etc/containerd/config.toml | |
systemctl restart containerd | |
mkdir -p /opt/cni/bin | |
wget https://public-chabok.s3.ir-thr-at1.arvanstorage.com/kubernetes/cni-plugins-linux-amd64-v1.1.1.tgz | |
tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.1.1.tgz | |
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf | |
overlay | |
br_netfilter | |
EOF | |
modprobe overlay | |
modprobe br_netfilter | |
echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables | |
echo 1 > /proc/sys/net/bridge/bridge-nf-call-ip6tables | |
sysctl -p | |
# sysctl params required by setup, params persist across reboots | |
cat > /etc/sysctl.d/99-k8s-cri.conf <<EOF | |
net.bridge.bridge-nf-call-iptables=1 | |
net.bridge.bridge-nf-call-ip6tables=1 | |
net.ipv4.ip_forward=1 | |
EOF | |
# Apply sysctl params without reboot | |
sudo sysctl --system | |
echo -e "${GREEN}add shecan dns ...${NC}" | |
rm /etc/resolv.conf | |
cat >/etc/resolv.conf <<EOF | |
nameserver 178.22.122.100 | |
nameserver 185.51.200.2 | |
EOF | |
apt update | |
apt install -y apt-transport-https ca-certificates curl bash-completion | |
curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://dl.k8s.io/apt/doc/apt-key.gpg | |
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list | |
apt update | |
apt install -y kubelet=1.25.9-00 kubeadm=1.25.9-00 kubectl=1.25.9-00 | |
apt-mark hold kubelet kubeadm kubectl | |
echo -e "${GREEN}add shecan dns ...${NC}" | |
rm /etc/resolv.conf | |
cat >/etc/resolv.conf <<EOF | |
nameserver 178.22.122.100 | |
nameserver 185.51.200.2 | |
EOF | |
# master node: | |
# kubeadm config images pull --kubernetes-version=v1.25.9 --image-repository "docker.chabokan.net" | |
# kubeadm init --pod-network-cidr=10.10.0.0/16 --kubernetes-version 1.25.9 | |
# kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.1/manifests/tigera-operator.yaml | |
# mkdir -p $HOME/.kube | |
# cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | |
# chown $(id -u):$(id -g) $HOME/.kube/config | |
wget https://public-chabok.s3.ir-thr-at1.arvanstorage.com/kubernetes/nerdctl-full-1.4.0-linux-amd64.tar.gz | |
tar Cxzvvf /usr/local nerdctl-full-1.4.0-linux-amd64.tar.gz | |
source <(kubectl completion bash) --> kubectl auto complete | |
echo 'source <(kubectl completion bash)' >> ~/.bashrcecho 'source <(kubectl completion bash)' >> ~/.bashrc | |
echo "To use the systemd cgroup driver in /etc/containerd/config.toml with runc, set: | |
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc] ... | |
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] | |
SystemdCgroup = true | |
sudo systemctl restart containerd" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run command:
screen -S kuber-install
bash install-kuber.sh
goto screen:
screen -r kuber-install