<p>Below is my Service object</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: srv1
spec:
  selector:
    name: srv1
  ports:
    protocol: TCP
    port: 80
    targetPort: 9736
</code></pre>
<p>When I am creating this object then I get below exception, do anyone knows what is wrong in this?</p>
<p><code>Error from server (BadRequest): error when creating &quot;listing62.yaml&quot;: Service in version &quot;v1&quot; cannot be handled as a Service: json: cannot unmarshal object into Go struct field ServiceSpec.spec.ports of type []v1.ServicePort</code></p>
<p>I have tried to make changes to the service object but not working.</p>

<p>This line is the problem:</p>
<p><code>    protocol: TCP</code></p>
<p>You are missing a hyphen. You need to put:</p>
<p><code>  - protocol: TCP</code></p>
<p>Basically, if there is a list for a specific field (like, containers, ports), then commonly, there is a hyphen at the start.</p>
