K8s on Vms With Calico

This post is a memo on how I did the installtion of Kubernetes and Calico on VMs. It’s not some best pactrices in anyway.
I’ve chose VM because I didn’t want to depend on any Cloud infrastructure. I’ve also wanted to understand the network interaction between K8s parts from an infrastructure point of view.

Prerequisite :

know how to create VMs on any hypervisors

Steps to deploy K8s :

  1. Install 1 ubuntu router with 3 interfaces. 1 for NAT/Internet access and 2 for the K8s LAN. I’ve created 2 LAN to see what happen under the hood when K8s nodes communicates.

  2. Install 3 Ubuntu servers, 1 for the master and 2 for the workers. 1 worker in the same ethernet segment and subnet than the master. 1 worker in another network.

    Gotchas:
    • By default, the K8s interface is the one with the default route. All my servers have one OOB interface and one production interface.
    • Special tunning for k8s => turn off the swap
  3. Install runtime and enable it on boot

  4. Installing kubeadm, kubelet and kubectl

  5. Initializing the master (choose the pod network add-on before to add the relevent parameters, Calico parameters in my case)

  6. Install the pod network add-on

  7. Join node/workers to the cluster

  8. That it, you can now play with the K8s cluster

Optional :

Install ctl for calico

Comments :

To create anything you just have to kubectl apply -f myfile The magic happen in myfile where you describe what you want to create.

Below the capture after the lab is completed CaptureCalicok8s

Details of the tasks

3. https://kubernetes.io/docs/setup/independent/install-kubeadm/#installing-runtime

I’ve needed to add the following commands

systemctl enable docker.service
systemctl start docker.service

4. https://kubernetes.io/docs/setup/independent/install-kubeadm/#installing-kubeadm-kubelet-and-kubectl

apt-get update && apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF

apt-get update
apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl

5.

kubeadm init --pod-network-cidr=192.168.0.0/16

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

6.

kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml
kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml

7.

kubeadm join 10.0.1.10:6443 --token d34b9i.v03t2yiozio63cq6 --discovery-token-ca-cert-hash sha256:c21d04ea23790a0bf81cf64118e3a9075ffb63ed90bc697acef5793386e9eb16

Related