Hands dirty with Kubernetes

The smallest entity Kubernetes can manage is pod: specification of how to run the containers. The pod have network and the storage. Identical Pods can be in a collection called replicas set. Replicaset guarantee the availability of the deployment. However, Kubernetes cannot handle services as well as deployment. Through the services, deployment is exposed. Same Kubernetes host, there can be number of Pods, the namespace define the group of pods belongs to each other: guarantee the secure environment.

Architecture .

Following are running in the very well defined processes

  • Head Node
  • Worker Node

Head Node

  • API server
  • scheduler- Place the containers where need to go
  • Controller Manager- state of the system
  • Etcd-Data store to store the state
  • Kubelet
  • docker

Worker Node

  • Kubelet is Kubenetes agent runs on all the cluster nodes Talks to API and local docker demon to manage the docker containers.
  • Kube-proxy manage the trafie of the PODS and the node
  • docker

Install in OSX

Follow the following steps

  1. First install the Kubernates client as follows

        brew install kubectl
    
  2. Install virtual box if not available already

        brew cask install virtualbox
    
  3. Install the minikube :

        curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.26.1/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
    
  4. start the minicube

        minikube start
    
  5. check the status:

        ~ minikube status
        minikube: Running
    cluster: Running
    kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100

If you want to find the version of client:

~ kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.1", GitCommit:"d4ab47518836c750f9949b9e0d387f20fb92260b", GitTreeState:"clean", BuildDate:"2018-04-13T22:27:55Z", GoVersion:"go1.9.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-26T16:44:10Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

Now you can get the nodes as follows

    ~ kubectl get nodes
    NAME       STATUS    ROLES     AGE       VERSION
    minikube   Ready     master    27m       v1.10.0

Connect to minikube

~ minikube ssh
                         _             _
            _         _ ( )           ( )
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __
/' _ ` _ `\| |/' _ `\| || , <  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

$

Let us create gost pod from docker

kubectl run ghost --image=ghost

Now deployment is read

~ kubectl get deployments
NAME      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
ghost     1         1         1            0           1m

After a moment you can check the pods

~ kubectl get pods
NAME                    READY     STATUS    RESTARTS   AGE
ghost-8b5b9d7fd-hwchj   1/1       Running   0          3m

You can delete the pod as follows

kubectl delete deployments ghost

To access the API Server, you need to run the proxy first

kubectl proxy

Access the proxy to find the pods

curl http://127.0.0.1:8001/api/v1/namespaces/default/pods

For further information please refer to the following tutorials:

  1. Minikube Introduction

Comments

Popular posts from this blog

How To: GitHub projects in Spring Tool Suite

Spring 3 Part 7: Spring with Databases

Parse the namespace based XML using Python