The Service "php" is invalid: spec.ports: Required value

8/1/2019

I was following this tutorial https://www.cloudbooklet.com/kubernetes-basic-php-application-with-nginx-on-google-cloud/ and when I got to this command kubectl apply -f php_service.yaml --validate=false this error popped up:

The Service "php" is invalid: spec.ports: Required value.

How do I fix this? This is the yaml file:

    apiVersion: v1
    kind: Service
    metadata:
      name: php
      labels:
        tier: backend
    spec:
      selector:
        app: php
        tier: backend
      ports:
    protocol: TCP
    port: 9000
-- marwa karaki
google-kubernetes-engine
php
service
yaml

1 Answer

8/2/2019

Your syntax is wrong. Protocol and port should be items from the spec.ports field. It should look something like this

-- Patrick W
Source: StackOverflow