Skip to content

Instantly share code, notes, and snippets.

@onmomo
Last active February 2, 2023 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onmomo/25407bc76be15554b4f85fd8fce4395e to your computer and use it in GitHub Desktop.
Save onmomo/25407bc76be15554b4f85fd8fce4395e to your computer and use it in GitHub Desktop.
[kubectl magic] cheatsheet #k8s
# export, import secrets < 1.14
kubectl get secret $my-secret --export -o yaml -n $source-ns | kubectl -n $target-ns apply -f -
# export => 1.14
SECRET= SOURCE= TARGET= \
&& kubectl get secret $SECRET --namespace=$SOURCE -o yaml | sed "s/namespace: .*/namespace: $TARGET/" | kubectl apply -f -
# force delete resources
kubectl -n prometheus delete --force --grace-period=0 pod
# run pod from any image
kubectl run -i --tty busybox --image=busybox --restart=Never -- bash
# get service ingress lb
kubectl get svc -A | grep -i nginx
# headless service SRV record lookup
kubectl run -i --tty busybox --image=k8s.gcr.io/e2e-test-images/jessie-dnsutils:1.3 --restart=Never -- bash
nslookup -type=srv apache-kafka-headless
# lookup resource descriptions
kubectl explain pods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment