Skip to content

Instantly share code, notes, and snippets.

@yurikilian
Last active August 22, 2023 11:04
Show Gist options
  • Save yurikilian/1a6c3183d231631e75869b99989b3232 to your computer and use it in GitHub Desktop.
Save yurikilian/1a6c3183d231631e75869b99989b3232 to your computer and use it in GitHub Desktop.
Kubernetes - Setup node
#!/bin/sh
set -x
NEEDRESTART_MODE=a apt-get dist-upgrade --yes
apt update
apt -y full-upgrade
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
tee /etc/modules-load.d/k8s.conf <<EOF
overlay
br_netfilter
EOF
modprobe overlay
modprobe br_netfilter
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
OS="xUbuntu_22.04"
VERSION=1.27
echo "deb [signed-by=/usr/share/keyrings/libcontainers-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
echo "deb [signed-by=/usr/share/keyrings/libcontainers-crio-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list
mkdir -p /usr/share/keyrings
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | gpg --dearmor -o /usr/share/keyrings/libcontainers-archive-keyring.gpg
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/Release.key | gpg --dearmor -o /usr/share/keyrings/libcontainers-crio-archive-keyring.gpg
apt-get update
apt-get install cri-o cri-o-runc -y
systemctl enable kubelet
systemctl daemon-reload
systemctl enable crio
systemctl start crio
echo '<private ip cp>\tnonprod-kubernetes-leader' >> /etc/hosts
echo '<private ip wk1>\tnonprod-kubernetes-worker1' >> /etc/hosts
echo '<private ip wk2>\tnonprod-kubernetes-worker2' >> /etc/hosts
apt-get install -y apt-transport-https ca-certificates curl
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list
apt-get update
apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl
iptables --flush
iptables-save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment