Kubernetes

My collection of favorite kubernetes commands

Kubectl run small busybox instance for debugging

1
2
3
4
5
kubectl run -i --tty --rm alpine --image=alpine -- sh

#Enter pod after deployment

kubectl exec -i --tty busybox -- sh

MSSQL Tools

1
2
3
kubectl run -i mssql-tools --image=mcr.microsoft.com/mssql-tools

sqlcmd -S {SERVER_IP} -d {DB_NAME} -U {DB_USERNAME} -P {DB_PASSWORD}

Troubleshoot K8S networking with Netshoot

1
kubectl run --rm -i --tty debug --image=nicolaka/netshoot --restart=Never -- curl -H "Host: mysite.com" http://{Ingress_IP} -v

Troubleshoot flux reconciliation

1
2
3
kubectl get kustomizations.kustomize.toolkit.fluxcd.io -A

flux get ks -A 

Kubectl unseal secret

1
kubectl get secret -n {NS_NAME} {SECRET_NAME} -o jsonpath='{.data.vault-root}'|base64 -d

Kubectl see all verbs

1
kubectl api-resources --no-headers --sort-by name -o wide | sed 's/.*\[//g' | tr -d "]" | tr " " "\n" | sort | uniq