Easiest way to install Kubernates on your machine

Why I should learn Kubernates


Below are some of the points which might motivates you towards kubernates . If you want to learn more technical toward is then click on Kubernates basics and its architecture

  • It gives same environment right from dev machine to production
  • Handle different micros services together
  • Open Source product from Google
  • Strong community support
  • Can run in multi cloud environment
  • One of the hottest trends on devops industry

Kubernates Installation instructions through vagrant



Part 1: Installation of Kubernates master and 2 nodes

Part 2: Installing &configuring kubernates dashboard

Pre-requisite:

  1. You should have a machine with minimum 8 GB of RAM (10 GB recommended)
    1. 2 GB for master
    2. 2 GB for node1
    3. 2 GB for node 2
    4. 2 GB for virtual box and vagrant
    5. 2 GB for your machine
  2. In my case I am running windows as host machine, You might be linux machine on which Vagrant should be up and running.

 

Part 1: Installation of Kubernates master and 2 nodes

  1. Download vagrant file from here and put it in a direcotry like Kubernates
  2. Go to command line and “cd Kubernates”
  3. Run the command “vagrant up” and wait until it gets completed
  4. You should have all 3 machines up and running. Just to confirm run command “vagrant global-status”. It should show all 3 machines are running. The output might be something like:-

 

id       name        provider   state   directory

——————————————————————————

5d7b60e  k8s-master  virtualbox running C:/My-Kube-Machine/Kubernates

02cb68a  k8s-slave-1 virtualbox running C:/My-Kube-Machine/Kubernates

21ce8d2  k8s-slave-2 virtualbox running C:/My-Kube-Machine/Kubernates

 

  1. Run command “vagrant ssh k8s-master
  2. Verify if the two command works without any error

Command1: kubectl get nodes

Command 2: kubectl get pods

 

If both commands are giving proper response like in below picture. You are good to go.

Get command screen

Get command screen

Part 2: Installing & configuring kubernates dashboard

  1. SSH into master node through vagrant ssh k8s-master
  2. Install kubernates-dashboard. To install run the below command:
kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
    1. Now run the command “kubectl create serviceaccount dashboard -n default
    2. kubectl create clusterrolebinding dashboard-admin -n default --clusterrole=cluster-admin --serviceaccount=default:dashboard
    3. To get the credentials in order to login to you kubernates dashboard. Run the command:-
      
      kubectl get secret $(kubectl get serviceaccount dashboard -o jsonpath="{.secrets[0].name}") -o jsonpath="{.data.token}" | base64 --decode 
    4. Go to another window and ssh into master node and run the command
      kubectl proxy --address 192.168.33.60 --port=9999 --accept-hosts='^*$'
    5. Now browse http://192.168.33.60:9999. This url is working now but its not showing dashboard yet.
    6. To see the dashboard open the link

http://192.168.33.60:9999/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login

 

    1. Enter the token from first window and use it for login and login it from there.
    2. You might see permission problem on dashboard.. if you seen then run below command on master nodes
      kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard 

    Related posts:

    The following two tabs change content below.

    Chandra Shekhar

    GCP Architect
    Chandra Shekhar Pandey is Google certified Cloud engineer, I am Magento2 Trained developer. Having huge experience in designing cloud solution. I have around 12 years of experience with world enterprise IT companies and fortune 500 clients. During my architecture design I am always caring about high availability, fast performance and resilient system. From the programmer background I have huge experience in LAMP stack as well. Throughout my carrier I have worked on Retail, E-Learning, Video... Read More about Chandra Shekhar

    Latest posts by Chandra Shekhar (see all)