| 1 | Kubernetes Wiki Doc: |
| 2 | [[TOC(Documentation/f*, depth=3)]] |
| 3 | |
| 4 | == Tutorial: Kubernetes Setup== |
| 5 | Requirements: |
| 6 | |
| 7 | 1. [https://www.orbit-lab.org/wiki/Documentation/CGettingStarted Setup/Practice] of Orbit Nodes. |
| 8 | |
| 9 | 2. Any available Orbit Sandbox Node |
| 10 | |
| 11 | 3. Ubuntu 20.04.5 LTS or Ubuntu 22.04.2 LTS (Choice is up to you) |
| 12 | |
| 13 | ---- |
| 14 | |
| 15 | In this tutorial, we will be using one of the sb1 nodes for setting up Kubernetes. However, sb(1-10) should also be capable for Kubernetes setup. |
| 16 | |
| 17 | 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'ing into your console. Substitute for the image and node you want. |
| 18 | |
| 19 | The below steps illustrate loading Ubuntu 20.04.5 LTS for node1-2 of sb1. For the sb1 console, |
| 20 | |
| 21 | {{{#!shell |
| 22 | username@console:~$ omf tell -t node1-2 -a offh |
| 23 | }}} |
| 24 | |
| 25 | {{{#!shell |
| 26 | username@console:~$ omf load -t node1-2 -i baseline20.04.ndz |
| 27 | }}} |
| 28 | |
| 29 | {{{#!shell |
| 30 | username@console:~$ omf tell -t node1-2 -a on |
| 31 | }}} |
| 32 | |
| 33 | To verify if you have loaded your Ubuntu version properly, use this command after ssh into the node1-2 |
| 34 | |
| 35 | {{{#!shell |
| 36 | root@node1-2:~# lsb_release -a |
| 37 | }}} |
| 38 | |
| 39 | This will list the current version of Ubuntu loaded. |
| 40 | |
| 41 | Example Image: |
| 42 | |
| 43 | [[Image(lsb_release.jpg)]] |
| 44 | |
| 45 | === Set up a Kubernetes Cluster === |
| 46 | After loading your version of Ubuntu, you can follow the below steps to install Kubernetes |
| 47 | |
| 48 | 1. Update and Upgrade Packages: |
| 49 | {{{#!shell |
| 50 | root@node1-2:~# sudo apt-get update && sudo apt-get upgrade |
| 51 | }}} |
| 52 | |
| 53 | 2. Install Docker: |
| 54 | {{{#!shell |
| 55 | root@node1-2:~# sudo apt install docker.io |
| 56 | }}} |
| 57 | |
| 58 | 3. Configure Docker to use systemd for the management of the container’s cgroups: |
| 59 | {{{#!shell |
| 60 | root@node1-2:~# cat <<EOF | sudo tee /etc/docker/daemon.json |
| 61 | { |
| 62 | "exec-opts": ["native.cgroupdriver=systemd"], |
| 63 | "log-driver": "json-file", |
| 64 | "log-opts": { |
| 65 | "max-size": "100m" |
| 66 | }, |
| 67 | "storage-driver": "overlay2" |
| 68 | } |
| 69 | EOF |
| 70 | }}} |
| 71 | |
| 72 | 4. Enable Docker: |
| 73 | {{{#!shell |
| 74 | root@node1-2:~# sudo systemctl enable docker |
| 75 | }}} |
| 76 | |
| 77 | 5. Reload the systemd manager configuration: |
| 78 | {{{#!shell |
| 79 | root@node1-2:~# sudo systemctl daemon-reload |
| 80 | }}} |
| 81 | |
| 82 | 6. Restart Docker: |
| 83 | {{{#!shell |
| 84 | root@node1-2:~# sudo systemctl restart docker |
| 85 | }}} |
| 86 | |
| 87 | 7. Update and Upgrade Packages again: |
| 88 | {{{#!shell |
| 89 | root@node1-2:~# apt update && apt upgrade -y |
| 90 | }}} |
| 91 | |
| 92 | 8. Add Kubernetes to the repository list: |
| 93 | {{{#!shell |
| 94 | root@node1-2:~# 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 |
| 95 | }}} |
| 96 | {{{#!shell |
| 97 | root@node1-2:~# 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 |
| 98 | }}} |
| 99 | |
| 100 | 9. Install Kubernetes: |
| 101 | {{{#!shell |
| 102 | root@node1-2:~# sudo apt-get update |
| 103 | }}} |
| 104 | {{{#!shell |
| 105 | root@node1-2:~# sudo apt-get install -y kubelet kubeadm kubectl |
| 106 | }}} |
| 107 | {{{#!shell |
| 108 | root@node1-2:~# sudo apt-mark hold kubelet kubeadm kubectl |
| 109 | }}} |
| 110 | |
| 111 | 10. Initialize the Kubernetes Cluster: |
| 112 | {{{#!shell |
| 113 | root@node1-2:~# kubeadm init --pod-network-cidr=10.19.0.0/16 |
| 114 | }}} |
| 115 | |
| 116 | You should see an output which includes a `kubeadm join` command, save this command for use on the worker nodes. |
| 117 | |
| 118 | 11. Set KUBECONFIG environment variable: |
| 119 | {{{#!shell |
| 120 | root@node1-2:~# export KUBECONFIG=/etc/kubernetes/admin.conf |
| 121 | }}} |
| 122 | |
| 123 | 12. Apply Flannel network overlay: |
| 124 | {{{#!shell |
| 125 | root@node1-2:~# kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml |
| 126 | }}} |
| 127 | |
| 128 | === Joining Worker Nodes to the Cluster === |
| 129 | To join worker nodes to the Kubernetes cluster, run the `kubeadm join` command that was outputted by the `kubeadm init` command. |
| 130 | |
| 131 | Example: |
| 132 | {{{#!shell |
| 133 | root@node1-2:~# kubeadm join 10.19.1.5:6443 --token o1cttx.z9al8w8ljqcmqb4y --discovery-token-ca-cert-hash sha256:6ecd74d7eca0299b80499cf2e2e1c87c4079c3d234282be5822761880998853e |
| 134 | }}} |
| 135 | |
| 136 | = Hope You Figure Out the Purpose of Kubernetes = |