<p>currently kubectl assigns the IP address to a pod and that is shared within the pod by all the containers. </p>

<p>I am trying to assign a static IP address to a pod i.e in the same network range as the one assigned by kubectl,  I am using the following deployment file </p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: redis
spec:
  replicas: 1
  template:
    metadata:
      labels:
        run: rediscont
    spec:
      containers:
      - name: redisbase
        image: localhost:5000/demo/redis
        ports:
        - containerPort: 6379
          hostIP: 172.17.0.1
          hostPort: 6379
</code></pre>

<p>On the dockerhost where its deployed i see the following:</p>

<pre><code>CONTAINER ID        IMAGE                                COMMAND                  CREATED             STATUS              PORTS                       NAMES
4106d81a2310        localhost:5000/demo/redis            "/bin/bash -c '/root/"   28 seconds ago      Up 27 seconds                                   k8s_redisbase.801f07f1_redis-1139130139-jotvn_default_f1776984-d6fc-11e6-807d-645106058993_1b598062
71b03cf0bb7a        gcr.io/google_containers/pause:2.0   "/pause"                 28 seconds ago      Up 28 seconds       172.17.0.1:6379-&gt;6379/tcp   k8s_POD.99e70374_redis-1139130139-jotvn_default_f1776984-d6fc-11e6-807d-645106058993_8c381981
</code></pre>

<p><strong>The IP tables-save gives the following output</strong></p>

<pre><code>-A DOCKER -d 172.17.0.1/32 ! -i docker0 -p tcp -m tcp --dport 6379 -j DNAT --to-destination 172.17.0.3:6379
</code></pre>

<p>Even with this, from other pods the IP 172.17.0.1 is not accessible. 
Basically the question is how to assign static IP to a pod so that 172.17.0.3 doesn't get assigned to it </p>

<p>Generally, assigning a Pod a static IP address is an anti-pattern in Kubernetes environments. There are a couple of approaches you may want to explore instead. Using a Service to front-end your Pods (or to front-end even just a single Pod) will give you a stable network identity, and allow you to horizontally scale your workload (if the workload supports it). Alternately, using a StatefulSet may be more appropriate for some workloads, as it will preserve startup order, host name, PersistentVolumes, etc., across Pod restarts.</p>

<p>I know this doesn't necessarily <em>directly</em> answer your question, but hopefully it provides some additional options or information that proves useful.</p>
