How to start a service and access it in minikube How to start a service and access it in minikube kubernetes kubernetes

How to start a service and access it in minikube


The problem is the missing selector field in the Service.

apiVersion: v1kind: Servicemetadata:  name: myservicespec:  type: NodePort  selector:    app: myapp  ports:  - port: 8080

Services route the traffic to the pods based on the selector defined in the service spec that match to the labels defined on the pods.

From the defining-a-service section of the docs:

The controller for the Service selector continuously scans for Podsthat match its selector, and then POSTs any updates to an Endpointobject also named "my-service".