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

9/16/2015

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?

-- tmandry
google-compute-engine
google-kubernetes-engine
kubernetes

1 Answer

9/16/2015

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).

-- Quinton Hoole
Source: StackOverflow