mirror of
https://github.com/openshift/installer.git
synced 2026-02-05 06:46:36 +01:00
This mirrors changes to GCP IPI in #3544 The infra id of the clusters on GCP was reduced to 12 in #2088 because we couldn't handle the hostname seen by rhcos machine to be greater than 64. More details on this are available in https://bugzilla.redhat.com/show_bug.cgi?id=1809345 now since BZ 1809345 is fixed by openshift/machine-config-operator#1711 and openshift/cluster-api-provider-gcp#88 the installer can relax the restriction on the infra-id to match the other platforms. Why is it important? On GCP all resources are prefixed with infra-id, which currently is 12 chars with 6 chars used by random bit, leaving only 6 chars from cluster name. This causes trouble associating the cluster to jobs in CI as most of the identifyable characters are dropped from the resource names in CI due to this restriction. Also because of the previous restriction, only one char are used from pool's name, making is higly likely to collide in cases there are more.
108 lines
4.1 KiB
Python
108 lines
4.1 KiB
Python
def GenerateConfig(context):
|
|
|
|
resources = [{
|
|
'name': context.properties['infra_id'] + '-master-0',
|
|
'type': 'compute.v1.instance',
|
|
'properties': {
|
|
'disks': [{
|
|
'autoDelete': True,
|
|
'boot': True,
|
|
'initializeParams': {
|
|
'diskSizeGb': context.properties['root_volume_size'],
|
|
'diskType': 'zones/' + context.properties['zones'][0] + '/diskTypes/pd-ssd',
|
|
'sourceImage': context.properties['image']
|
|
}
|
|
}],
|
|
'machineType': 'zones/' + context.properties['zones'][0] + '/machineTypes/' + context.properties['machine_type'],
|
|
'metadata': {
|
|
'items': [{
|
|
'key': 'user-data',
|
|
'value': context.properties['ignition']
|
|
}]
|
|
},
|
|
'networkInterfaces': [{
|
|
'subnetwork': context.properties['control_subnet']
|
|
}],
|
|
'serviceAccounts': [{
|
|
'email': context.properties['service_account_email'],
|
|
'scopes': ['https://www.googleapis.com/auth/cloud-platform']
|
|
}],
|
|
'tags': {
|
|
'items': [
|
|
context.properties['infra_id'] + '-master',
|
|
]
|
|
},
|
|
'zone': context.properties['zones'][0]
|
|
}
|
|
}, {
|
|
'name': context.properties['infra_id'] + '-master-1',
|
|
'type': 'compute.v1.instance',
|
|
'properties': {
|
|
'disks': [{
|
|
'autoDelete': True,
|
|
'boot': True,
|
|
'initializeParams': {
|
|
'diskSizeGb': context.properties['root_volume_size'],
|
|
'diskType': 'zones/' + context.properties['zones'][1] + '/diskTypes/pd-ssd',
|
|
'sourceImage': context.properties['image']
|
|
}
|
|
}],
|
|
'machineType': 'zones/' + context.properties['zones'][1] + '/machineTypes/' + context.properties['machine_type'],
|
|
'metadata': {
|
|
'items': [{
|
|
'key': 'user-data',
|
|
'value': context.properties['ignition']
|
|
}]
|
|
},
|
|
'networkInterfaces': [{
|
|
'subnetwork': context.properties['control_subnet']
|
|
}],
|
|
'serviceAccounts': [{
|
|
'email': context.properties['service_account_email'],
|
|
'scopes': ['https://www.googleapis.com/auth/cloud-platform']
|
|
}],
|
|
'tags': {
|
|
'items': [
|
|
context.properties['infra_id'] + '-master',
|
|
]
|
|
},
|
|
'zone': context.properties['zones'][1]
|
|
}
|
|
}, {
|
|
'name': context.properties['infra_id'] + '-master-2',
|
|
'type': 'compute.v1.instance',
|
|
'properties': {
|
|
'disks': [{
|
|
'autoDelete': True,
|
|
'boot': True,
|
|
'initializeParams': {
|
|
'diskSizeGb': context.properties['root_volume_size'],
|
|
'diskType': 'zones/' + context.properties['zones'][2] + '/diskTypes/pd-ssd',
|
|
'sourceImage': context.properties['image']
|
|
}
|
|
}],
|
|
'machineType': 'zones/' + context.properties['zones'][2] + '/machineTypes/' + context.properties['machine_type'],
|
|
'metadata': {
|
|
'items': [{
|
|
'key': 'user-data',
|
|
'value': context.properties['ignition']
|
|
}]
|
|
},
|
|
'networkInterfaces': [{
|
|
'subnetwork': context.properties['control_subnet']
|
|
}],
|
|
'serviceAccounts': [{
|
|
'email': context.properties['service_account_email'],
|
|
'scopes': ['https://www.googleapis.com/auth/cloud-platform']
|
|
}],
|
|
'tags': {
|
|
'items': [
|
|
context.properties['infra_id'] + '-master',
|
|
]
|
|
},
|
|
'zone': context.properties['zones'][2]
|
|
}
|
|
}]
|
|
|
|
return {'resources': resources}
|