A lot of the examples require jq
to be installed
command: ["/bin/bash", "-c", "--"]args: ["while true; do sleep 30; done;"]
kubectl
kubectl create job --from=cronjob/<cronjob-name> <job-name>
kubectl get --all-namespaces pods |awk '/Terminating/ { print $1 " " $2 }' |xargs -I{} bash -c "kubectl delete pods -n {} --force --grace-period=0
kubectl get deployment --all-namespaces -o json |jq '.items[] | select (.metadata.labels["app.kubernetes.io/managed-by"] == "Helm") | { "name": .metadata.name, "namespace": .metadata.namespace }'
kubectl get --all-namespaces pods -o json |jq '.items[] | select(.spec.nodeSelector["cloud.google.com/gke-nodepool"] == "misc") | .metadata.name'
.*app.*
kubectl get --all-namespaces pods -o json |jq '.items[].metadata.labels | with_entries(select(.key | test(".*app.*")))'
kubectl get pods -l colour=green -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' |xargs -I{} kubectl -n somenamespace exec -it {} -c fpm date
kubectl delete pods --field-selector status.phase==Failed
kubectl get --all-namespaces pods -o json |jq '.items[] | select(.spec.nodeName | contains("worker")) | .metadata.name'
kubectl get --all-namespaces pods -o json | jq 'select(.items[].status.podIP == "10.10.10.10") | .items[].metadata.name'
kubectl get --all-namespaces pods -o json | jq 'select(.items[].status.hostIP == "10.10.10.10") | .items[].metadata.name'
kubectl get pods pod-name -o json | jq '.status.containerStatuses[] | select(.ready == false)'
kubectl get pod -o=custom-columns=NAME:.metadata.name,STATUS:.status.phase,NODE:.spec.nodeName --all-namespaces
kubectl get pods mypodname -o jsonpath={.spec.containers[*].name}
...or in multiple pods
kubectl pods -o jsonpath={.items[*].spec.containers[*].name}