The final piece of the puzzle is to define a k8s service:
apiVersion: v1
kind: Service
metadata:
name: comments-api
spec:
type: NodePort
selector:
name: comments-api
ports:
- protocol: TCP
port: 8080
targetPort: 8080
With this in place, we can now apply this service using the following command:
kubectl apply -f config/service.yml
We can then set up port-forwarding on our local machine to map localhost:8080
through to the kubernetes service running on port 8080:
kubectl port-forward service/comments-api 8080:8080