Forked from DazWilkin/kubernetes_engine_regional_cluster.py
Created
May 14, 2021 07:09
-
-
Save udoyen/d9f98c447f713f1e5671f07747bac8b6 to your computer and use it in GitHub Desktop.
Cloud Deployment Manager & Kubernetes
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_region = context.properties['CLUSTER_ZONE'] | |
number_of_nodes = context.properties['NUM_NODES'] | |
resources = [] | |
outputs = [] | |
resources.append({ | |
'name': cluster_name, | |
'type': 'gcp-types/container-v1beta1:projects.locations.clusters', | |
'properties': { | |
'parent': 'projects/{}/locations/{}'.format(context.env['project'], cluster_region), | |
'cluster': { | |
'name': cluster_name, | |
'nodePools': [{ | |
'name': 'core', | |
'initialNodeCount': number_of_nodes, | |
'config': { | |
'imageType': 'COS', | |
'preemptible': True, | |
'oauthScopes': [ | |
'https://www.googleapis.com/auth/' + scope | |
for scope in [ | |
'compute', | |
'devstorage.read_only', | |
'logging.write', | |
'monitoring' | |
] | |
] | |
}, | |
'autoscaling': { | |
'enabled': False | |
}, | |
'management': { | |
'autoUpgrade': True, | |
'autoRepair': True, | |
'upgradeOptions': {} | |
} | |
}] | |
} | |
} | |
}) | |
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