Kubernetes - services without selector Kubernetes - services without selector nginx nginx

Kubernetes - services without selector


it works if you remove the "name" field from the endpoints configuration. it should look like this:

apiVersion: v1kind: Endpointsmetadata:  name: dummy-svc subsets:   - addresses:    - ip: 172.17.0.4    - ip: 172.17.0.5    - ip: 172.17.0.6    ports:    - port: 80


As @iliefa mentioned in his comment above, the below part of the definition is treated as labels in this type of cases.

ports:    - port: 80      name: http

In your scenario, we need to either remove 'name: http' as mentioned by @iliefa or we need to add 'name: http' under 'ports:' in the service definition as you can spot below.

apiVersion: v1kind: Servicemetadata:  name: dummy-svc  labels:    app: nginxspec: ports:    - protocol: TCP      port: 80      targetPort: 80      name: http