def GenerateConfig()

in marketplace/vm-solution/cluster.py [0:0]


def GenerateConfig(context):
  """Generate YAML resource configuration."""

  # name_prefix = context.env['deployment'] + '-' + context.env['name']
  cluster_name = 'datashare-cluster-resource'
  acutal_cluster_name = 'datashare'
  # type_name = name_prefix + '-type'
  cluster_version_num = context.properties['clusterVersion']
  cluster_version = '' + str(cluster_version_num) + ''
  is_private_gke_cluster = context.properties['isPrivateGkeCluster']
  workload_pool = context.env['project'] + '.svc.id.goog'
  machine_type = 'n2-standard-2'
  initial_node_count = 4
  network = context.properties['network']
  subnetwork = context.properties['subnetwork']
  ## TODO add control statement to add PrivateClusterConfig if user selects true;

  resources = [
      {
          'name': cluster_name,
          'type': 'container.v1.cluster',
          #'metadata': {
          #  'dependsOn': ['delete-api']
          #},
          'properties': {
              'zone': context.properties['zone'],
              'cluster': {
                  'name': acutal_cluster_name,
                  'initialClusterVersion': '' + cluster_version + '',
                  'ipAllocationPolicy': {
                      'useIpAliases': True,
                  },
                  "releaseChannel" : {
                      "channel": 'STABLE'
                  },
                  "nodePools": [
                      {
                          "name": "default-pool",
                          "initial_node_count": initial_node_count,
                          "autoscaling": {
                              "enabled": True,
                              "minNodeCount": initial_node_count, 
                              "maxNodeCount": 8

                          },   
                          "management": {
                              "autoUpgrade": True,
                              "autoRepair": True
                          },
                          "upgradeSettings": {
                            "maxSurge": 2
                          },
                          "config": {
                            'machineType': machine_type,
                            'oauthScopes': [
                                'https://www.googleapis.com/auth/' + s
                                    for s in [
                                    'compute',
                                    'devstorage.read_only',
                                    'logging.write',
                                    'monitoring'
                                 ]
                            ]
                          } 
                      }
                  ],
                  'network': network,
                  'subnetwork': subnetwork,
                  'workloadIdentityConfig': {
                      'workloadPool': workload_pool,
                  },
                  'addonsConfig': {
                    'horizontalPodAutoscaling': {
                        'disabled': False,  
                    },
                    'httpLoadBalancing': {
                        'disabled': False,
                    },
                    'cloudRunConfig': {
                        'disabled': False,
                    }
                  }
              }
          }
      }
  ]

  if is_private_gke_cluster == True:
      resources[0]['privateClusterConfig'] =  {
                      'enablePrivateNodes': True,
                      'masterIpv4CidrBlock': '172.16.0.32/28'
                  }
                  
  outputs = []
  
  return {'resources': resources, 'outputs': outputs}