Skip to content

Instantly share code, notes, and snippets.

@tommeramber
Last active June 21, 2025 12:06
Show Gist options
  • Save tommeramber/87c82525ed31c0605478b4c82b5f048c to your computer and use it in GitHub Desktop.
Save tommeramber/87c82525ed31c0605478b4c82b5f048c to your computer and use it in GitHub Desktop.
for NAMESPACE in $(oc get namespace --no-headers | awk '{print $1}' | grep -v "openshift-*") ;
do
oc get deployment,deploymentconfig -o name -n $NAMESPACE |\
xargs -n 1 -I OBJECT oc get OBJECT -o json -n $NS 2>/dev/null |\
jq -r 'select(.spec.template.spec.containers[].securityContext!={}) |
"Kind: " + .metadata.kind,
"NAME: " + .metadata.name,
"NAMESPACE: " + .metadata.namespace,
"To see the exact SCC, run:",
"oc get " + .kind + " " + .metadata.name + " -n " .metadata.namespace + " -o jsonpath={.spec.template.spec.containers[].securityContext} | jq .",
"\n"'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment