CKAD security Context practice

Hi, The solution for question #2 in security contexts in CKAD cource is not working. Followed below steps,

  1. Exported the live object to yaml
  2. Deleted running pod
  3. Edited the yaml to add securityContext → runAsUser = 1010
  4. Created the pod,
    The solution given is also same, but the user is still shown as root and the last check of the three is failing.
    What am I doing wrong?

Hello @pramod-suryawanshi,
Try this

---
apiVersion: v1
kind: Pod
metadata:
  name: ubuntu-sleeper
  namespace: default
spec:
  securityContext:
    runAsUser: 1010
  containers:
  - command:
    - sleep
    - "4800"
    image: ubuntu
    name: ubuntu-sleeper

Hi @pramod-suryawanshi ,
Maybe because there is one more same-name field available. By default, it’s picking the second field.

cat <NAME>.yaml | grep securityContext

Make use of the grep command to filter out the same name fields.

Regards,

You can compare it with the given manifest file.