Coder Social home page Coder Social logo

cloudrun-cloudsql-integration-java-app's Introduction

Create a CloudSql instance

 gcloud sql instances create cloudrun-db-instance \
--database-version=MYSQL_8_0 \
--cpu=1 \
--memory=4GB \
--region=us-central1 \
--authorized-networks 0.0.0.0/0 \
--root-password=Gcp@2022

Create a database

gcloud sql databases create compare_db --instance=cloudrun-db-instance

Run the gcloud sql users create command to create the user.

gcloud sql users create cloud-user \
--instance=cloudrun-db-instance \
--password=Gcp@2022

(Optional) Configure a Cloud Run service account

gcloud iam service-accounts list

gcloud projects add-iam-policy-binding testingiamproject-369302 \
  --member="serviceAccount:SERVICE_ACCOUNT_EMAIL" \
  --role="roles/cloudsql.client"

Configure a Cloud SQL sample app

mvn clean package com.google.cloud.tools:jib-maven-plugin:2.8.0:build \
 -Dimage=gcr.io/testingiamproject-369302/cloudsqlrun:v1 -DskipTests

CLoud run Deploy

gcloud run deploy run-sql --image gcr.io/testingiamproject-369302/cloudsqlrun:v1 \
  --region us-central1 \
  --allow-unauthenticated \
  --add-cloudsql-instances testingiamproject-369302:us-central1:cloudrun-db-instance \
  --set-env-vars INSTANCE_UNIX_SOCKET="/cloudsql/testingiamproject-369302:us-central1:cloudrun-db-instance" \
  --set-env-vars INSTANCE_CONNECTION_NAME="testingiamproject-369302:us-central1:cloudrun-db-instance" \
  --set-env-vars DB_NAME="compare_db" \
  --set-env-vars DB_USER="cloud-user" \
  --set-env-vars DB_PASS="Gcp@2022"

Note

Make sure to create VPC connector in the same n/w where ur cloud sql instance is created

cloudrun-cloudsql-integration-java-app's People

Contributors

devopswithcloud avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.