简体   繁体   中英

Why does my kubernetes service endpoint IP change every time I update the pods?

I have a kubernetes service called staging that selects all app=jupiter pods. It exposes an HTTP service on port 1337. Here's the describe output:

$ kubectl describe service staging
Name:           staging
Namespace:      default
Labels:         run=staging
Selector:       app=jupiter
Type:           NodePort
IP:             10.11.255.80
Port:           <unnamed>   1337/TCP
NodePort:       <unnamed>   30421/TCP
Endpoints:      10.8.0.21:1337
Session Affinity:   None
No events.

But when I run a kubectl rolling-update on the RC, which removes the 1 pod running the application and adds another, and run describe again, I get:

$ kubectl describe service staging
Name:           staging
Namespace:      default
Labels:         run=staging
Selector:       app=jupiter
Type:           NodePort
IP:             10.11.255.80
Port:           <unnamed>   1337/TCP
NodePort:       <unnamed>   30421/TCP
Endpoints:      10.8.0.22:1337
Session Affinity:   None
No events.

Everything is the same, except for the Endpoint IP address. In fact, it goes up by 1 every time I do this. This is the one thing I expected not to change, since services are an abstraction over pods, so they shouldn't change when the pods change.

I know you can hardcode the endpoint address, so this is more of a curiosity.

Also, can anyone tell me what the IP field in the describe output is for?

IP is the address of your service, which remains constant over time. Endpoints is the collection of backend addresses across which requests to the service address are spread at a given point in time. That collection changes every time the set of pods comprising your service changes, as you've noticed when performing a rolling update on your replication controller (RC).

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