I have pod level security context like in below snippet:
spec:
securityContext:
runAsUser: 1010
runAsGroup: 1010
fsGroup: 1010
containers:
--------
-------
one of my container need root privileges so I added one more securityContext as below:
spec:
securityContext:
runAsUser: 1010
runAsGroup: 1010
fsGroup: 1010
containers:
- name: sample
securityContext:
runAsUser: 0
image: sampleimage
----------------
-----------------
Now my container is able to run with root privileges but my requirement is rather than making runAsUser: 0 which is root! Is there any other way we can escalate privileges for container alone using same runAsUser: 1010 ?
I found some options like allowPrivilegeEscalation: true & capabilities: but no luck! maybe am using it in wrong way.
containers:
- image: sampleimage
name: sample
securityContext:
allowPrivilegeEscalation: true
AND
containers:
- image: sampleimage
name: sample
securityContext:
capabilities:
add: ["SYS_ADMIN"]
Can anyone help by correcting my code or help with an example to refer to and implement? Please.