简体   繁体   中英

cloudbuild.yaml create a sql instance

Hi I am new to the GCP world and am creating my first cloudbuild.yaml file.

I haven't found an example of how to create a cloud sql instance(Postgres or MySQL), is this not supported?

it's not listed in thecloud-builders-community on GitHub .

Anything to point me in the right direction would be a big help.

I have this below and don't know if it is the correct or best way to do this:

        # # steps:
    # # # Create Cloud SQL Instance
    # # - name: gcr.io/cloud-builders/gcloud
    # #   id: 'create_cloud_sql_instance'
    # #   entrypoint: "bash"
    # #   args: 
    # #     - '-c' # pass what follows as a command to bash
    # #     - |
    # #       gcloud sql instances create $_INSTANCE_NAME --database-version=POSTGRES_11 \
    # #        --cpu=$_NUMBER_CPUS --memory=$_MEMORY_SIZE \
    # #        --region=[$_REGION] 
    # #   waitFor: ["-"]

Thanks in advance.

You are on the right track, but you don't need to change the entrypoint to be bash and then execute the gcloud command, as the gcr.io/cloud-builders/gcloud image already has gcloud as the entrypoint.

Doing this works:

steps:
- name: 'gcr.io/cloud-builders/gcloud'
  args: ["sql", "instances", "create", "$_INSTANCE_NAME", "--database-version=POSTGRES_11", "--region=$_REGION"]

Also you don't need the waitFor tag for the step either, if you are not concerned about concurrent/consecutive build steps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM