<p>I have a YAML file which contains multiple resources Deployment and Service.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: petclinic
  name: petclinic
spec:
  replicas: 1
  selector:
    matchLabels:
      app: petclinic
  strategy: {}
  template:
    metadata:
      labels:
        app: petclinic
    spec:
      containers:
        - image: arey/springboot-petclinic
          name: springboot-petclinic
          resources: {}
          ports:
            - containerPort: 8080
status: {}
---
apiVersion: v1
kind: Service
metadata:
  name: petclinic
spec:
  type: LoadBalancer
  selector:
    app: petclinic
  ports:
    - port: 8080
      targetPort: 8080
      protocol: TCP
      name: http
</code></pre>
<p>I'm creating a similar file in JSON. I was able to create the deployment resource with JSON and successfully deploy, but when i attempt to include the service resource, it's failing. Any assistance on where i'm going wrong would be much appreciate. Here's the below snippet for JSON.</p>
<pre><code>{
   &quot;apiVersion&quot;: &quot;apps/v1&quot;,
   &quot;kind&quot;: &quot;Deployment&quot;,
   &quot;metadata&quot;: {
      &quot;creationTimestamp&quot;: null,
      &quot;labels&quot;: {
         &quot;app&quot;: &quot;petclinic&quot;
      },
      &quot;name&quot;: &quot;petclinic&quot;
   },
   &quot;spec&quot;: {
      &quot;replicas&quot;: 2,
      &quot;selector&quot;: {
         &quot;matchLabels&quot;: {
            &quot;app&quot;: &quot;petclinic&quot;
         }
      },
      &quot;strategy&quot;: {},
      &quot;template&quot;: {
         &quot;metadata&quot;: {
            &quot;labels&quot;: {
               &quot;app&quot;: &quot;petclinic&quot;
            }
         },
         &quot;spec&quot;: {
            &quot;containers&quot;: [
               {
                  &quot;image&quot;: &quot;arey/springboot-petclinic&quot;,
                  &quot;name&quot;: &quot;springboot-petclinic&quot;,
                  &quot;resources&quot;: {},
                  &quot;ports&quot;: [
                     {
                        &quot;containerPort&quot;: 8080
                     }
                  ]
               }
            ]
         }
      }
   },
   &quot;status&quot;: {}
}

{
   &quot;apiVersion&quot;: &quot;v1&quot;,
   &quot;kind&quot;: &quot;Service&quot;,
   &quot;metadata&quot;: {
        &quot;name&quot;: &quot;petclinic&quot;
   },
   &quot;spec&quot;: {
      &quot;type&quot;: &quot;LoadBalancer&quot;,
      &quot;selector&quot;: {
       
            &quot;app&quot;: &quot;petclinic&quot;
         
      },
        
            &quot;ports&quot;: [
               {
                  &quot;port&quot;: 8080,
                  &quot;targetPort&quot;: 8080,
                  &quot;protocol&quot;: &quot;TCP&quot;,
                  &quot;name&quot;: &quot;http&quot;                   
                  ]
             }     
   }    
}
</code></pre>

Coolbreeze
<p>There is a syntax error in your Service resource (array closing bracket in <code>ports</code>). It should be:</p>
<pre><code>{
  &quot;apiVersion&quot;: &quot;v1&quot;,
  &quot;kind&quot;: &quot;Service&quot;,
  &quot;metadata&quot;: {
    &quot;name&quot;: &quot;petclinic&quot;
  },
  &quot;spec&quot;: {
    &quot;type&quot;: &quot;LoadBalancer&quot;,
    &quot;selector&quot;: {
      &quot;app&quot;: &quot;petclinic&quot;
    },
    &quot;ports&quot;: [
      {
        &quot;port&quot;: 8080,
        &quot;targetPort&quot;: 8080,
        &quot;protocol&quot;: &quot;TCP&quot;,
        &quot;name&quot;: &quot;http&quot;
      }
    ]
  }
}
</code></pre>
<p>To make the file a valid JSON file, you can wrap the definitions in the <code>List</code> resource:</p>
<pre><code>{
  &quot;apiVersion&quot;: &quot;v1&quot;,
  &quot;kind&quot;: &quot;List&quot;,
  &quot;items&quot;: [
    {
      &quot;apiVersion&quot;: &quot;v1&quot;,
      &quot;kind&quot;: &quot;Deployment&quot;,
      ...
    },
    {
      &quot;apiVersion&quot;: &quot;v1&quot;,
      &quot;kind&quot;: &quot;Service&quot;,
      ...
    }
  ]
}
</code></pre>
