<p>I am doing a lab about Kubernetes. I have created the YAML file, but when I am trying to deploy it in a shell, it shows me this error:</p>
<blockquote>
<p>error: error parsing mongodb-deployment.yaml: error converting YAML to JSON: yaml: line 27: did not find expected key</p>
</blockquote>
<p>This is the YAML file for MongoDB for Kubernetes:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
 name: mongodb-deployment
 labels:
   app: mongodb
spec:
  replicas: 1
  selector:
   matchLabels:
     app: mongodb
   template:
     metadata:
       labels:
         app: mongodb
     spec:
       containers:
       - name: mongodb
         image: mongo
         ports:
         - containerPort: 27017
         env:
         - name: MONGO_INITDB_ROOT_USERNAME
           valueFROM:
             secretKeyRef:
                name: mongodb-secret
                key: mongo-root-username
         - name: MONGO_INITDB_ROOT_PASSWORD
           valueFROM:
             secretKeyRef:
                name: mongodb-secret
                key: mongo-root-password
</code></pre>

Battistis Ciccio Rossi
<p><code>valueFROM</code> is changed to <code>valueFrom</code>. Also, <code>template</code> was under <code>selector</code>, so I moved <code>template</code> out of <code>selector</code>, so it would be under <code>spec</code>.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
 name: mongodb-deployment
 labels:
   app: mongodb
spec:
  replicas: 1
  selector:
   matchLabels:
     app: mongodb
  template:  #this and all the following lines are moved 2 places left.
    metadata:
      labels:
        app: mongodb
    spec:
      containers:
      - name: mongodb
        image: mongo
        ports:
        - containerPort: 27017
        env:
        - name: MONGO_INITDB_ROOT_USERNAME
          valueFrom:
            secretKeyRef:
              name: mongodb-secret
              key: mongo-root-username
        - name: MONGO_INITDB_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mongodb-secret
              key: mongo-root-password
</code></pre>
