Accessing GCP Memorystore from local machines

前端 未结 4 1031
一整个雨季
一整个雨季 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 07:59

    I created a vm on google cloud

    gcloud compute instances create redis-forwarder --machine-type=f1-micro
    

    then ssh into it and installed haproxy

    sudo su
    apt-get install haproxy
    

    then updated the config file

    /etc/haproxy/haproxy.cfg
    
    ....existing file contents
    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 [MEMORYSTORE IP]:6379 check
    

    restart haproxy

    /etc/init.d/haproxy restart
    

    I was then able to connect to memory store from my local machine for development

提交回复
热议问题