gke - redis - connection timeout

9/3/2019

My node js application is throwing a connection timeout in order to connect with Redis instance. I have tried to spin up redis instance as a separate deployment as well as memory store redis instance as well. As a deployment in a pod, I use normal nodeport and tried to access this instance using cluster ip. The ip was in the Config Map.

I tried to ping the ip of memory store as well as cluster ip of redis deployment on gke, from the pod of the node js application, but it did not connect.

As deployment of redis instance also got internal ip: 10.0.231.4

Nothing worked

Memory Store :

gcloud redis instances describe my-redis --region=us-central1

Response:
authorizedNetwork: projects/xxxxx/global/networks/xxxxx
createTime: '2019-09-03T13:39:36.050896298Z'
currentLocationId: us-central1-a
host: 10.0.48.3
locationId: us-central1-a
memorySizeGb: 2
name: projects/xxxxx/locations/us-central1/instances/transact-redis
persistenceIamIdentity: serviceAccount:xxxxxxxxxxx-compute@developer.gserviceaccount.com
port: 6379
redisVersion: REDIS_4_0
reservedIpRange: 10.0.48.0/29
state: READY
tier: BASIC

From cloud shell also, I tried to telnet to 10.0.48.3 on 6379 port. It failed as well.

Here is the log:

2019-09-04 17:20:01.164 CEST at Socket.emit (events.js:209:13)
2019-09-04 17:20:01.164 CEST at emitErrorNT (internal/streams/destroy.js:91:8)
2019-09-04 17:20:01.164 CEST at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
2019-09-04 17:20:01.164 CEST at processTicksAndRejections (internal/process/task_queues.js:77:11) {
2019-09-04 17:20:01.164 CEST errno: 'ETIMEDOUT',
2019-09-04 17:20:01.164 CEST code: 'ETIMEDOUT',
2019-09-04 17:20:01.164 CEST syscall: 'connect',
2019-09-04 17:20:01.164 CEST address: '10.0.48.3',
2019-09-04 17:20:01.164 CEST port: 6379
2019-09-04 17:20:01.164 CEST}
2019-09-04 17:20:06.565 CESTContainer called exit(1).

Any idea how to make it work? Thanks in advance.

-- ARINDAM BANERJEE
google-cloud-memorystore
google-kubernetes-engine
node.js
redis

1 Answer

9/9/2019

Remember that you can connect to your Redis instance from Google Kubernetes Engine clusters that are in the same region and use the same network as your instance.

By the same token, you cannot connect to a Cloud Memorystore for Redis instance from a Google Kubernetes Engine cluster without VPC-native/IP aliasing enabled.

My hypothesis would be that you may either have the cluster on a different zone, not configured your VPC for internal connections, or are on different VPCs. Have you tried this setup to connect Redis to a GKE instance?

Keep me posted on any progress!

-- sllopis
Source: StackOverflow