<p>We have a docker image and a corresponding yaml file for the deployment using kubernetes. The application we have built is in scala with akka-http. We have used akka-cluster. We have a particular variable(seed-nodes in our case - akka cluster) in the configuration file which is used in our application code that uses the pod ip. But, we will not get the pod ip unless the deployment is done. How should we go about tackling the issue? Will environment variables help, if yes how? </p>

<p>More specifically, Once the docker images is deployed in the container in a pod, and when the container starts, the pod ip is already assigned. So, can we programmatically or otherwise configure the pod ips in our code or config file before the process starts in the container?  </p>

<p>For reference, this is our configuration file : </p>

<pre><code>akka {
  actor {
    provider = "akka.cluster.ClusterActorRefProvider"
  }    
  remote {
    log-remote-lifecycle-events = off
    netty.tcp {
      hostname = "127.0.0.1"
      port = 0
    }
  }
  cluster {
    seed-nodes = [
      "akka.tcp://our-system@127.0.0.1:3000",
      "akka.tcp://our-system@127.0.0.1:3001",
    ],
    metrics {
      enabled = off
    }
  }    
}
service {
  validateTokenService {
     ml.pubkey.path = "&lt;filePath&gt;"
  }
  ml_repository {
    url = &lt;url address&gt;
  }
  replication.factor = 3
  http.service.interface = "0.0.0.0"
  http.service.port = 8080
}
</code></pre>

<p>In the above file, instead of having akka.remote.netty.tcp.hostname as "127.0.0.1", we need to have the pod-ip.
So, that we can use it in the seed nodes as : </p>

<pre><code>seed-nodes = [
          "akka.tcp://our-system@hostname:3000",
          "akka.tcp://our-system@hostname:3001",
        ],
</code></pre>

<p>How can we do so?
Thanks in advance.</p>

<p>I have tried something very similar. What you can do is use stateful sets <a href="https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/" rel="nofollow noreferrer">Kubernetes-Stateful sets</a>. Stateful sets have a naming convention and the pods will be named accordingly - you can read more about that in the link. This way, you can hard-code the values for the seed-nodes, since you know how the pods are going to be named. But, they have a drawback, stateful sets don't yet support rolling update(primarily because they are designed that way.) This article has a great explanation step by step : <a href="https://medium.com/google-cloud/clustering-akka-in-kubernetes-with-statefulset-and-deployment-459c0e05f2ea#.as2fq3qsw" rel="nofollow noreferrer">stateful set - akka clustering</a>
This article explains everything together - so posting a link instead of copying the steps here. Hope this helps</p>
