chimame / connection-memorystore-rails-from-cloudrun

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

README

This is a Rails application with Cloud Memorystore connection settings from Cloud Run managed.

Deploy

From building a container image to deploying it to Cloud Run, you can do the following.

Container build

The first step is to install the beta command, as of May 17, 2020, the connection option from Cloud Run to Cloud Memorystore is for beta.

$ gcloud components install --quiet beta

Next, we will enable the build of this Rails container image to use Kaniko.

$ gcloud config set builds/use_kaniko True

Finally, to build the container image, execute the command of Cloud Build, because the configuration of Cloud Build needs the specific configuration of cloudbuild.yml.

$ gcloud builds submit --project <Google Cloud Platform Project ID> --config ./cloudbuild.yml

Deploy to Cloud Run

You can connect to Cloud Memorystore from Cloud Run by running the command to deploy to Cloud Run. The important option for this command is to specify -vpc-connector, which is the serverless VPC access connector created from Cloud Run. By specifying this, you can connect to a Cloud Memorystore instance set to REDIS_HOST.

$ gcloud beta run deploy <your cloud run service name> \
  --image gcr.io/<Google Cloud Platform Project ID>/<Container Image Name>:latest \
  --vpc-connector <your serverless vpc access connector name> \
  --platform managed \
  --region asia-northeast1 \
  --allow-unauthenticated \
  --set-env-vars RAILS_ENV=production \
  --set-env-vars RAILS_MASTER_KEY=<your Rails master key> \
  --set-env-vars REDIS_HOST=<your Cloud Memorystore instance host ip> \
  --set-env-vars REDIS_PORT=6379

About


Languages

Language:Ruby 77.3%Language:HTML 15.4%Language:JavaScript 3.6%Language:CSS 2.0%Language:Dockerfile 1.1%Language:Shell 0.6%