Skip to content


What Where
Official Page

kubectl controls the Kubernetes cluster manager


Some basics to get information:

kubectl get nodes
kubectl describe node <your-node>
kubectl get namespaces
kubectl get pods -o wide --all-namespaces
  • Set contect to namespace: kubectl config set-context --current --namespace=<your-namespace>
  • Dump pod logs, with label name=myLabel (stdout): kubectl logs -l name=myLabel -c my-container
  • Restart Rollout (and pull container image if imagePullPolicy: Always): kubectl rollout restart deployment/frontend
  • Auto scale a deployment "foo": kubectl autoscale deployment foo --cpu-percent=20 --min=1 --max=10
  • Delete Nodepool: az aks nodepool delete -n OldNodePool --cluster-name MyManagedCluster -g MyResourceGroup

Delete all evicted pods:

kubectl get pod -n mynamespace | grep Evicted | awk '{print $1}' | xargs kubectl delete pod -n mynamespace

Port forwarding

Simple example:

kubectl port-forward mycontainer 8080:3000

Retrieve information about resources in the cluster

  • List all pods: kubectl get pods
  • ist all deployments kubectl get deployments
  • List all services kubectl get services
  • List all nodes in the cluster kubectl get nodes

Provide detailed information about a specific resource

  • Get pod details kubectl describe pod <pod-name>
  • Get deployment details kubectl describe deployment <deployment-name>
  • Get service details kubectl describe service <service-name>

Create a resource from a YAML or JSON file

  • Create a resource from a YAML file kubectl create -f <filename.yaml>
  • Create a deployment using a specified image kubectl create deployment <deployment-name> --image=<image-name>

Delete a resource

  • Delete a pod kubectl delete pod <pod-name>
  • Delete a deployment kubectl delete deployment <deployment-name>
  • Delete a service kubectl delete service <service-name>


  • Scale deployment replicas kubectl scale deployment <deployment-name> --replicas=<number>
  • Print pod logs kubectl logs <pod-name>
  • Execute a command on a pod kubectl exec -it <pod-name> -- <command>
  • Apply changes to a resource using a YAML file kubectl apply -f <filename.yaml>

Kubernetes Dashboard

Running Docker for Windows with enabled Kubernetes Cluster

Deploy Kubernetes Dashboard: kubectl apply -f Verify that it's running: kubectl get -f .\recommended.yaml.txt

Get token:

Create a user:

  • Create a Cluster Admin service account: kubectl create serviceaccount dashboard -n default
  • Add the cluster binding rules to your dashboard account: kubectl create clusterrolebinding dashboard-admin -n default --clusterrole=cluster-admin --serviceaccount=default:dashboard
  • Get the secret token with this command: kubectl get secret $(kubectl get serviceaccount dashboard -o jsonpath="{.secrets[0].name}") -o jsonpath="{.data.token}" | base64 --decode
  • Choose token authentication in the Kubernetes dashboard login page.

Azure Kubernetes Service (AKS)


az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
az acr login --name myAKSCluster
docker login


az aks nodepool list --cluster-name MyManagedCluster -g MyResourceGroup -o table```
az aks nodepool add -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --node-vm-size=Standard_XX --mode User

Pods and namespaces

kubectl get nodes
kubectl describe node your-node
kubectl get namespaces
kubectl get pods -o wide --all-namespaces
kubectl config set-context --current --namespace=your-namespace

Other Kubernetes Tools

More tools