gokul-c of K8's
1/26/2017 - 6:20 PM

Short demo of `kubeadm`

Short demo of kubeadm

Per https://www.youtube.com/watch?v=Bv3JmHKlA0I&feature=youtu.be

workstation$ export K8S_1=<k8s_1_ip>
workstation$ export K8S_2=<k8s_2_ip>
workstation$ export K8S_3=<k8s_3_ip>

Common

workstation$ ssh root@$K8S_1

cat <<EOF > /etc/apt/sources.list.d/k8s.list
deb [arch=amd64] http://apt.dockerproject.org/repo ubuntu-xenial main
deb [arch=amd64] http://apt.k8s.io xenial main 
EOF
apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv-keys F76221572C52609D 81A45CB679084BD1
apt-get update
apt-get install -y kubelet docker-engine=1.11.2-0~xenial


# --- everything between these lines won't be necessary eventually ---

curl -sSL -o /usr/bin/kubelet https://kubeadm.lukemarsden.net/kubelet
curl -sSL -o /usr/bin/kubectl https://kubeadm.lukemarsden.net/kubectl

curl -sSL -o /usr/bin/kubeadm https://kubeadm.lukemarsden.net/kubeadm
chmod +x /usr/bin/kube{let,ctl,adm}

sed -i '4iStartLimitInterval=0' /etc/systemd/system/kubelet.service

echo KUBELET_OPTS=\"--network-plugin=cni --network-plugin-dir=/etc/cni/net.d --kubeconfig=/etc/kubernetes/kubelet.conf --require-kubeconfig=true --pod-manifest-path=/etc/kubernetes/manifests\" > /etc/default/kubelet

# ---------------------------------------------------------------------

systemctl enable kubelet && systemctl start kubelet

Kubelet will now wait in a crash-loop until it receives instructions from kubeadm.

Now go and run this on the other two nodes.

Master

workstation$ ssh root@$K8S_1
kubeadm manual bootstrap init-master

Make a note of the command which was just printed, you'll need it as <command-from-init-with-path-to-ca-cert-replaced-with-/tmp/ca.pem> below.

Check that the master came up (may take 30 seconds or so):

kubectl get nodes

As a demo of installing a CNI network as an add-on, let's also install Weave as a pod network. This will get automatically deployed to new nodes as DaemonSets:

kubectl apply -f \
  https://raw.github.com/weaveworks/weave-kube/master/weave-daemonset.yaml
exit

workstation$ scp root@$K8S_1:/etc/kubernetes/pki/ca.pem .
workstation$ scp ca.pem root@$K8S_2:/tmp/ca.pem
workstation$ scp ca.pem root@$K8S_3:/tmp/ca.pem

Nodes

workstation$ ssh root@$K8S_2 <command-from-init-with-path-to-ca-cert-replaced-with-/tmp/ca.pem>
workstation$ ssh root@$K8S_3 <command-from-init-with-path-to-ca-cert-replaced-with-/tmp/ca.pem>