Steevo Wiki

You are here: Home » kubernetes » kubectl

Kubernetes:kubectl

This is an old revision of the document!


kubectl

Delete terminated pods
#!/bin/sh
for namespace in $(kubectl get ns | awk '{print $1}' | grep -v NAME); do
    for pod in $(kubectl get pod -n $namespace --field-selector=status.phase!=Running | grep Terminated | awk '{print $1}' | grep -v NAME); do
      kubectl delete pod -n "$namespace" "$pod"
    done
done
Get secrets with name wildcard
kubectl get secret --no-headers=true | awk '/db-container-v8-credentials/{print $1}' | xargs  kubectl delete secret