Given following AKS advisor recommendation "Running containers as root user should be avoided" with following remediation step:
- For these pods, add rule: 'MustRunAsNonRoot' in a runAsUser section of the container's spec.
I should note here that MustRunAsNonRoot
is part of PodSecurityPolicy
, which should not be used anymore with AKS, as noted in How to enforce MustRunAsNonRoot policy in K8S cluster in AKS
I added runAsNonRoot: true
to the pod's securityContext
:
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
...
creationTimestamp: "2021-09-28T14:02:34Z"
generation: 13
labels:
app.kubernetes.io/managed-by: Helm
name: my-service
namespace: my-namespace
resourceVersion: "..."
uid: ...
spec:
replicas: 1
...
template:
metadata:
...
spec:
securityContext:
runAsNonRoot: true
... but the resource is still being listed for this recommendation. What do I miss here, what should I change in order to fulfill this recommendation?