I'm trying to create K8
yaml file that match to:
docker run --privileged
What I'm trying in my K8
yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
spec:
privileged: true
....
But when I'm trying to run kubectl apply -f my.yaml
I got the following error:
error: error validating "my.yaml": error validating data: ValidationError(Deployment.spec): unknown field "privileged" in io.k8s.api.apps.v1.DeploymentSpec; if you choose to ignore these errors, turn validation off with --validate =false
How can I create yaml deployment file with privileged
flag?
privileged: true
needs to be in securityContext
in the spec section of the pod template.
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
labels:
app: test
spec:
replicas: 3
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
spec:
containers:
- name: pause
image: k8s.gcr.io/pause
securityContext:
privileged: true