wiki:Tutorials/m0SDN/k8s

Version 15 (modified by jlaxman, 17 months ago) ( diff )

Tutorial: Kubernetes Multi Node Setup

Requirements:

  1. Setup/Practice of Orbit Nodes.
  1. Any available Orbit Sandbox Node
  1. Ubuntu 20.04.5 LTS or 22.04.2 LTS

Kubernetes Multi Node lab setup via kubeadm utility

Let’s take a look at this Kubernetes Multi-Node lab setup step-by-step and see how it is put together.

In this tutorial, we will be using one of the sb9 nodes for setting up Kubernetes. Any sb(1-10) should also be capable of Kubernetes setup.

Make sure you have Ubuntu 20.04.5 (baseline20.04.ndz) or 22.04.2 (ubuntu2204-beta.ndz) LTS. To get the Ubuntu Version, follow these steps after ssh into your console. Substitute for the image and node you want.

The below steps illustrate loading Ubuntu 20.04.5 LTS for node1-5 of sb9. For the sb9 console,

username@console:~$ omf tell -t node1-5 -a offh 
username@console:~$ omf load -t node1-5 -i baseline20.04.ndz
username@console:~$ omf tell -t node1-5 -a on

To verify if you have loaded your Ubuntu version properly, use this command after ssh into the node1-5

root@node1-5:~# lsb_release -a

This will list the current version of Ubuntu loaded.

Set up a Kubernetes Cluster

After loading your version of Ubuntu, you can follow the below steps to install Kubernetes

  1. Update and Upgrade Packages:
    root@node1-5:~# sudo apt-get update && sudo apt-get upgrade
    
  1. Install Docker:
    root@node1-5:~# sudo apt install docker.io
    
  1. Configure Docker to use systemd for the management of the container’s cgroups:
    root@node1-5:~# cat <<EOF | sudo tee /etc/docker/daemon.json
    {
      "exec-opts": ["native.cgroupdriver=systemd"],
      "log-driver": "json-file",
      "log-opts": {
        "max-size": "100m"
      },
      "storage-driver": "overlay2"
    }
    EOF
    
  1. Enable Docker:
    root@node1-5:~# sudo systemctl enable docker
    
  1. Reload the systemd manager configuration:
    root@node1-5:~# sudo systemctl daemon-reload
    
  1. Restart Docker:
    root@node1-5:~# sudo systemctl restart docker
    
  1. Update and Upgrade Packages again:
    root@node1-5:~# apt update && apt upgrade -y
    
  1. Add Kubernetes to the repository list:
    root@node1-5:~# curl -sSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/kubernetes-archive-keyring.gpg >/dev/null
    
    root@node1-5:~# 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
    
  1. Install Kubernetes:
    root@node1-5:~# sudo apt-get update
    
    root@node1-5:~# sudo apt-get install -y kubelet kubeadm kubectl
    
    root@node1-5:~# sudo apt-mark hold kubelet kubeadm kubectl
    

All the above steps are common for both master and worker nodes, the below steps should only be made run on the master node)

  1. Initialize the Kubernetes Cluster:
    root@node1-5:~# kubeadm init --pod-network-cidr=10.19.0.0/16
    

You should see an output which includes a kubeadm join command, save this command for use on the worker nodes.

  1. Set KUBECONFIG environment variable:
    root@node1-5:~# export KUBECONFIG=/etc/kubernetes/admin.conf
    
  1. Apply Flannel network overlay:
    root@node1-5:~# kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
    

Joining Worker Nodes to the Cluster

Make sure you follow till step 9[including] on the worker nodes, and then To join worker nodes to the Kubernetes cluster, run the kubeadm join command on the worker nodes that was outputted by the above kubeadm init command.

Example of kubeadm join command generated by kubeadm init, lets say we want to add node1-6 as the worker node:

root@node1-6:~# kubeadm join 10.19.1.5:6443 --token o1cttx.z9al8w8ljqcmqb4y --discovery-token-ca-cert-hash sha256:6ecd74d7eca0299b80499cf2e2e1c87c4079c3d234282be5822761880998853e

To get the current status of nodes

root@node1-5:~# kubectl get nodes

Node Status

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.