en:dev:env:kubernetes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:dev:env:kubernetes [2019/01/05 18:26] alexejsaileren:dev:env:kubernetes [2020/03/05 21:23] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Kubernetes ====== ====== Kubernetes ======
 +
 +This is a smal how-to to setup a kmaster and a knode.
  
 With ubuntu 16.04 With ubuntu 16.04
Line 109: Line 111:
 apt-mark hold kubelet kubeadm kubectl apt-mark hold kubelet kubeadm kubectl
 </sxh> </sxh>
 +
 +**//From here all operations should be done only on kmaster//**
 +
  
   * check cgroup driver   * check cgroup driver
Line 143: Line 148:
 kubeadm init --apiserver-advertise-address=192.168.56.201 --pod-network-cidr=192.168.0.0/16 kubeadm init --apiserver-advertise-address=192.168.56.201 --pod-network-cidr=192.168.0.0/16
 </sxh> </sxh>
 +
 +  * you should see the following:
 +
 +<sxh bash;>
 +
 +  mkdir -p $HOME/.kube
 +  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
 +  sudo chown $(id -u):$(id -g) $HOME/.kube/config
 +
 +You should now deploy a pod network to the cluster.
 +Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
 +  https://kubernetes.io/docs/concepts/cluster-administration/addons/
 +
 +You can now join any number of machines by running the following on each node
 +as root:
 +
 +  kubeadm join 192.168.56.201:6443 --token usymgb.c5s530zqqs89napy --discovery-token-ca-cert-hash sha256:dadb42d6961e21cba21265dc345c23e1bf33bf9dcd26c96b4dd7eb9b66522614
 +
 +</sxh>
 +
  
 <sxh bash;> <sxh bash;>
Line 149: Line 174:
 sudo chown $(id -u):$(id -g) $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
 </sxh> </sxh>
 +
 +  * install flannel
  
 <sxh bash;> <sxh bash;>
Line 155: Line 182:
 </sxh> </sxh>
  
 +  * check if everything is running
 +
 +<sxh bash;>
 +kubectl get pods -o wide --all-namespaces
 +</sxh>
 +
 +  * should look like
 +
 +<sxh bash;>
 +NAMESPACE     NAME                                   READY   STATUS    RESTARTS   AGE    IP               NODE      NOMINATED NODE   READINESS GATES
 +kube-system   coredns-86c58d9df4-hpl5s               1/    Running            2d2h   192.168.0.3      kmaster   <none>           <none>
 +kube-system   coredns-86c58d9df4-jbvxv               1/    Running            2d2h   192.168.0.2      kmaster   <none>           <none>
 +kube-system   etcd-kmaster                           1/    Running            2d2h   192.168.56.201   kmaster   <none>           <none>
 +kube-system   kube-apiserver-kmaster                 1/    Running            2d2h   192.168.56.201   kmaster   <none>           <none>
 +kube-system   kube-controller-manager-kmaster        1/1     Running            2d2h   192.168.56.201   kmaster   <none>           <none>
 +kube-system   kube-flannel-ds-amd64-q5lgj            1/1     Running            44h    192.168.56.202   knode     <none>           <none>
 +kube-system   kube-flannel-ds-amd64-zjxh8            1/1     Running            46h    192.168.56.201   kmaster   <none>           <none>
 +kube-system   kube-proxy-dj8h7                       1/    Running            2d2h   192.168.56.201   kmaster   <none>           <none>
 +kube-system   kube-proxy-qwh2x                       1/    Running            44h    192.168.56.202   knode     <none>           <none>
 +kube-system   kube-scheduler-kmaster                 1/    Running            2d2h   192.168.56.201   kmaster   <none>           <none>
 +kube-system   kubernetes-dashboard-57df4db6b-2r4th   1/    Running            45h    192.168.0.4      kmaster   <none>           <none>
 +</sxh>
 + 
 +* install the kubernetes dashboard
 +
 +<sxh bash;>
 +kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
 +# get token to login to dashboard
 +kubectl create serviceaccount dashboard -n default
 +kubectl create clusterrolebinding dashboard-admin -n default --clusterrole=cluster-admin --serviceaccount=default:dashboard
 +kubectl get secret $(kubectl get serviceaccount dashboard -o jsonpath="{.secrets[0].name}") -o jsonpath="{.data.token}" | base64 --decode
 +</sxh>
 +
 +  * start dashboard
 +
 +<sxh bash;>
 +kubectl proxy
 +</sxh>
 +
 +  * now you can reach the dashbard at
 +
 +http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
 +
 +  * to reach it from the host os you can tunnel the port 8001 from kmaster to your host
 +
 +So now the kmaster is running. For the knode you have to repeate all operations above until the bold message which says: **From here all operations should be done only on kmaster**. Just set a diffrent host **knode** and a new static IP **192.168.56.202**
 +
 +After all operations were executed successfully do the connection. To join type in the above join statement. This is exactly what you got as message after starting kubernetes on master:** Refere to the output above, it is the same!**
 +
 +<sxh bash;>
 +sudo kubeadm join 192.168.56.201:6443 --token usymgb.c5s530zqqs89napy --discovery-token-ca-cert-hash sha256:dadb42d6961e21cba21265dc345c23e1bf33bf9dcd26c96b4dd7eb9b66522614
 +</sxh>
  
 +Sources:
  
 +https://kubernetes.io/
  
  
  • en/dev/env/kubernetes.txt
  • Last modified: 2020/03/05 21:23
  • by 127.0.0.1