Accessing GCP Memorystore from local machines

前端 未结 4 1024
一整个雨季
一整个雨季 2020-12-08 07:34

Whats the best way to access Memorystore from Local Machines during development? Is there something like Cloud SQL Proxy that I can use to set up a tunnel?

4条回答
  •  有刺的猬
    2020-12-08 08:12

    You can spin up a Compute Engine instance and setup an haproxy using the following docker image haproxy docker image then haproxy will forward your tcp requests to memorystore.

    For example i want to access memorystore instance with ip 10.0.0.12 so added the following haproxy configs:

    frontend redis_frontend
       bind *:6379
       mode tcp
       option tcplog
       timeout client  1m
       default_backend redis_backend
    
    backend redis_backend
       mode tcp
       option tcplog
       option log-health-checks
       option redispatch
       log global
       balance roundrobin
       timeout connect 10s
       timeout server 1m
       server redis_server 10.0.0.12:6379 check
    

    So now you can access memorystore from your local machine using the following command:

    redis-cli -h  -p 6379
    

    Note: replace with you actual haproxy ip address.

    Hope that can help you to solve your problem.

提交回复
热议问题