无法通过Deployment Manager创建postgres cloudsql吗?

时间:2018-12-08 08:43:05

标签: google-cloud-platform google-cloud-sql google-deployment-manager

我已经签到supported-gcp-typessupported-resource-types,但我完全看不到任何可能性

2 个答案:

答案 0 :(得分:2)

Deployment Manager支持PostgreSQL。

您需要将backendType指定为SECOND_GEN,将databaseVersion指定为POSTGRES_9_6,将tier指定为db-custom-1-3840

Documentation

示例(create-postgresql-instance.jinja):

{% set deployment_name = env['deployment']  %}
{% set instance_name = deployment_name + '-instance'  %}
{% set database_name = deployment_name + '-db'  %}
{% set region = 'us-central1'  %}
{% set tier = 'db-custom-1-3840'  %}

resources:
- name: {{ instance_name }}
  type: gcp-types/sqladmin-v1beta4:instances
  properties:
    region: {{ region }}
    backendType: SECOND_GEN
    databaseVersion: POSTGRES_9_6
    settings:
      tier: {{ tier }}
      backupConfiguration:
        enabled: true

- name: {{ database_name }}
  type: gcp-types/sqladmin-v1beta4:databases
  properties:
    name: {{ database_name }}
    instance: $(ref.{{ instance_name }}.name)
    charset: utf8

部署:

gcloud deployment-manager deployments create mydb --template create-postgresql-instance.jinja

答案 1 :(得分:1)

PostgresSQL的部署管理器Jinja模板

{% set deployment_name = env['deployment']  %}
{% set instance_name = deployment_name + '-instance'  %}
{% set database_name = deployment_name + '-db'  %}
{% set region = 'us-central1'  %}
{% set tier = 'db-n1-standard-1'  %}
{% set databaseVersion = 'POSTGRES_11' %}
resources:
- name: {{ instance_name }}
  type: gcp-types/sqladmin-v1beta4:instances
  properties:
      region: us-central1
      databaseVersion: POSTGRES_9_6
      instanceType: CLOUD_SQL_INSTANCE
      settings:
        tier: db-f1-micro
        backupConfiguration:
          startTime: '02:00'
          enabled: true
        locationPreference:
          zone: us-central1-c

- name: {{ database_name }}
  type: gcp-types/sqladmin-v1beta4:databases
  properties:
    name: {{ database_name }}
    databaseVersion: POSTGRES_12
    instance: $(ref.{{ instance_name }}.name)
    charset: utf8