Kubernetes - Minikube & Kubectl CLI Cheat Sheet

By Hemanta Sundaray on 2022-07-13

Minikube

Start a multi-node Kubernetes cluster.

minikube start --nodes 2 -p multinode-demo

The command above will create a cluster with 2 nodes: 1 master node & 1 worker node

Check the status of your nodes.

minikube status -p multinode-demo

The command above will create a cluster with 2 nodes: 1 master node & 1 worker node

Start a local Kubernetes cluster

minikube start

Get the status of a local Kubernetes cluster

minikube status

Access the kubernetes dashboard running within the Minikube cluster

minikube dashboard

Return a URL to connect to a service.

minikube service <service_name>

Kubectl

Get the list of deployments

kubectl get deployments or kubectl get deploy

View the nodes in the cluster

kubectl get nodes

Retrieve additional details about Nodes

kubectl describe node

Get the list of pods

kubectl get pods

Get additional details about pods

kubectl describe pods

Get the whole YAML definition of a pod

kubectl get pod <pod_name> -o yaml

Delete a pod

kubectl delete pod <pod_name>

Retrive the container log

kubectl logs <pod_name>

Retrive the container log, when the pod contains multiple containers

kubectl logs <pod_name> -c <container_name>

Retrieving the application log of a crashed container

kubectl logs <pod_name> --previous

Get the list of services

kubectl get services or kubectl get svc

Delete a deployment

kubectl delete deploy <deployment_name>

DaemonSet

Delete a DaemonSet

kubectl delete -f fluentd.yaml

Query the current state of a DaemonSet

kubectl describe daemonset <DaemonSet_name>

Create a Kubernetes object

kubectl apply -f=<file_name>.yaml

Update a kubernetes deployment using a new image

kubectl set image deployment/<deployment_name> <container_name>/<image_name>:<tag_name>

Join the Newsletter