<p>I wrote small application that support clustering with Akka Cluster. I want to deploy it to Kubernetes with support scaling. This is my <code>docker-compose.yml</code> file:</p>

<pre><code>version: '3.5'

networks:
  cluster-network:

services:
  seed:
    networks:
      - cluster-network
    image: akka-cluster-server
    ports:
      - '2552:2552'
      - '8000:8000'
    environment:
      SERVER_IP: 0.0.0.0
      CLUSTER_IP: seed
      CLUSTER_SEED_IP: seed

  node1:
    networks:
      - cluster-network
    image: akka-cluster-server
    ports:
      - '8001:8000'
    environment:
      SERVER_IP: 0.0.0.0
      CLUSTER_IP: node1
      CLUSTER_PORT: 1600
      CLUSTER_SEED_IP: seed
      CLUSTER_SEED_PORT: 2552

  node2:
    networks:
      - cluster-network
    image: akka-cluster-server
    ports:
      - '8002:8000'
    environment:
      SERVER_IP: 0.0.0.0
      CLUSTER_IP: node2
      CLUSTER_PORT: 1600
      CLUSTER_SEED_IP: seed
      CLUSTER_SEED_PORT: 2552
</code></pre>

<p>There is three instances that share network among themselves. Note that <code>node1</code> and <code>node2</code> use <code>seed</code>'s DNS name to connect. I wrote simple deployment and service.</p>

<p>Deployment:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: akka-cluster
spec:
  selector:
    matchLabels:
      app: akka-cluster
  replicas: 2
  template:
    metadata:
      labels:
        app: akka-cluster
    spec:
      containers:
      - name: server-seed
        image: akka-cluster-server
        imagePullPolicy: Never
        ports:
        - containerPort: 8000
        - containerPort: 2552
        env:
        - name: SERVER_IP
          value: 0.0.0.0
        - name: CLUSTER_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: CLUSTER_SEED_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: CLUSTER_PORT
          value: "1600"
        - name: CLUSTER_SEED_PORT
          value: "2552"
</code></pre>

<p>Service:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: akka-cluster-service
spec:
  type: LoadBalancer
  selector:
    app: akka-cluster
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 8000
</code></pre>

<p>Note that in this case containers will connect to self (<code>CLUSTER_SEED_IP</code>)  instead of seed node when you will scale replicas.</p>

<p>How to correct translate my <code>docker-compose.yml</code> to Kubernetes deployment/service?</p>

Valeriy
<p>To "translate" docker-compose correctly you should create two sets of deployment +service:  one for seed and another for nodes. </p>

<p>If you need to list all the instances as seeds then probably better way would be to implement via statefulset. You can check this for example <a href="https://github.com/IBM/Akka-cluster-deploy-kubernetes/blob/master/deploy/kubernetes/resources/myapp/myapp-statefulset.json" rel="nofollow noreferrer">https://github.com/IBM/Akka-cluster-deploy-kubernetes/blob/master/deploy/kubernetes/resources/myapp/myapp-statefulset.json</a></p>
