2

我的my-app服务公开了多个端口:

/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

执行时minikube service my-app -n default --url,我得到了 minikube 转发的每个端口,但是如果不查询它们,我不知道哪个是哪个。有没有一种简单的方法来打印映射或自己设置端口转发?

/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
4

1 回答 1

3

您可以使用以下命令轻松检查 kubernetes 服务中的端口和 TargetPort 映射:

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>

这样就可以找到porttargetportendpoints映射。

于 2019-01-10T07:00:07.320 回答