11.18.
참고
$ export COMPUTE_SUBNET=(`gcloud compute networks subnets describe ${HOST_PROJECT_COMPUTE_SUBNET} --region=${REGION} --project ${HOST_PROJECT} --account ${HOST_PROJECT_ACCOUNT} --format json | jq -r .selfLink`)$ export WORKER_SERVICE_ACCOUNT=(`gcloud iam service-accounts list --filter "email~^${INFRA_ID}-w@${PROJECT_NAME}." --format json | jq -r '.[0].email'`)$ export WORKER_IGNITION=`cat <installation_directory>/worker.ign`
$ cat <<EOF >06_worker.yaml imports: - path: 06_worker.py resources: - name: 'worker-0'1 type: 06_worker.py properties: infra_id: '${INFRA_ID}'2 zone: '${ZONE_0}'3 compute_subnet: '${COMPUTE_SUBNET}'4 image: '${CLUSTER_IMAGE}'5 machine_type: 'n1-standard-4'6 root_volume_size: '128' service_account_email: '${WORKER_SERVICE_ACCOUNT}'7 ignition: '${WORKER_IGNITION}'8 - name: 'worker-1' type: 06_worker.py properties: infra_id: '${INFRA_ID}'9 zone: '${ZONE_1}'10 compute_subnet: '${COMPUTE_SUBNET}'11 image: '${CLUSTER_IMAGE}'12 machine_type: 'n1-standard-4'13 root_volume_size: '128' service_account_email: '${WORKER_SERVICE_ACCOUNT}'14 ignition: '${WORKER_IGNITION}'15 EOF$ gcloud deployment-manager deployments create ${INFRA_ID}-worker --config 06_worker.yaml
11.18.1. 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
예 11.10.
def GenerateConfig(context):
resources = [{
'name': context.properties['infra_id'] + '-' + context.env['name'],
'type': 'compute.v1.instance',
'properties': {
'disks': [{
'autoDelete': True,
'boot': True,
'initializeParams': {
'diskSizeGb': context.properties['root_volume_size'],
'sourceImage': context.properties['image']
}
}],
'machineType': 'zones/' + context.properties['zone'] + '/machineTypes/' + context.properties['machine_type'],
'metadata': {
'items': [{
'key': 'user-data',
'value': context.properties['ignition']
}]
},
'networkInterfaces': [{
'subnetwork': context.properties['compute_subnet']
}],
'serviceAccounts': [{
'email': context.properties['service_account_email'],
'scopes': ['https://www.googleapis.com/auth/cloud-platform']
}],
'tags': {
'items': [
context.properties['infra_id'] + '-worker',
]
},
'zone': context.properties['zone']
}
}]
return {'resources': resources}