Skip to content

Instantly share code, notes, and snippets.

@ricardochaves
Created November 6, 2019 21:22
Show Gist options
  • Save ricardochaves/438735c776a19275ba3571aa3b3704ab to your computer and use it in GitHub Desktop.
Save ricardochaves/438735c776a19275ba3571aa3b3704ab to your computer and use it in GitHub Desktop.
Recipe for Google Deployment Manager
def GenerateConfig(context):
"""Generate YAML resource configuration."""
cluster_name = context.properties["CLUSTER_NAME"]
cluster_zone = context.properties["CLUSTER_ZONE"]
number_of_nodes = context.properties["NUM_NODES"]
resources = []
resources.append(
{
"name": cluster_name,
"type": "container.v1.cluster",
"properties": {
"zone": cluster_zone,
"cluster": {
"name": cluster_name,
"initialNodeCount": number_of_nodes,
"nodeConfig": {
"oauthScopes": [
"https://www.googleapis.com/auth/" + scope
for scope in ["compute", "devstorage.read_only", "logging.write", "monitoring"]
],
"machineType": "g1-small",
"imageType": "COS",
"diskType": "pd-standard",
"diskSizeGb": 10,
"metadata": {"disable-legacy-endpoints": "false"},
"preemptible": True,
},
"initialClusterVersion": "1.14.6-gke.2",
"network": "projects/my-project-dev/global/networks/default",
"subnetwork": "projects/my-project-dev/regions/us-central1/subnetworks/default",
"defaultMaxPodsConstraint": {"maxPodsPerNode": "110"},
"ipAllocationPolicy": {"useIpAliases": True},
},
},
}
)
outputs = []
outputs.append({"name": "endpoint", "value": "$(ref." + cluster_name + ".endpoint)"})
return {"resources": resources, "outputs": outputs}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment