Skip to content

Instantly share code, notes, and snippets.

@Weiyuan-Lane
Created February 3, 2019 05:17
Show Gist options
  • Save Weiyuan-Lane/bf77e9a935967814ad9c2faf23c53f9f to your computer and use it in GitHub Desktop.
Save Weiyuan-Lane/bf77e9a935967814ad9c2faf23c53f9f to your computer and use it in GitHub Desktop.
Deployment manager config example using a jinja file
{# Note that the following properties can be passed with running deployment manager #}
{# setting up deployment manager can be as simple as follows: #}
{# `gcloud deployment-manager deployments create deployment --template cluster.jinja --properties "ADD PROPERTIES FOR BELOW CONFIG HERE" ` #}
{% set CLUSTER_NAME = properties['clusterName'] %}
{% set REGION = properties['region'] %}
{% set NODE_POOL_NAME = properties['nodePoolName'] %}
{% set NODE_POOL_MIN = properties['nodePoolMinCount'] %}
{% set NODE_POOL_MAX = properties['nodePoolMaxCount'] %}
{# The following can be defined as GCP's machine type #}
{# e.g. `n1-standard-2` #}
{% set MACHINE_TYPE = properties['machineType'] %}
{% set DISK_SPACE = properties['diskSpace'] %}
resources:
- name: {{ CLUSTER_NAME }}
type: gcp-types/container-v1beta1:projects.locations.clusters
properties:
parent: projects/{{ env["project"] }}/locations/{{ REGION }}
cluster:
name: {{ CLUSTER_NAME }}
location: {{ REGION }}
nodePools:
- name: {{ NODE_POOL_NAME }}
initialNodeCount: {{ NODE_POOL_MIN }}
autoscaling:
enabled: true
minNodeCount: {{ NODE_POOL_MIN }}
maxNodeCount: {{ NODE_POOL_MAX }}
config:
machineType: {{ MACHINE_TYPE }}
diskSizeGb: {{ DISK_SPACE }}
preemptible: false
{# Declare a static IP for use to interface with services in cluster above #}
{# Declare more if you need multiple entrypoints for different services #}
- name: static-ip
type: compute.v1.globalAddress
properties:
ipVersion: IPV4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment