'Kubernetes proxy to Google Cloud MemoryStore-Redis

I would like to make Google Cloud MemoryStore-Redis accessible from localhost even without any setup to my local PC (I know it's a security hole but I need a simple setup for everyone from my team ASAP).

My current approach is to use standard .net library and call redis like this:

            ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(
                        new ConfigurationOptions
                        {
                            EndPoints = { ip }
                        });

            var db = redis.GetDatabase();

Because I'm currently hosting everything in GKE, I set up my Gateway/VirtualService/ServiceEntry like this:


apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: default-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - '*'
    port:
      name: http
      number: 80
      protocol: HTTP
  - hosts:
    - '*'
    port:
      name: redis
      number: 6379
      protocol: TCP      


---


apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: proxy-redis
spec:
  gateways:
  - default-gateway
  hosts:
  - "*"
  tcp:
  - match:
    - port: 6379
    route:
    - destination:
        host: redis-expose-service


---


apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: redis-expose-service
spec:
  hosts:
  - redis-expose-service
  ports:
  - name: tcp
    number: 6379
    protocol: TCP
  location: MESH_EXTERNAL
  resolution: STATIC
  endpoints:
    - address: X.X.X.X # address provided by gcloud
      ports:
        tcp: 6379      
    
  
---


apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: redis-expose-service 
spec:
  host: redis-expose-service  

Connecting from GatewayPublicIP:6379 works fine from the Kubernetes cluster but not from my local machine (Exception: StackExchange.Redis.RedisConnectionException: It was not possible to connect to the Redis server(s). Error connecting right now.). Any help would be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source