<p>I'm  trying to create <code>K8</code> yaml file that match to:</p>

<pre><code>docker run --privileged
</code></pre>

<p>What I'm  trying in my <code>K8</code> yaml:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
spec:
  privileged: true
....
</code></pre>

<p>But when I'm trying to run <code>kubectl apply -f my.yaml</code> I got the following error:</p>

<blockquote>
  <p>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</p>
</blockquote>

<p>How can I create yaml deployment file with <code>privileged</code> flag?</p>

samisaviv
<p><code>privileged: true</code> needs to be in <code>securityContext</code> in the spec section of the pod template.</p>

<pre><code>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
</code></pre>
