diff options
| -rw-r--r-- | recipes-containers/kubernetes/README.md | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/recipes-containers/kubernetes/README.md b/recipes-containers/kubernetes/README.md new file mode 100644 index 00000000..ae79d6c2 --- /dev/null +++ b/recipes-containers/kubernetes/README.md | |||
| @@ -0,0 +1,117 @@ | |||
| 1 | # k8s: Kubernetes | ||
| 2 | |||
| 3 | meta-virtualization provides the recipes and packages suitable for a k8s | ||
| 4 | cluster instance. | ||
| 5 | |||
| 6 | For a kubernetes controller: | ||
| 7 | |||
| 8 | - packagegroup-k8s-host | ||
| 9 | |||
| 10 | For a kubernetes worker/node: | ||
| 11 | |||
| 12 | - packagegroup-k8s-node | ||
| 13 | |||
| 14 | If kernel issues or missing features are detected, consider adding the | ||
| 15 | "kernel-modules" package to your image (Since the configuration and RDEPENDS | ||
| 16 | may not be correct for your kernel + k8s version). | ||
| 17 | |||
| 18 | ## CNI | ||
| 19 | |||
| 20 | The CNI base packages provide core support and are installed by default as | ||
| 21 | dependencies of the kubernetes packages. Minimal configuration and startup | ||
| 22 | are provided, but you will need to apply the CNI configuration of your choice | ||
| 23 | after boot (see below fo an example) | ||
| 24 | |||
| 25 | ## Configure and initialize the host | ||
| 26 | |||
| 27 | A convenience script "k8s-init" is provided to do basic setup on the controller | ||
| 28 | node. After the contoller boots, run it for kubeadm setup and other basic | ||
| 29 | configuration. | ||
| 30 | |||
| 31 | Once the node is ready ('kubectl get nodes' to check), follow the instructions | ||
| 32 | for copying the token to your home directory, and apply the networking configuration | ||
| 33 | of choice (flannel in the example): | ||
| 34 | |||
| 35 | ```shell | ||
| 36 | % mkdir -p $HOME/.kube | ||
| 37 | % cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | ||
| 38 | % chown $(id -u):$(id -g) $HOME/.kube/config | ||
| 39 | |||
| 40 | % kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml | ||
| 41 | ``` | ||
| 42 | |||
| 43 | ## Configuration and initialize the node/worker | ||
| 44 | |||
| 45 | Once the kubernetes node has booted, it is ready to join the cluster. Some | ||
| 46 | basica configuration is done via the packages and a systctl.d configuration | ||
| 47 | snippet. | ||
| 48 | |||
| 49 | Join the cluster (substitute your controller ip and token information): | ||
| 50 | |||
| 51 | ```shell | ||
| 52 | kubeadm join <controller ip>:6443 --token cq8ngi.6m6mgqi9zf08ypc4 --discovery-token-ca-cert-hash sha256:6064ae531c8dad824f9eadff030f83ec84d00796fac75f1adbd343255eb34fd2 | ||
| 53 | ``` | ||
| 54 | |||
| 55 | ## Notes: | ||
| 56 | |||
| 57 | Memory: | ||
| 58 | |||
| 59 | if running under qemu, the default of 256M of memory is not enough, k3s will | ||
| 60 | OOM and exit. | ||
| 61 | |||
| 62 | Boot with qemuparams="-m 2048" to boot with 2G of memory (or choose the | ||
| 63 | appropriate amount for your configuration) | ||
| 64 | |||
| 65 | CPUs: | ||
| 66 | |||
| 67 | Kubernetes needs at least two cpus, so ensure your qemuboot is smp of at | ||
| 68 | least 2, and/or that your hardware has the required capabilties. | ||
| 69 | |||
| 70 | Disk: | ||
| 71 | |||
| 72 | if using qemu and core-image* you'll need to add extra space in your disks | ||
| 73 | to ensure containers can start. The following in your image recipe, or | ||
| 74 | local.conf would add 2G of extra space to the rootfs: | ||
| 75 | |||
| 76 | ```shell | ||
| 77 | IMAGE_ROOTFS_EXTRA_SPACE = "2097152" | ||
| 78 | ``` | ||
| 79 | |||
| 80 | ## Example qemux86-64 boot line: | ||
| 81 | |||
| 82 | ```shell | ||
| 83 | runqemu qemux86-64 nographic kvm slirp qemuparams="-m 2048" | ||
| 84 | ``` | ||
| 85 | k8s logs can be seen via: | ||
| 86 | |||
| 87 | ```shell | ||
| 88 | % journalctl -u kubelet | ||
| 89 | ``` | ||
| 90 | |||
| 91 | or | ||
| 92 | |||
| 93 | ```shell | ||
| 94 | % journalctl -xe | ||
| 95 | ``` | ||
| 96 | |||
| 97 | ## Example output from qemux86-64: | ||
| 98 | |||
| 99 | If you've lost the join token, you can create a new one, or list existing | ||
| 100 | ones: | ||
| 101 | |||
| 102 | ```shell | ||
| 103 | root@qemux86-64-7b:~# kubeadm token create --print-join-command | ||
| 104 | kubeadm join 10.10.10.117:6443 --token dr71zq.y5vi3s2n2antvcej --discovery-token-ca-cert-hash sha256:6064ae531c8dad824f9eadff030f83ec84d00796fac75f1adbd343255eb34fd2 | ||
| 105 | |||
| 106 | root@qemux86-64-7b:~# kubeadm token list | ||
| 107 | TOKEN TTL EXPIRES USAGES DESCRIPTION EXTRA GROUPS | ||
| 108 | cq8ngi.6m6mgqi9zf08ypc4 23h 2021-12-16T16:58:02Z authentication,signing The default bootstrap token generated by 'kubeadm init'. system:bootstrappers:kubeadm:default-node-token | ||
| 109 | dr71zq.y5vi3s2n2antvcej 23h 2021-12-16T17:46:28Z authentication,signing <none> system:bootstrappers:kubeadm:default-node-token | ||
| 110 | ``` | ||
| 111 | |||
| 112 | ```shell | ||
| 113 | root@qemux86-64:~# kubectl get nodes | ||
| 114 | NAME STATUS ROLES AGE VERSION | ||
| 115 | qemux86-64-7b Ready control-plane,master 51m v1.23.1-rc.0.1+dd1b0a12471310-dirty | ||
| 116 | qemux86-64-9d Ready <none> 49m v1.23.1-rc.0.1+dd1b0a12471310-dirty | ||
| 117 | ``` | ||
