<p>I have a kubernetes cluster deployed with rke witch is composed of 3 nodes in 3 different servers and in those server there is 1 pod which is running yatsukino/healthereum which is a personal modification of  ethereum/client-go:stable .
The problem is that I'm not understanding how to add an external ip to send request to the pods witch are </p>

<p>My pods could be in 3 states:</p>

<ol>
<li>they syncing the ethereum blockchain</li>
<li>they restarted because of a sync problem</li>
<li>they are sync and everything is fine</li>
</ol>

<p>I don't want my load balancer to transfer requests to the 2 first states, only the third point consider my pod as up to date.</p>

<p>I've been searching in the kubernetes doc but (maybe because a miss understanding) I only find load balancing for pods inside a unique node.</p>

<p><strong>Here is my deployment file:</strong></p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: goerli
  name: goerli-deploy
spec:
  replicas: 3
  selector:
    matchLabels:
      app: goerli
  template:
    metadata:
      labels:
        app: goerli
    spec:
      containers:
        - image: yatsukino/healthereum
          name: goerli-geth
          args: ["--goerli", "--datadir", "/app", "--ipcpath", "/root/.ethereum/geth.ipc"]
          env:
          - name: LASTBLOCK
            value: "0"
          - name: FAILCOUNTER
            value: "0"
          ports:
          - containerPort: 30303
            name: geth
          - containerPort: 8545
            name: console
          livenessProbe:
            exec:
              command:
              - /bin/sh
              - /app/health.sh
            initialDelaySeconds: 20
            periodSeconds: 60
          volumeMounts:
          - name: app
            mountPath: /app
      initContainers: 
      - name: healthcheck
        image: ethereum/client-go:stable
        command: ["/bin/sh", "-c", "wget -O /app/health.sh http://my-bash-script &amp;&amp; chmod 544 /app/health.sh"]
        volumeMounts:
        - name: app
          mountPath: "/app"
      restartPolicy: Always
      volumes:
      - name: app
        hostPath:
          path: /app/

</code></pre>

<p>The answers above explains the concepts, but about your questions anout services and external ip; you must declare the service, example;</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: goerli
spec:
  selector:
    app: goerli
  ports:
  - port: 8545
  type: LoadBalancer
</code></pre>

<p>The <code>type: LoadBalancer</code> will assign an external address for in public cloud or if you use something like <a href="https://metallb.universe.tf/" rel="noreferrer">metallb</a>. Check your address with <code>kubectl get svc goerli</code>. If the external address is "pending" you have a problem...</p>

<p>If this is your own setup you can use <code>externalIPs</code> to assign your own external ip;</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: goerli
spec:
  selector:
    app: goerli
  ports:
  - port: 8545
  externalIPs:
  - 222.0.0.30
</code></pre>

<p>The <code>externalIPs</code> can be used from outside the cluster but you must route traffic to <em>any</em> node yourself, for example;</p>

<pre><code>ip route add 222.0.0.30/32 \
  nexthop via 192.168.0.1 \
  nexthop via 192.168.0.2 \
  nexthop via 192.168.0.3
</code></pre>

<p>Assuming yous k8s nodes have ip 192.168.0.x. This will setup ECMP routes to your nodes. When you make a request from outside the cluster to 222.0.0.30:8545 k8s will load-balance between your <em>ready</em> PODs.</p>
