0
votes

I have been trying to figure this out for a few hours. I cant see what is causing this issue. It appears to be something with line 10 of the YAML. I have tried with and without quotes and starting a new file in case there was some corrupt values.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: "foyer-api"
  namespace: "foyer-api"
spec:
   replicas: 3
   selector:
     matchLabels:
       app: "foyer-api"
    template:
      metadata:
        labels:
          app: "foyer-api"
      spec:
        containers:
        - image: foyer-api
         imagePullPolicy: Always
          name: "foyer-api"
          ports:
          - containerPort: 80
2
It looks like the identation is a bit off? since metadata and spec is on the same level, their children should also be at the same indentation :) - Martin Lund
I have updated the indentation and still getting the same error on line 10. Which is the line after the matchLabels command. - Michael McDermott

2 Answers

1
votes

This error occurs mostly when copy-and-pasting into a yaml which might cause syntax error.

Consider pasting the yaml in YAML Linters (for example this one) that in some cases help to identify the problem more quickly.

0
votes

After I correct the indentation,

apiVersion: apps/v1
kind: Deployment
metadata:
  name: "foyer-api"
  namespace: "foyer-api"
spec:
  replicas: 3
  selector:
    matchLabels:
      app: "foyer-api"
    template:
      metadata:
        labels:
          app: "foyer-api"
      spec:
        containers:
        - image: foyer-api
          imagePullPolicy: Always
          name: "foyer-api"
          ports:
          - containerPort: 80

it can be converted to JSON with no problem

{
  "apiVersion": "apps/v1",
  "kind": "Deployment",
  "metadata": {
    "name": "foyer-api",
    "namespace": "foyer-api"
  },
  "spec": {
    "replicas": 3,
    "selector": {
      "matchLabels": {
        "app": "foyer-api"
      },
      "template": {
        "metadata": {
          "labels": {
            "app": "foyer-api"
          }
        },
        "spec": {
          "containers": [
            {
              "image": "foyer-api",
              "imagePullPolicy": "Always",
              "name": "foyer-api",
              "ports": [
                {
                  "containerPort": 80
                }
              ]
            }
          ]
        }
      }
    }
  }
}