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: https://minikube.sigs.k8s.io/docs/start/ 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.