Skip to content

Instantly share code, notes, and snippets.

@phsteve
Created May 7, 2025 16:13
Show Gist options
  • Select an option

  • Save phsteve/504fc2e757ca3fa1b75899742a140efb to your computer and use it in GitHub Desktop.

Select an option

Save phsteve/504fc2e757ca3fa1b75899742a140efb to your computer and use it in GitHub Desktop.
Kube cheatsheet

Find all deployments/cronjobs using a particular secret:

NAMESPACE=the-namespace KUBE_CONTEXT=the-context SECRET_NAME=the-secret-name; kubectl get deployments,cronjobs -n $NAMESPACE --context ${KUBE_CONTEXT} -o json | jq -j --arg secret "${SECRET_NAME}" '.items[]|select(.spec.template.spec.containers[]?.env[]?.valueFrom.secretKeyRef.name == $secret) | "\(.kind): \(.metadata.name)\n"' | sort | uniq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment