Difference between revisions of "Kubeadm kubernetes cluster Ubuntu 24.04"

From UVOO Tech Wiki
Jump to navigation Jump to search
(Created page with "# Init ``` #!/bin/bash set -eu kubeadm_init(){ sudo apt update && sudo apt upgrade -y sudo apt install apt-transport-https curl -y sudo apt install containerd -y sudo...")
 
Line 1: Line 1:
# Init
+
# Kubeadm Cluster Scripts
 +
 
 +
## Init
 
```
 
```
 
#!/bin/bash
 
#!/bin/bash

Revision as of 18:35, 27 December 2024

Kubeadm Cluster Scripts

Init

#!/bin/bash
set -eu
kubeadm_init(){
  sudo apt update && sudo apt upgrade -y
  sudo apt install apt-transport-https curl -y

  sudo apt install containerd -y
  sudo mkdir -p /etc/containerd
  containerd config default | sudo tee /etc/containerd/config.toml > /dev/null
  sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
  sudo systemctl restart containerd

  curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo 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.30/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
  sudo apt update
  sudo apt install -y kubelet kubeadm kubectl
  sudo apt-mark hold kubelet kubeadm kubectl

  sudo swapoff -a
  sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

  sudo modprobe overlay
  sudo modprobe br_netfilter
  echo -e "br_netfilter\noverlay" | sudo tee /etc/modules-load.d/kubernetes-cni.conf
  lsmod | grep overlay
  lsmod | grep br_netfilter

  cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1
EOF

  sysctl --system
  reboot
}

kubeadm_init