UPDATE:
I think I'm not clear about the question. And after the OP's comment. I'm going to look through the redis cluster set up and similar issues.
Here are what I found
From this Github Issue When Redis does that "Redirected to slot xxx" behavior, it doesn't proxy the connection through the Redis server, but rather simply passes the IP address of the appropriate server back to the client, which then initiates
the connection directly.
From this Github Issue In a case when one of the docker containers dies, and a new container comes back up, we reattach nodes.conf from a volume to it so that It can join the currently running Redis cluster again automatically.
However, when the container comes back, it comes with a different IP address. And when we start new Redis server inside this container it does not update the IP address inside nodes.conf file for the only new generated container. But all other nodes have awareness of new IP address inside their nodes.conf. Overall, a node which went down - does not update its own IP address inside nodes.conf
So the conclusion here is we need to update the IP of the pod to the nodes.conf
file after restarting, so it can join cluster. The example can be found here by adding script to add podIP to nodes.conf
after restarting.
OLD ANSWER:
If you are exposing using LoadBalancer
service, consider using static IP so that it won't be allocated to new IP.
Here is a sample
apiVersion: v1
kind: Service
metadata:
name: redis
labels:
app: redis
spec:
selector:
app: redis
ports:
- port: 6379
targetPort: 6379
type: LoadBalancer
loadBalancerIP: "YOUR.IP.ADDRESS.HERE"
Replace YOUR.IP.ADDRESS.HERE
with a reserved internal IP (and remember that it is a regional IP).
How to reserve internal IP in GCP