Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nanox/81fdbdd1eb7d1022ccef25171607a6df to your computer and use it in GitHub Desktop.
Save nanox/81fdbdd1eb7d1022ccef25171607a6df 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