<p>Is there anyway to list all securityContext including default and defined:</p>
<ol>
<li>Pod Level</li>
<li>Container Level</li>
</ol>
<p>Using <code>kubectl get pod -o yaml</code> only show the defined in <code>spec.securityContext</code> and <code>spec.containers[*].securityContext</code> of manifest without the default one?</p>

skystone
<p>Here you are, source can be found <a href="https://medium.com/@pjbgf/kubectl-list-security-context-settings-for-all-pods-containers-within-a-cluster-93349681ef5d" rel="noreferrer">in this medium article</a>:</p>
<pre><code>kubectl get pods --all-namespaces -o go-template \
    --template='{{range .items}}{{&quot;pod: &quot;}}{{.metadata.name}}
{{if .spec.securityContext}}
  PodSecurityContext:
    {{&quot;runAsGroup: &quot;}}{{.spec.securityContext.runAsGroup}}                               
    {{&quot;runAsNonRoot: &quot;}}{{.spec.securityContext.runAsNonRoot}}                           
    {{&quot;runAsUser: &quot;}}{{.spec.securityContext.runAsUser}}                                 {{if .spec.securityContext.seLinuxOptions}}
    {{&quot;seLinuxOptions: &quot;}}{{.spec.securityContext.seLinuxOptions}}                       {{end}}
{{else}}PodSecurity Context is not set
{{end}}{{range .spec.containers}}
{{&quot;container name: &quot;}}{{.name}}
{{&quot;image: &quot;}}{{.image}}{{if .securityContext}}                                      
    {{&quot;allowPrivilegeEscalation: &quot;}}{{.securityContext.allowPrivilegeEscalation}}   {{if .securityContext.capabilities}}
    {{&quot;capabilities: &quot;}}{{.securityContext.capabilities}}                           {{end}}
    {{&quot;privileged: &quot;}}{{.securityContext.privileged}}                               {{if .securityContext.procMount}}
    {{&quot;procMount: &quot;}}{{.securityContext.procMount}}                                 {{end}}
    {{&quot;readOnlyRootFilesystem: &quot;}}{{.securityContext.readOnlyRootFilesystem}}       
    {{&quot;runAsGroup: &quot;}}{{.securityContext.runAsGroup}}                               
    {{&quot;runAsNonRoot: &quot;}}{{.securityContext.runAsNonRoot}}                           
    {{&quot;runAsUser: &quot;}}{{.securityContext.runAsUser}}                                 {{if .securityContext.seLinuxOptions}}
    {{&quot;seLinuxOptions: &quot;}}{{.securityContext.seLinuxOptions}}                       {{end}}{{if .securityContext.windowsOptions}}
    {{&quot;windowsOptions: &quot;}}{{.securityContext.windowsOptions}}                       {{end}}
{{else}}
    SecurityContext is not set
{{end}}
{{end}}{{end}}'
</code></pre>
