Kubernetes Commands
Debugging
https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-output-verbosity-and-debugging
--v=9is good for seeing values, put into JSON formatter
Get logs for pod
$ kubectl logs <pod_name>Get logs for ingress controller
$ kubectl logs -n kube-system $(kubectl get po -n kube-system | egrep -o 'alb-ingress[a-zA-Z0-9-]+')Spinning up the instances
$ kubectl run --replicas=1000 web-server # deploys an application on the cluster 1000 timesScaling the instances
$ kubectl run --replicas=1000 web-server
$ kubectl scale --replaces=2000 web-server # scales up the current webserver to 2000 instancesUpdating the instances
# Updates all instances to the given image
$ kubectl rolling-update web-server --image=web-server:2Rollback
# If something goes wrong in the updates, we can always roll back all the instances
$ kubectl rolling-update web-server --rollbackView Information on the Cluster
$ kubectl cluster-infoSee nodes in cluster
$ kubectl get nodesList pods
$ kubectl get podsDescribe pods (Troubleshooting)
$ kubectl describe pod <pod_name>Exec into bash
$ kubectl exec -it <pod_name> -c <container_name> -- /bin/bashDelete pods by pattern
kubectl get pods -n default --no-headers=true | awk '/<word>/{print $1}'| xargs kubectl delete -n default podLast updated
Was this helpful?