Kubernetes spec.ports required value error

12/23/2020

I am running minikube version v1.15.1 on Windows 10 Home.

I started minikube using VirtualBox.

Below is my yaml file

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: ClusterIP
  selector:
    component: web
  ports:
    - port: 3000
      targetPort: 3000

I am running the command kubectl apply -f filename.yaml for creating the service. Getting error The Service "my-service" is invalid: spec.ports: Required value

I referred documentation and can see that the syntax is correct. Other places i referred were

i. https://github.com/kubernetes/kubernetes/issues/8619 which is having an issue opened for the same. It is closed and requested to follow up on stackoverflow.

ii. https://stackoverflow.com/questions/57304332/the-service-php-is-invalid-spec-ports-required-value this thread didn't help me as OP had a syntax error in the file.

Any suggestions would be helpful. I just started learning Kubernetes and it's my first attempt.

-- NewBee
kubernetes

0 Answers