<p>Hello folks I'm trying to deploy a nodejs application that runs mongoDB in Kubernetes. In order to accomplish this, I've created a folder named <strong>k8s</strong> and in that folder I have 2 files - <strong>deployment_nodejs.yaml</strong> and <strong>deployment_mongo.yaml</strong>. After run the command <strong>kubectl apply -f k8s</strong>.
I successfully create the 'deployment_nodejs.yaml' but I <strong>failed</strong> deploying the other one. The error says the following: 'error: error parsing k8s/deployment_mongo.yaml: error converting YAML to JSON: yaml: line 20: did not find expected '-' indicator'.
I realized that the error might be the <strong>ports</strong> command although I can't understand why because in my opinion I've done anything wrong. Hope you could help me fixing this bug.</p>
<p>Code of <strong>deployment_mongo.yaml</strong> file:</p>
<pre><code>kind: PersistentVolumeClaim
metadata:
  name: mongo-pvc 
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 256Mi

---
apiVersion: v1
kind: Service
metadata:
  name: mongo
spec:
  selector:
    app: mongo
  ports:
  - port: 27017
    targetPort: 27017
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongo
spec: 
  selector: 
    matchLabels: 
      app: mongo
  template:
    metadata:
      labels:
        app: mongo
    specs:
      containers:
        - name: mongo
          image: 3.6.23-xenial
          ports:
            - containerPort: 27017
          volumeMounts: 
            - name: storage
            mountPath: /data/db
      volumes:
        - name: storage
        PersistentVolumeClaim:
          claimName: mongo-pvc 
</code></pre>

Lucas Seabra
<p>Tried generating the resources as per the YAML given, below are the issues found.
api-version is not mentioned on the first line, volumes and volumeMounts are not properly indented in Deployment Yaml. PersistentVolumeClaim (P in caps it should be persistentVolumeClaim), claimName is not indented. Fix them or use the below manifest and you should be good to go.</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mongo-pvc 
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 256Mi

---
apiVersion: v1
kind: Service
metadata:
  name: mongo
spec:
  selector:
    app: mongo
  ports:
  - port: 27017
    targetPort: 27017
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongo
spec: 
  selector: 
    matchLabels: 
      app: mongo
  template:
    metadata:
      labels:
        app: mongo
    spec:
      containers:
        - name: mongo
          image: 3.6.23-xenial
          ports:
            - containerPort: 27017
          volumeMounts: 
            - name: storage
              mountPath: /data/db
      volumes:
        - name: storage
          persistentVolumeClaim:
            claimName: mongo-pvc 

</code></pre>
