Rancher and Kubernetes


#1

Setup One Master & 3 worker nodes:
OS: Ubuntu 18
All 4 nodes are going to be VMs based on virtualbox software.

Lets setup 4 VMs first.

  1. copy ubuntu18 golden image (ncd-ubnt18x86-goldenimage-v1.vdi )from ncodeit-vm-images-server to laptop
    launch winscp -> connect to ncodeit-vm-images-server -> go to vbox-images location -> download the image ncd-ubnt18x86-goldenimage-v1.vdi
    watch this video for more clarity :

Leave the downloaded copy as it is. Make 4 more copies.

  1. copy the ncodeit ubuntu golden images from the image server to the baremetal server. Follow the document launch VMs using prebuilt custom images and virtualbox

( password : collect it from project manager)

  1. after the vdi file is downloaded into the baremetal server make a copy of that file for master
    cp ncd-ubnt18x86-goldenimage-v1.vdi ncd-ubnt18x86-goldenimage-v1-master.vdi

  2. after the vdi file is downloaded into the baremetal server make a copy of that file for node1
    cp ncd-ubnt18x86-goldenimage-v1.vdi ncd-ubnt18x86-goldenimage-v1-node1.vdi

  3. after the vdi file is downloaded into the baremetal server make a copy of that file for node2
    cp ncd-ubnt18x86-goldenimage-v1.vdi ncd-ubnt18x86-goldenimage-v1-node2.vdi

  4. after the vdi file is downloaded into the baremetal server make a copy of that file for node3
    cp ncd-ubnt18x86-goldenimage-v1.vdi ncd-ubnt18x86-goldenimage-v1-node3.vdi
    Launch 4 Virtual Machines using the above 4 VDI images

  5. Login to the baremetal server directly using mobxterm (do not ssh to bare-metal from anothe unix box. mobxterm will not work)

  6. execute below command to launch the virtualbox software which will be used for creating the virtual machines

                `virtualbox`
    
  7. create a 4 virtual machine by following the document at https//ncdtec.tumblr.com/post/186888967416/launch-vms-using-prebuilt-custom-images-and
    ( password : collect it from project manager)

VM1 name - k8s-master
VM1 vdi file - ncd-ubnt18x86-goldenimage-v1-master.vdi

VM2 name - k8s-node1
VM1 vdi file - ncd-ubnt18x86-goldenimage-v1-node1.vdi

VM3 name - k8s-node2
VM1 vdi file - ncd-ubnt18x86-goldenimage-v1-node2.vdi

VM4 name - k8s-node3
VM1 vdi file - ncd-ubnt18x86-goldenimage-v1-node3.vdi

Bring up all the VMs after they are up.

All VMs will have same username/password : ncodeit/ncodeit123

Installing Kubernetes Master and Nodes

I will add 1 cluster with one Master and three Worker nodes.

Once I add 4 nodes I will proceed with below steps like

Now I will set up a connection between master node and worker nodes

1.Add the Docker gpg key.
curl -fsSL https//download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

2.Add the Docker repository:**
sudo add-apt-repository "deb [arch=amd64] https//download.docker.com/linux/ubuntu \

$(lsb_release -cs) \ stable"

3.Add the Kubernetes gpg key
curl -s https//packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

4.Add the Kubernetes repository
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list

deb https//apt.kubernetes.io/ kubernetes-xenial main

EOF

5.Update your packages
sudo apt-get update

6.Install Docker, kubelet, kubeadm, and kubectl:
sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu kubelet=1.13.5-00 kubeadm=1.13.5-00 kubectl=1.13.5-00

7.Hold Docker and kubernetes at the current version
sudo apt-mark hold docker-ce kubelet kubeadm kubectl

8.Modify Bridge adaptor settings, add the iptables rule to sysctl.conf:
echo “net.bridge.bridge-nf-call-iptables=1” | sudo tee -a /etc/sysctl.conf

9.Enable bridge adaptor settings iptables immediately:
sudo sysctl -p

To join the workers to master I use below commands

10.Initialize the K8s cluster
sudo kubeadm init --pod-network-cidr=10.244.0.0/16

11.Make Directory for K8s:
mkdir -p $HOME/.kube

12.Copy the Kubeconfig:
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

13.Change ownership of the config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

14.Apply Flannel CNI network overlay:
kubectl apply -f https//raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml

15.Join the worker nodes to the cluster:
sudo kubeadm join [your unique string from the kubeadm init command]

Verify the worker nodes have joined the cluster successfully:
kubectl get nodes
sudo kubeadm join [your unique string from the kubeadm init command]

Install Rancher

To install Rancher on your host, connect to it and then use a shell to install.

$ sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher

Use below command to get Ip address

Cat|etc|hosts | grep “rancher.praqma”

Cat|etc|hosts | grep “k8s-prod”

Log in to Rancher to begin using the application.

Log in to Rancher to begin using the application

Go to rancher.praqma.com

Give password

Confirm Password

In url Paste your Ip address and save url.

Once we login we can add cluster

Select Add Cluster select import existing.

Select Production and click create

If we get any errors about certification run the below command