Download Ubuntu Desktop (18.04.3 LTS) from https://ubuntu.com/download/desktop
Create a VirtualBox node called master using the downloaded image.
START the ubuntu server and accept all defaults during the installation ( although I did change the language to UK English).
Hostname “master”Username “paul”
Password “paul”
Login automatically selected.
Start the system and open a terminal
$ swapoff -a
$ nano /etc/fstab
Comment out the swapfile line
Install docker
$ apt install docker.io
$ systemctl enable docker
$ apt install net-tools
Shutdown & Clone
Clone the machine to two other systems, slave1 and slave2. Make sure you choose to generate new mac addresses for each clone.
For each clone:
- $ sudo su
- $ nano /etc/hostname
Change master to slave1 or slave2
Change master to slave1 or slave2
- $ nano /etc/hosts
Add the routes to the hosts:
192.168.0.124 master
192.168.0.125 slave1
192.168.0.126 slave2
Shutdown all hosts and add a second network device:
Restart the hosts.
Set the new network as
Repeat for slave1 and slave2 as 192.168.99.121 and 192.168.99.122 respectively
Update the /etc/hosts file on each machine
192.168.99.124 kbm
192.168.99.125 kbs1
192.168.99.126 kbs2
Check all machines are reachable
$ ping kbm
$ ping kbs1
$ ping kbs2
On each host
From: https://kubernetes.io/docs/tasks/tools/install-kubectl/
sudo update-alternatives –set iptables /usr/sbin/iptables-legacy
sudo update-alternatives –set ip6tables /usr/sbin/iptables-legacy
sudo update-alternatives –set arptables /usr/sbin/arptables-legacy
sudo update-alternatives –set ebtables /usr/sbin/ebtables-legacy
sudo apt-get update && sudo apt-get install -y apt-transport-https
apt install curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add –
echo “deb https://apt.kubernetes.io/ kubernetes-xenial main” | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
cat << EOF > /etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get update
sudo apt-get install -y kubectl
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
apt-get install -y kubelet=1.15.4-00 kubeadm=1.15.4-00 kubectl=1.15.4-00 docker.io
ON MASTER
$ sudo kubeadm init
OR
$ sudo kubeadm init –apiserver-advertise-address=192.168.99.124 –pod-network-cidr=192.168.0.0/16
:
:
:
Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
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:
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join 192.168.99.124:6443 –token a8kfye.dqb1ee5oyn76zmhp \
–discovery-token-ca-cert-hash sha256:aafefd10048cba3c3ab530cdb1ecb39f3a62b4abfc1350770147249b92da03d9
root@master:/home/paul#
Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
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:
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join 192.168.0.124:6443 –token n342j4.d1mvtihlg96g3p6q \
–discovery-token-ca-cert-hash sha256:fed729348d4c421bc12b39f482efaf520ff43d541b65c3a6550856aa6a17c13f
paul@master:~$ mkdir -p $HOME/.kube
paul@master:~$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
paul@master:~$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
paul@master:~$ kubectl apply -f https://docs.projectcalico.org/v3.11/manifests/calico.yaml
kubectl apply -f https://docs.projectcalico.org/master/getting-started/kubernetes/installation/hosted/calico.yaml
paul@master:~$ watch kubectl get pods –all-namespaces
paul@master:~$ kubectl taint nodes –all node-role.kubernetes.io/master-
paul@master:~$ kubectl get nodes -o wide
Kubectl describe pods
sysctl net.bridge.bridge-nf-call-iptables=1
kubectl apply -f “https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d ‘\n’)”
paul@master:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 23m v1.17.0
On slave1 and slave2
sudo kubeadm join 192.168.99.124:6443 –token a8kfye.dqb1ee5oyn76zmhp \
–discovery-token-ca-cert-hash sha256:aafefd10048cba3c3ab530cdb1ecb39f3a62b4abfc1350770147249b92da03d9
TEST KUBERNETES
Cd ~/Course_Kubernetes_Deep_Dive_NP/lesson-networking
kubectl apply -f ping-deploy.yml
kubectl label node slave1 node-role.kubernetes.io/worker=slave1
kubectl label node slave2 node-role.kubernetes.io/worker=slave2
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 87m v1.17.0
slave1 Ready worker 70m v1.17.0
slave2 Ready slave2,worker 70m v1.17.0
Add Label
kubectl label node
Remove label
kubectl label node