minikube service --url when service exposes multiple ports

1/9/2019

My my-app service exposes multiple ports:

/Mugen$ kubectl get endpoints
NAME           ENDPOINTS                                                   AGE
my-app         172.17.0.7:80,172.17.0.7:8003,172.17.0.7:8001 + 3 more...   7m
kubernetes     192.168.99.100:8443                                         10h
mysql-server   172.17.0.5:3306                                             10h

When executing minikube service my-app -n default --url, I'm getting each port forwarded by minikube, however I can't tell which is which without querying them. Is there a simple way to print the mapping or to set the port forwarding myself?

/Mugen$ minikube service my-app -n default --url
http://192.168.99.100:30426
http://192.168.99.100:30467
http://192.168.99.100:31922
http://192.168.99.100:32008
http://192.168.99.100:30895
http://192.168.99.100:31602
-- Mugen
kubectl
kubernetes-service
minikube
portforwarding

1 Answer

1/10/2019

You can easily check the port and TargetPort mapping in kubernetes service using:

kubectl descrive svc my-app
Name:                     my-app
Namespace:                default
Labels:                   <none>
Annotations:              <none>
Selector:                 app=MyApp
Type:                     NodePort
IP:                       10.152.183.56
Port:                     http  80/TCP
TargetPort:               9376/TCP
NodePort:                 http  30696/TCP
Endpoints:                <none>
Port:                     https  443/TCP
TargetPort:               9377/TCP
NodePort:                 https  32715/TCP
Endpoints:                <none>
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

This way you can find port, targetport and endpoints mapping.

-- Prafull Ladha
Source: StackOverflow