简体   繁体   中英

Kubernetes: Service External IP is not working

I am deploying k8s in a private lab and using --external-ip option in the k8s service:

Name:              my-service
Namespace:         default
Labels:            <none>
Annotations:       <none>
Selector:          app=myapp
Type:              ClusterIP
IP:                10.98.4.250
External IPs:      10.10.16.21
Port:              http  80/TCP
TargetPort:        80/TCP
Endpoints:         192.168.237.3:80

Session Affinity:  None
Events:            <none>


user@k8s-master:~$ kubectl get svc
NAME         TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.96.0.1     <none>        443/TCP   22h
my-service   ClusterIP   10.98.4.250   10.10.16.21   80/TCP    7m

But I can only curl the endpoint from the same node (k8s-master) via the External IP. If I use other node (which is the same subnet as k8s-master), curl will not work.

Running tcpdump and I can see the http request is coming thru but there is no reply.

How does External IP work in service?

If you check the kubectl source code in github , you would find that external-ip is only documented in kubectl expose with the description as following:

cmd.Flags().String("external-ip", "", i18n.T("Additional external IP address (not managed by Kubernetes) to accept for the service. If this IP is routed to a node, the service can be accessed by this IP in addition to its generated service IP."))

When adding external-ip parameters to a service, Kubernete would likely to do nothing as it does not manage the behavior of this IP nor its routing inside the cluster. It just assumes that this IP would be routed to a node in the cluster. It would be treated same as the generated service IP.

To have an external IP working, configurations similar to Service type LoadBalancer or NodePort should be applied. I think it is just more of an annotation purpose.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM