Build VM
Issue the following commands on your vm. The master node will require 2 cores and 2GB memory.On VM:
Code Block |
---|
sudo su
apt-get update
#install openssh
apt-get install openssh-server
#install docker
apt-get install -y docker.io
#install curl
apt-get install -y apt-transport-https curl
#setup kubernetes repo
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
#install kubernetes
apt-get install -y kubelet kubeadm kubectlapt-mark hold kubelet kubeadm kubectl
#disable swap
swapoff -va
#comment out the line for swap in the fstab file
vi /etc/fstab
#pull images
kubeadm config images pull
#if vm, save for duplication
#setup network settings
#hostname, ip , etc...
#initialize kubernetes
kubeadm init |
...
Now clone this VM with names:
- k8master
- k8worker1
- k8worker2
- k8worker3
Setup Network
Initialize Master
> kubeadm init
Code Block |
---|
... Your Kubernetes master 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: 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 10.0.2.100:6443 --token 8616y5.99svelizti79sgyw --discovery-token-ca-cert-hash sha256:b3631a1b774382f980ac6e8e881241f59eccc5ff250ffc948e001e9aff40cbb7 |
...