Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pandeybk/20809559381aeb5afd390e1447c336bc to your computer and use it in GitHub Desktop.
Save pandeybk/20809559381aeb5afd390e1447c336bc to your computer and use it in GitHub Desktop.
kubectl handy gist
# Copying kubernetes resources accross namespaces
kubectl get rs,secrets -o json --namespace old | jq '.items[].metadata.namespace = "new"' | kubectl create -f -
kubectl get cm -o json --namespace old some-config-map | jq '.metadata.namespace = "new"' | kubectl create -f -
# kubectl exec in each pods
for pod in `kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'`; do echo $pod date:; kubectl exec -it $pod -- date ; echo "--------------"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment