kubernetes cluster
Search Posts
how to launch kubernetes cluster using ncodeit k8 custom image
Video – https://www.youtube.com/watch?v=Llh-GhhK-uA&list=PLL7rh2YAHA3bYc1xgWMLc5deImoZn2ods&index=9&t=0s
Mandatory Guidelines :
1
2 3 4 5 6 7 8 9 |
1) Everything should be built on VMs only.Ubuntu16.04 LTS.VMs should be based on KVM hypervisor
No other hypervisor (VMWare,Virtualbox) is allowed. 2) All VMs sholud be launched with below qcow2 image. (meta file for the qcow2 image is also given) → ncd-ubuntu1604min-lxd3.3.0-v1-sparcified-kubernetes-master-v1.11.1-docker-v17.03.2-ce-070818-DHCP.qcow2 → ncd-ubuntu1604min-lxd3.3.0-v1-sparcified-kubernetes-master-v1.11.1-docker-v17.03.2-ce-070818-DHCP.meta → ncd-ubuntu1604min-lxd3.3.0-v1-sparcified-kubernetes-node-v1.11.1-docker-v17.03.2-ce-070818-DHCP.qcow2 → ncd-ubuntu1604min-lxd3.3.0-v1-sparcified-kubernetes-node-v1.11.1-docker-v17.03.2-ce-070818-DHCP.meta Above 2 files available at ncdftp@192.168.12.142:/home/ncdftp/Lkvms2 password for ncdftp user is ncodeit1234 |
Create a new KVM based Ubuntu VM :
launch the master & node VMs using virt-manager
→ Open virt manager
$ virt-manager
→ Click on File
→ Select create new virtual machine
→ Select “import existing disk image”
→ Select qcow2 image from image directory
→ Select RAM as per requirement
→ Select Network selection “Select Bridge br0”
→ Select finish.
Steps Only For Kubernetes Master VM (kmaster)
Note: These steps will only be executed on the master node (kmaster VM).
Step 1: We will now reset kubeadm from the master’s machine. Run the following command:
1
|
$ sudo kubeadm reset
|

Step 2: We will now start our Kubernetes cluster from the master’s machine. Run the following command:
$ kubeadm init --apiserver-advertise-address=<ip-address-of-kmaster-vm> --pod-network-cidr=192.168.0.0/16

Step 3: As mentioned before, run the commands from the above output as a non-root user
1
2 3 |
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config $ sudo chown $(id -u):$(id -g) $HOME/.kube/config |
It should look like this:

To verify, if kubectl is working or not, run the following command:
1
|
$ kubectl get pods -o wide --all-namespaces
|

Step 4: You will notice from the previous command, that all the pods are running except one: ‘kube-dns’. For resolving this we will install a pod network. To install the CALICO pod network, run the following command:
1
|
$ kubectl apply -f https://docs.projectcalico.org/v3.0/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml
|
After some time, you will notice that all pods shift to the running state

Step 5: Next, we will install the dashboard. To install the Dashboard, run the following command:
1
|
$ kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
|
It will look something like this:

Your dashboard is now ready with it’s the pod in the running state.

Step 6: By default dashboard will not be visible on the Master VM. Run the following command in the command line:
1
|
$ kubectl proxy
|
Step 7: In this step, we will create the service account for the dashboard and get it’s credentials.
Note: Run all these commands in a new terminal, or your kubectl proxy command will stop.
Note: Run all these commands in a new terminal, or your kubectl proxy command will stop.
Run the following commands:
1. This command will create a service account for dashboard in the default namespace
1
|
$ kubectl create serviceaccount dashboard -n default
|
2. This command will add the cluster binding rules to your dashboard account
1
2 3 |
$ kubectl create clusterrolebinding dashboard-admin -n default \
--clusterrole=cluster-admin \ --serviceaccount=default:dashboard |

step 8 : Run this commands to access kubernetes dashboard in browser
$ kubectl proxy --accept-hosts='^.*$' --address=VM masterIp &
Now Access Dashboard in browser by below mentioned command
1
|
http://VM masterip:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login
|

step 9 : Now to access kubernetes dashboard without token run the below command
1
|
kubectl create -f dashboard-admin.yaml
|
Access the dashboard again and click skip
you should be able to login now and the output will like below screenshot.

