Created
November 6, 2019 21:22
-
-
Save ricardochaves/438735c776a19275ba3571aa3b3704ab to your computer and use it in GitHub Desktop.
Recipe for Google Deployment Manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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