Created
          September 7, 2024 11:31 
        
      - 
      
- 
        Save sampathshivakumar/199858482e98bcd429a582459b0ecb83 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or 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 | |
| sudo swapoff -a | |
| # Enable IPv4 packet forwarding | |
| # sysctl params required by setup, params persist across reboots | |
| cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf | |
| net.ipv4.ip_forward = 1 | |
| EOF | |
| # Apply sysctl params without reboot | |
| sudo sysctl --system | |
| # Installing Containerd runtime using Docker repository. | |
| # Add Docker's official GPG key: | |
| sudo apt-get update | |
| sudo apt-get install ca-certificates curl -y | |
| sudo install -m 0755 -d /etc/apt/keyrings | |
| sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | |
| sudo chmod a+r /etc/apt/keyrings/docker.asc | |
| # Add the repository to Apt sources: | |
| echo \ | |
| "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ | |
| $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ | |
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
| sudo apt-get update | |
| sudo apt-get install containerd.io -y | |
| containerd config default > /etc/containerd/config.toml | |
| sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml | |
| sudo systemctl restart containerd | |
| # Update the apt package index and install packages needed to use the Kubernetes apt repository: | |
| sudo apt-get update | |
| # apt-transport-https may be a dummy package; if so, you can skip that package | |
| sudo apt-get install -y apt-transport-https ca-certificates curl gpg | |
| # Download the public signing key for the Kubernetes package repositories. The same signing key is used for all repositories so you can disregard the version in the URL | |
| # If the directory `/etc/apt/keyrings` does not exist, it should be created before the curl command, read the note below. | |
| # sudo mkdir -p -m 755 /etc/apt/keyrings | |
| curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg | |
| # This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list | |
| 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 | |
| # Update the apt package index, install kubelet, kubeadm and kubectl, and pin their version | |
| sudo apt-get update | |
| sudo apt-get install -y kubelet kubeadm kubectl | |
| sudo apt-mark hold kubelet kubeadm kubectl | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment