@wayne.swaniawski
To expose pods in Minikube, you can use the kubectl expose
command or define a service manifest file.
1 2 3 4 5 6 7 8 9 10 11 12 |
apiVersion: v1 kind: Service metadata: name: <service-name> spec: type: NodePort selector: app: <deployment-name> ports: - protocol: TCP port: <port-number> targetPort: <target-port> |
b. Save the file as service.yaml
or any preferred name.
c. Apply the service manifest by running: kubectl apply -f service.yaml
After exposing the pods as a service, you can access them using the Minikube IP and the NodePort assigned. To obtain the IP and port, run: minikube service <service-name> --url