<p>Here my command line:</p>
<pre><code>kubectl apply -f postgres.secret.yaml \
-f postgres.configmap.yaml \
-f postgres.volume.yaml \
-f postgres.deployment.yaml \
-f postgres.service.yaml
</code></pre>
<p>and i got and error as this picture :
<a href="https://i.stack.imgur.com/8CpqL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8CpqL.png" alt="enter image description here" /></a></p>
<p>Here my yaml file deployment:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
spec:
  replicas: 0
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      restartPolicy: Always
      containers:
        - name: postgres
          image: postgres:12
          ports:
            - containerPort: 5432
          envFrom:
            - secretRef:
              name: postgres-secret
            - configMapRef:
              name: postgres-configmap
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgres-pv
      volumes:
        - name: postgredb
          persistentVolumeClaim:
            claimName: postgres-pv-claim
</code></pre>
<p>And i got an error : Unknown field &quot;name&quot; in io.k8s.api.core.v1.EnvFromSource
I have checked this error everyobdy says that is from space from envFrom however it is rightly indent as the solution they propose.</p>

<p>The indentation is wrong.</p>
<p>It should be:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
spec:
  replicas: 0
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      restartPolicy: Always
      containers:
        - name: postgres
          image: postgres:12
          ports:
            - containerPort: 5432
          envFrom:
            - secretRef:
                name: postgres-secret
            - configMapRef:
                name: postgres-configmap
          volumeMounts:
            - mountPath: /var/lib/postgresql/data
              name: postgres-pv
      volumes:
        - name: postgredb
          persistentVolumeClaim:
            claimName: postgres-pv-claim

</code></pre>
<p>i.e. <code>name</code> should be indented under the <code>secretRef</code> or <code>configMapRef</code> fields</p>