Steps For Only Kubernetes Node VM (knode)
It is time to get your node, to join the cluster! This is probably the only step that you will be doing on the node, after installing kubernetes on it.
Run the join command that you saved, when you ran ‘kubeadm init’ command on the master.
Note: Run this command with “sudo”.
sudo kubeadm join --apiserver-advertise-address=<ip-address-of-the master> --pod-network-cidr=192.168.0.0/16
Video – https://www.youtube.com/watch?v=Llh-GhhK-uA&list=PLL7rh2YAHA3bYc1xgWMLc5deImoZn2ods&index=9&t=0s
Mandatory Guidelines :
1
2 3 4 5 6 7 8 9 |
1) Everything should be built on VMs only.Ubuntu16.04 LTS.VMs should be based on KVM hypervisor
No other hypervisor (VMWare,Virtualbox) is allowed. 2) All VMs sholud be launched with below qcow2 image. (meta file for the qcow2 image is also given) → ncd-ubuntu1604min-lxd3.3.0-v1-sparcified-kubernetes-master-v1.11.1-docker-v17.03.2-ce-070818-DHCP.qcow2 → ncd-ubuntu1604min-lxd3.3.0-v1-sparcified-kubernetes-master-v1.11.1-docker-v17.03.2-ce-070818-DHCP.meta → ncd-ubuntu1604min-lxd3.3.0-v1-sparcified-kubernetes-node-v1.11.1-docker-v17.03.2-ce-070818-DHCP.qcow2 → ncd-ubuntu1604min-lxd3.3.0-v1-sparcified-kubernetes-node-v1.11.1-docker-v17.03.2-ce-070818-DHCP.meta Above 2 files available at ncdftp@192.168.12.142:/home/ncdftp/Lkvms2 password for ncdftp user is ncodeit1234 |
Create a new KVM based Ubuntu VM :
launch the master & node VMs using virt-manager
→ Open virt manager
$ virt-manager
→ Click on File
→ Select create new virtual machine
→ Select “import existing disk image”
→ Select qcow2 image from image directory
→ Select RAM as per requirement
→ Select Network selection “Select Bridge br0”
→ Select finish.
Steps Only For Kubernetes Master VM (kmaster)
Note: These steps will only be executed on the master node (kmaster VM).
Step 1: We will now reset kubeadm from the master’s machine. Run the following command:
1
|
$ sudo kubeadm reset
|

Step 2: We will now start our Kubernetes cluster from the master’s machine. Run the following command:
1
|
$ kubeadm init --apiserver-advertise-address=0.0.0.0 --pod-network-cidr=192.168.51.0/24
|

Step 3: As mentioned before, run the commands from the above output as a non-root user
1
2 3 |
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config $ sudo chown $(id -u):$(id -g) $HOME/.kube/config |
It should look like this:

To verify, if kubectl is working or not, run the following command:
1
|
$ kubectl get pods -o wide --all-namespaces
|

Step 4: You will notice from the previous command, that all the pods are running except one: ‘kube-dns’. For resolving this we will install a pod network. To install the CALICO pod network, run the following command:
1
|
$ kubectl apply -f https://docs.projectcalico.org/v3.0/getting-started/kubernetes/installation/hosted/kubeadm/1.7/calico.yaml
|
After some time, you will notice that all pods shift to the running state

Step 5: Next, we will install the dashboard. To install the Dashboard, run the following command:
1
|
$ kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
|
It will look something like this:

Your dashboard is now ready with it’s the pod in the running state.

Step 6: By default dashboard will not be visible on the Master VM. Run the following command in the command line:
1
|
$ kubectl proxy
|
Step 7: In this step, we will create the service account for the dashboard and get it’s credentials.
Note: Run all these commands in a new terminal, or your kubectl proxy command will stop.
Note: Run all these commands in a new terminal, or your kubectl proxy command will stop.
Run the following commands:
1. This command will create a service account for dashboard in the default namespace
1
|
$ kubectl create serviceaccount dashboard -n default
|
2. This command will add the cluster binding rules to your dashboard account
1
2 3 |
$ kubectl create clusterrolebinding dashboard-admin -n default \
--clusterrole=cluster-admin \ --serviceaccount=default:dashboard |

step 8 : Run this commands to access kubernetes dashboard in browser
$ kubectl proxy --accept-hosts='^.*$' --address=VM masterIp &
Now Access Dashboard in browser by below mentioned command
1
|
http://VM masterip:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login
|

step 9 : Now to access kubernetes dashboard without token run the below command
1
|
kubectl create -f dashboard-admin.yaml
|
Access the dashboard again and click skip
you should be able to login now and the output will like below screenshot.

Steps For Only Kubernetes Node VM (knode)
It is time to get your node, to join the cluster! This is probably the only step that you will be doing on the node, after installing kubernetes on it.
Run the join command that you saved, when you ran ‘kubeadm init’ command on the master.
Note: Run this command with “sudo”.
sudo kubeadm join --apiserver-advertise-address=<ip-address-of-the master> --pod-network-cidr=192.168.0.0/16

No comments:
Post a Comment