Kubectl

👍 Cheatsheet

  • uses curl under the hood

  • kubectl [command] --help

  • kubectl api-versions

  • kubectl get nodes

  • kubectl get all

  • ⚠️ @Deprecated kubectl run

    • kubectl run ngnix-run --image=nginx

The context that kubectl uses is stored in ~/.kube/config . (kubectl config view shows parts of current configuration).

  • kubectl inspect -> etcs

  • kubectl logs -> pod

  • kubectl exec -it -> container

Pod commands

  • kubectl create -f podDefinitionFile.yaml

  • kubectl delete pods [name]

  • kubectl get pods [pod_name]

  • kubectl get pods -o wide

Deployment commands

kubectl rollout status deployment nginx-deployment

ReplicaSet commands

k get rs -o wide

Curl

You need kubectl proxy to use curl commands. kubectl proxy --port=8001 &

Proxy takes care of TLS connection => you can use http .

Authentication/Authorization

  • kubectl config specifies to which cluster to authenticate

  • authorization is what this users can do

    • behind is a RBAC

    • kubectl auth can-i get prods to find out what you can do

Useful utilities

  • brew install kubectx

  • brew install kube-ps1

Last updated