Skip to content

Commit 46203a8

Browse files
committed
add ability to use named secondary ranges
1 parent fbd6b37 commit 46203a8

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

python-clusters/create-gke-cluster/cluster.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@
6464
{
6565
"name": "podIpRange",
6666
"label": "Pod IP range",
67-
"description": "Use CIDR block/mask notation, e.g. 10.0.0.0/21 or /21",
67+
"description": "Range name or CIDR block/mask notation, e.g. 10.0.0.0/21 or /21",
6868
"type": "STRING",
6969
"mandatory": false,
7070
"visibilityCondition": "model.isVpcNative"
7171
},
7272
{
7373
"name": "svcIpRange",
7474
"label": "Service IP range",
75-
"description": "Use CIDR block/mask notation, e.g. 10.0.0.0/24 or /24. MUST be different from pod IP range.",
75+
"description": "Range name or CIDR block/mask notation, e.g. 10.0.0.0/24 or /24. MUST be different from pod IP range.",
7676
"type": "STRING",
7777
"mandatory": false,
7878
"visibilityCondition": "model.isVpcNative"

python-lib/dku_google/clusters.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,18 @@ def build(self):
260260
if self.is_vpc_native:
261261
ip_allocation_policy = {
262262
"createSubnetwork": False,
263-
"useIpAliases": True,
264-
"servicesIpv4CidrBlock": cluster_svc_ip_range,
265-
"clusterIpv4CidrBlock": cluster_pod_ip_range,
263+
"useIpAliases": True
266264
}
265+
if re.match('[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+', cluster_svc_ip_range):
266+
ip_allocation_policy["servicesIpv4CidrBlock"] = cluster_svc_ip_range
267+
elif cluster_svc_ip_range is not None and len(cluster_svc_ip_range) > 0:
268+
# assume it's an existing range name (shared VPC case)
269+
ip_allocation_policy["servicesSecondaryRangeName"] = cluster_svc_ip_range
270+
if re.match('[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+', cluster_pod_ip_range):
271+
ip_allocation_policy["clusterIpv4CidrBlock"] = cluster_pod_ip_range
272+
elif cluster_pod_ip_range is not None and len(cluster_pod_ip_range) > 0:
273+
# assume it's an existing range name (shared VPC case)
274+
ip_allocation_policy["clusterSecondaryRangeName"] = cluster_pod_ip_range
267275
create_cluster_request_body["cluster"]["ipAllocationPolicy"] = ip_allocation_policy
268276

269277
if self.legacy_auth:

0 commit comments

Comments
 (0)