{"id":26499697,"url":"https://github.com/cockroachlabs-field/google-cloud-run","last_synced_at":"2026-04-11T16:44:45.063Z","repository":{"id":117484075,"uuid":"303881612","full_name":"cockroachlabs-field/google-cloud-run","owner":"cockroachlabs-field","description":"Google Cloud Run with a Serverless VPC Connector for CockroachCloud","archived":false,"fork":false,"pushed_at":"2020-10-16T01:55:39.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-30T21:43:39.333Z","etag":null,"topics":["cockroachdb","google-cloud-run","serverless","vpc-peering"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cockroachlabs-field.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-10-14T02:29:46.000Z","updated_at":"2021-12-07T14:28:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"1c6f589f-e06c-4535-9b74-ef99f19c9e3e","html_url":"https://github.com/cockroachlabs-field/google-cloud-run","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cockroachlabs-field/google-cloud-run","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cockroachlabs-field%2Fgoogle-cloud-run","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cockroachlabs-field%2Fgoogle-cloud-run/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cockroachlabs-field%2Fgoogle-cloud-run/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cockroachlabs-field%2Fgoogle-cloud-run/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cockroachlabs-field","download_url":"https://codeload.github.com/cockroachlabs-field/google-cloud-run/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cockroachlabs-field%2Fgoogle-cloud-run/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31687881,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T13:07:20.380Z","status":"ssl_error","status_checked_at":"2026-04-11T13:06:47.903Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cockroachdb","google-cloud-run","serverless","vpc-peering"],"created_at":"2025-03-20T15:18:47.621Z","updated_at":"2026-04-11T16:44:45.055Z","avatar_url":"https://github.com/cockroachlabs-field.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Cloud Run using a Serverless VPC Connector for CockroachCloud\n\n## High Level Steps\n\n1) Create You're Own VPC in GCloud\n2) Create CockroachCloud cluster\n    - Create a SQL user\n    - Create a VPC Peering between CockroachCloud and your new VPC in step 1\n3) Create VPC Serverless Connector\n4) Deploy a container in Google Cloud Run\n\n## Step 1 - Create A New VPC for your Google Run app\n\nIn Google cloud, create a new VPC\n\n_Console --\u003e VPC Networks_\n\n- Name = chrisc-vpc \n- Use a Custom subnet\n- CIDR Range: 10.0.0.0/28 =\u003e 16 IPs\n- Dynamic Routing = Regional\n- DNS Server Policy = None\n- Private Google Access = Off (we should try with on)\n- Click Create\n- Record your Project Id and the name of the new VPC\n\n\n**NOTE: Keep track of your CIDR range to know your range of IPs**\n\n## Step 2 - Create a CockroachCloud Cluster\n\nCreate a CockroachCloud cluster\n\nAdd a new SQL User\n\nAdd a VPC Peering connection (need Project Id and name of VPC network created in Step 1)\n\nVerify VPC Connection in your new VPC.  The verification command should look something like this and is generated from the CockroachCloud VPC Peering \"Connect\" button:\n\n```\ngcloud --project cockroach-chrisc compute networks peerings create chrisc-cc-gcp --network=chrisc-vpc --peer-network=crdb --peer-project=crl-prod-5th --auto-create-routes\n```\n\nAlso get the Connect URL for the database and the required cert.\n\nPlace the cert in a /certs folder in this directory.\n\n```\nmkdir certs\n```\n\n\n## Step 3 -  Create VPC Servlerless Connector\n\nIn Google console, go toS \"Console\" -\u003e \"Serverless VPC Access\"\n\n**Very important: When creating make sure that the CIDR range for the connector doesn't overlap with the VPC.  If you're not sure of your CIDR range, you can figure it using a CIDR calculator: https://www.ipaddressguide.com/cidr**\n\n- Click \"Create Connector\"\n- Give the connector a name: \"cc-connector\"\n- Create in same region as created VPC\n  - Region = us-east4\n  - Network = chrisc-vpc (the name from Step 1)\n- Click Create\n- Validate the connector creates successfully\n- Choose the Route all traffic option. (Should we try this Private IP setup?)\n\n## Step 4 - Run Google Run\n\n### Local Testing with Docker (Optional)\n\nInstead of using the VPC Peering connection string, us a public IP instead.  To do this, you can create a whitelisted IP in CockroachCloud for your local machine.\n\n```\ndocker build -t chriscasano/gcr:latest .\nexport COCKROACH_URI=\"postgres://chris:\u003cpassword\u003e@clerk-test-5th.gcp-us-east4.cockroachlabs.cloud:26257/defaultdb?sslmode=require\u0026sslrootcert=/app/certs/clerk-test-ca.crt\"\ndocker run -p 8080:8080 --env COCKROACH_URI chriscasano/gcr\n```\n\n## Google Build \n\nDocs: https://cloud.google.com/run/docs/quickstarts/build-and-deploy?_ga=2.147364543.-903456326.1570542011\n\nAdd the container to the registry\n```\ngcloud builds submit --tag gcr.io/cockroach-chrisc/cctest\n```\n\n~~gcloud run deploy --image gcr.io/cockroach-chrisc/cctest --platform managed~~\n\n~~Choose the region, service name and Y for allow unauthenticated invocations~~\n\nGo to Cloud Run (GCP Console --\u003e \"Cloud Run\") \n\nClick Create Service\n\nService Settings:\n- Fully Managed, Region = us-east4\n- Service name = cctest\n- Allow unauthenticated invocations\n\nService Revisions:\n- Choose your latest image\n- In Advanced Settings -\u003e Variables -\u003e Add Variables\n  - ```COCKROACH_URI = postgres://chris:\u003cpassword\u003e@clerk-test-5th.gcp-us-east4.cockroachlabs.cloud:26257/defaultdb?sslmode=require\u0026sslrootcert=/app/certs/clerk-test-ca.crt```\n- In Advanced Settings -\u003e Connections -\u003e VPC Connector\n  - VPC Connector = Choose Custom\n  - Select your serverless vpc connector = \"cc-connector\"\n  - Select \"Route All Traffic Through VPC Connector\"\n\nDeploy the container in Google Cloud Run\n\nOnce deployed, check the logs of the running container.  If you see this...\n\n```\n2020-10-16T01:40:12.832159Z  Connecting to database...\n2020-10-16T01:40:13.011622Z  DB Connection Success\n2020-10-16T01:40:13.014043Z  SQL Executed!\n```\n\nThen you can get the....\n# Champagne!\n\n\n\n#### Container debugging tools\n```\napt-get update\napt-get install net-tools\napt-get install iputils-ping\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcockroachlabs-field%2Fgoogle-cloud-run","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcockroachlabs-field%2Fgoogle-cloud-run","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcockroachlabs-field%2Fgoogle-cloud-run/lists"}