Kubernetes Book 3 - Installing Kubernetes
Jump to navigation
Jump to search
Play with Kubernetes
Run few commands.
$ docker version Client: Docker Engine - Community Version: 19.03.5 API version: 1.40 Go version: go1.12.12 Git commit: 633a0ea Built: Wed Nov 13 07:25:41 2019 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.5 API version: 1.40 (minimum version 1.12) Go version: go1.12.12 Git commit: 633a0ea Built: Wed Nov 13 07:24:18 2019 OS/Arch: linux/amd64 Experimental: true containerd: Version: 1.2.10 GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339 runc: Version: 1.0.0-rc8+dev GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657 docker-init: Version: 0.18.0 GitCommit: fec3683 $ kubectl version -o yaml clientVersion: buildDate: "2019-11-13T11:21:43Z" compiler: gc gitCommit: 500f5aba80d71253cc01ac6a8622b8377f4a7ef9 gitTreeState: clean gitVersion: v1.14.9 goVersion: go1.12.12 major: "1" minor: "14" platform: linux/amd64 serverVersion: buildDate: "2019-12-11T12:32:32Z" compiler: gc gitCommit: 575467a0eaf3ca1f20eb86215b3bde40a5ae617a gitTreeState: clean gitVersion: v1.14.10 goVersion: go1.12.12 major: "1" minor: "14" platform: linux/amd64
Use the kubeadm command to initialize a new cluster.
$ kubeadm init --apiserver-advertise-address $(hostname -i) ... Your Kubernetes control-plane has initialized successfully!
Verify the cluster with the kubectl command.
$ kubectl get nodes NAME STATUS ROLES AGE VERSION node1 NotReady master 9m29s v1.14.9
Initialize the Pod network(cluster networking).
$ kubectl apply -n kube-system -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')" serviceaccount/weave-net created clusterrole.rbac.authorization.k8s.io/weave-net created clusterrolebinding.rbac.authorization.k8s.io/weave-net created role.rbac.authorization.k8s.io/weave-net created rolebinding.rbac.authorization.k8s.io/weave-net created daemonset.apps/weave-net created
Verify the cluster again to see if node1 has changed to Ready.
$ kubectl get nodes NAME STATUS ROLES AGE VERSION node1 Ready master 13m v1.14.9
Copy the kubeadm join command from the oputput of the kubeadm init.
Click the + ADD NEW INSTANCE button in the left pane of the PWK window.
Paste the kubeadm join command into the terminal of node2.
[node2 ~]$ kubeadm join 192.168.0.28:6443 --token usb8x1.xx76fcfgedotamdv \ > --discovery-token-ca-cert-hash sha256:bc3287994658c1eb6005e2d1de316bb5c9a34341bf71ef8af569bdd4666340b3
Switch back to node1 and run another kubectl get nodes.
[node1 ~]$ kubectl get nodes NAME STATUS ROLES AGE VERSION node1 Ready master 19m v1.14.9 node2 Ready <none> 2m19s v1.14.9