Kubeadm tutorial
TAGS:How to deploy k8s with calico net on 2 virtualbox vm’s via kubeadm
-
Create 2 ubuntu VB vms
+4GB ram
+50GB dynamic storage
2 adapters (nat + virtualbox host network)
ubuntu 16.04 adapter -
Install os
-
Adapter settings
Virtualboxhostnetwork:
cat /etc/network/interfaces.d/enp0s9 auto enp0s9 iface enp0s9 inet static address 172.28.33.46 — IMPORTNAT — ONLY NOT THE 192.168. or 10.0…. netmask 255.255.255.0 gateway 172.28.33.1 up route del gw 172.28.33.1
Nat: auto enp0s3 iface enp0s3 inet dhcp up route add default gw 10.0.2.2
-
Update ssh config — permit rootlogin && service ssh restart
-
Ssh into machines
-
Install kubeadm
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add — cat </etc/apt/sources.list.d/docker.list deb https://download.docker.com/linux/$(lsb_release -si | tr ‘[:upper:]’ ‘[:lower:]’) $(lsb_release -cs) stable EOF apt install curl apt-transport-https kubeadm ebtables
-
Install Docker 1.12
curl https://releases.rancher.com/install-docker/1.12.sh | sh
-
Edit /etc/hosts — insert machines ip/names
-
Generate ssh keys and copy them to all machines
ssh-keygen ; ssh-copy-id root@machine{1,2}
-
Disable swap
vim /etc/fstab — comment swap entry swapoff -a; reboot
-
Start kubeadm master
Master VM
kubeadm init --apiserver-advertise-address $MASTERVBHOSTNETIP --pod-network-cidr=192.168.0.0/16 --service-cidr 10.96.0.0/12
If there is any problem — run
kubeadm reset
-
Copy kube config through the nodes
mkdir ~/.kube; cp /etc/kuebernetes/admin.conf ~/.kube/config; scp -r ~/.kube/config node2:~/
-
Creating calico virtual network in k8s
kubectl apply -f http://docs.projectcalico.org/v2.4/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
-
Join slave node to master run on slave (you will need information from step 11 - token,sha256
kubeadm join --token $roken --discovery-token-ca-cert-hash $sha256
-
Enable compute resources on master node
kubectl taint nodes —all node-role.kubernetes.io/master
tells our cluster tha we can ran some pods on master node -
Check
kubectl get nodes
if all okey — lets try out our cluster - Creating test app
kubectl create namespace sock-shop kubectl apply -n sock-shop -f "https://github.com/microservices-demo/microservices-demo/blob/master/deploy/kubernetes/complete-demo.yaml?raw=true"
- Check
kubectl get po -n sock-shop