Do Kubernetes service IPs change?
<p>I'm very new to kubernetes/docker, so apologies if this is a silly question.</p>
<p>I have a pod that is accessing a few services. In my container I'm running a python script and need to access the service. Currently I'm doing this using the services' IP addresses.</p>
<p>Is the service IP address stable or is it better to use <a href="http://kubernetes.io/docs/user-guide/services/#environment-variables" rel="noreferrer">environment variables</a>? If so, some tips on doing that would be great.</p>
<p>The opening paragraph of the <a href="http://kubernetes.io/docs/user-guide/services/" rel="noreferrer">Services Documentation</a> gives a motivation for services which implies stable IP addresses, but I never see it explicitly stated:</p>
<blockquote>
<p>While each Pod gets its own IP address, <strong>even those IP addresses cannot be relied upon to be stable over time</strong>. This leads to a problem: if some set of Pods (let’s call them backends) provides functionality to other Pods (let’s call them frontends) inside the Kubernetes cluster, how do those frontends find out and keep track of which backends are in that set?</p>
<p>Enter Services.</p>
</blockquote>
<p>My pod spec for reference:</p>
<pre><code>kind: Pod
apiVersion: v1
metadata:
  name: fetchdataiso 
  labels:
    name: fetchdataiso
spec:
  containers:
    - name: fetchdataiso 
      image: 192.111.1.11:5000/ncllc/fetch_data
      command: [&quot;python&quot;]
      args: [&quot;feed/fetch_data.py&quot;, &quot;-hf&quot;, &quot;10.222.222.51&quot;, &quot;-pf&quot;, &quot;8880&quot;, &quot;-hi&quot;, &quot;10.223.222.173&quot;, &quot;-pi&quot;,&quot;9101&quot;]
</code></pre>