-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
02_lb_int.py
71 lines (67 loc) · 2.63 KB
/
02_lb_int.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def GenerateConfig(context):
backends = []
for zone in context.properties['zones']:
backends.append({
'group': '$(ref.' + context.properties['infra_id'] + '-master-' + zone + '-ig' + '.selfLink)'
})
resources = [{
'name': context.properties['infra_id'] + '-cluster-ip',
'type': 'compute.v1.address',
'properties': {
'addressType': 'INTERNAL',
'region': context.properties['region'],
'subnetwork': context.properties['control_subnet']
}
}, {
# Refer to docs/dev/kube-apiserver-health-check.md on how to correctly setup health check probe for kube-apiserver
'name': context.properties['infra_id'] + '-api-internal-health-check',
'type': 'compute.v1.healthCheck',
'properties': {
'httpsHealthCheck': {
'port': 6443,
'requestPath': '/readyz'
},
'type': "HTTPS"
}
}, {
'name': context.properties['infra_id'] + '-api-internal',
'type': 'compute.v1.regionBackendService',
'properties': {
'backends': backends,
'healthChecks': ['$(ref.' + context.properties['infra_id'] + '-api-internal-health-check.selfLink)'],
'loadBalancingScheme': 'INTERNAL',
'region': context.properties['region'],
'protocol': 'TCP',
'timeoutSec': 120
}
}, {
'name': context.properties['infra_id'] + '-api-internal-forwarding-rule',
'type': 'compute.v1.forwardingRule',
'properties': {
'backendService': '$(ref.' + context.properties['infra_id'] + '-api-internal.selfLink)',
'IPAddress': '$(ref.' + context.properties['infra_id'] + '-cluster-ip.selfLink)',
'loadBalancingScheme': 'INTERNAL',
'ports': ['6443','22623'],
'region': context.properties['region'],
'subnetwork': context.properties['control_subnet']
}
}]
for zone in context.properties['zones']:
resources.append({
'name': context.properties['infra_id'] + '-master-' + zone + '-ig',
'type': 'compute.v1.instanceGroup',
'properties': {
'namedPorts': [
{
'name': 'ignition',
'port': 22623
}, {
'name': 'https',
'port': 6443
}
],
'network': context.properties['cluster_network'],
'zone': zone
}
})
return {'resources': resources}