Minikube & Kubectl -Basic Operations

Minikube & Kubectl will help the developer to create the cluster environment in the local machine and can test the functionality to gain more confidence in the deployment pipeline. Minikube is a one-node cluster environment that contains the master and worker process, which creates a virtual box in the local environment and node runs on top of the virtual box.

Install minkube using the official URL: follow instructions based on the operating system.

Once done open the command prompt and execute: minikube start.

Kubectl is used to communicate with API server, Master process contains the API server and is the entry point for the Kubernetes.

Will check basic commands to check the status of minikubes 

kubectl get node: will give the node details with the status

minikube status: will give details about the minikube components

* The main advantage of Kubernetes is the replicaSet, Kubernetes will take care of taking the replication of the pods, and pod is the smallest unit in the Kubernetes cluster.

Trying to deploy mongo in Kubernetes and we can make the pod up using the command:

Deployment using the images directly from the DockerHub

kubectl create deployment mongo-dployment --image=mongo

will check that this deployment created the pod ready for business using the command: kubectl get pod

To get the logs of the pod deployment kubectl logs <pod-name>  or to get  structured information

kubectl describe pod  <pod-name>

to get into the interactive terminal can use the same docker syntax like kubectl exec -it <pod-name> bash

Kubernetes used to take care of the replication, we can check this by using kubectl get replicaset

 To scale the pod up and down use the below command 

kubectl scale deployment mongo-dployment --replicas=2 

Pods and Deployments before calling.

Pods and Deployment After scaling

* replicaset is automatically taken care by Kubernetes and it will increase automatically 😲

To get equivalent deployment.yaml from use the command:kubectl get deploy mongo-dployment -o yaml

Else generate yaml file using the command : kubectl get deploy mongo-dployment -o yaml >deployment.yaml

This yaml can be used for the deployment, will explain in the below section.

To delete the deployment

to delete the deployment: kubectl delete deployment mongo-dployment

Deployment using Deployment Descriptor (.yaml file) 

We can deploy applications in the Kubernetes using yaml file.

Here we are using the yaml file which we generated in the above section using the command kubectl get deploy mongo-dployment -o yaml >deployment.yaml

It will generate a yaml file in the directory.

Apply this deployment.yaml to create deployment: kubectl apply -f deployment.yaml and check the deployments.

We can scale up or scale down the deployments by editing the replica sections provided in the deployment.yaml file.

*Note: Before do editing reexport the document then make the changes else versioning errors may occur. (kubectl get deploy mongo-dployment -o yaml >deployment.yaml)

Apply the deployment.yaml again to see the changes

We can check the replicaset, kubernetes take care of the calling automatically.


Popular posts from this blog

Linux Basics

JAVA 8 Predefined Functions