Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unmarshalling exception while creating a Service object

Below is my Service object

apiVersion: v1
kind: Service
metadata:
  name: srv1
spec:
  selector:
    name: srv1
  ports:
    protocol: TCP
    port: 80
    targetPort: 9736

When I am creating this object then I get below exception, do anyone knows what is wrong in this?

Error from server (BadRequest): error when creating "listing62.yaml": Service in version "v1" cannot be handled as a Service: json: cannot unmarshal object into Go struct field ServiceSpec.spec.ports of type []v1.ServicePort

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have tried to make changes to the service object but not working.

>Solution :

This line is the problem:

protocol: TCP

You are missing a hyphen. You need to put:

- protocol: TCP

Basically, if there is a list for a specific field (like, containers, ports), then commonly, there is a hyphen at the start.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading