Skip to content

Commit a2de17e

Browse files
aks-preview: Change NAT gateway V2 outbound IPs/prefixes to comma-separated
Change --nat-gateway-outbound-ips and --nat-gateway-outbound-ip-prefixes from space-separated (nargs='+') to comma-separated string input, matching the existing load balancer outbound IP parameter pattern (--load-balancer-outbound-ips). Before: az aks create --nat-gateway-outbound-ips id1 id2 After: az aks create --nat-gateway-outbound-ips id1,id2
1 parent e60945d commit a2de17e

File tree

5 files changed

+48
-18
lines changed

5 files changed

+48
-18
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ To release a new version, please select a new version number (usually plus 1 to
1212
Pending
1313
+++++++
1414

15+
19.0.0b30
16+
+++++++
17+
* `az aks create/update`: Change `--nat-gateway-outbound-ips` and `--nat-gateway-outbound-ip-prefixes` to use comma-separated values, consistent with load balancer outbound IP parameters.
18+
1519
19.0.0b29
1620
+++++++
1721
* Add MIG (Multi-Instance GPU) strategy option to node pool property in `az aks nodepool add` and `az aks nodepool update`.
1822
* Fix monitoring addon key casing compatibility with azure-cli/acs
1923
* `az aks create/update`: Add `--outbound-type managedNATGatewayV2` support using Azure NAT Gateway Standard V2 SKU with IPv6, user-provided IPs, and IP prefixes.
2024
* `az aks create/update`: Fix `--outbound-type managedNATGatewayV2` being silently overwritten to `loadBalancer` by the dynamic completion logic.
25+
* `az aks create/update`: Change `--nat-gateway-outbound-ips` and `--nat-gateway-outbound-ip-prefixes` to use comma-separated values, consistent with load balancer outbound IP parameters.
2126

2227
19.0.0b28
2328
+++++++

src/aks-preview/azext_aks_preview/_natgateway.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,16 @@ def configure_nat_gateway_profile(
9191

9292
if outbound_ip_ids is not None:
9393
ManagedClusterNATGatewayProfileOutboundIPs = models.ManagedClusterNATGatewayProfileOutboundIPs
94+
ip_id_list = [x.strip() for x in outbound_ip_ids.split(',') if x.strip()]
9495
profile.outbound_i_ps = ManagedClusterNATGatewayProfileOutboundIPs(
95-
public_i_ps=outbound_ip_ids
96+
public_i_ps=ip_id_list
9697
)
9798

9899
if outbound_ip_prefix_ids is not None:
99100
ManagedClusterNATGatewayProfileOutboundIPPrefixes = models.ManagedClusterNATGatewayProfileOutboundIPPrefixes
101+
prefix_id_list = [x.strip() for x in outbound_ip_prefix_ids.split(',') if x.strip()]
100102
profile.outbound_ip_prefixes = ManagedClusterNATGatewayProfileOutboundIPPrefixes(
101-
public_ip_prefixes=outbound_ip_prefix_ids
103+
public_ip_prefixes=prefix_id_list
102104
)
103105

104106
return profile

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,7 @@ def load_arguments(self, _):
691691
"--nat-gateway-outbound-ips",
692692
"--nat-gw-ips",
693693
],
694-
nargs="+",
695-
help="Space-separated public IP resource IDs for the "
694+
help="Comma-separated public IP resource IDs for the "
696695
"cluster NAT gateway. V2 only.",
697696
)
698697
c.argument(
@@ -701,8 +700,7 @@ def load_arguments(self, _):
701700
"--nat-gateway-outbound-ip-prefixes",
702701
"--nat-gw-prefixes",
703702
],
704-
nargs="+",
705-
help="Space-separated public IP prefix resource IDs "
703+
help="Comma-separated public IP prefix resource IDs "
706704
"for the cluster NAT gateway. V2 only.",
707705
)
708706
c.argument(
@@ -1329,8 +1327,7 @@ def load_arguments(self, _):
13291327
"--nat-gateway-outbound-ips",
13301328
"--nat-gw-ips",
13311329
],
1332-
nargs="+",
1333-
help="Space-separated public IP resource IDs for the "
1330+
help="Comma-separated public IP resource IDs for the "
13341331
"cluster NAT gateway. V2 only.",
13351332
)
13361333
c.argument(
@@ -1339,8 +1336,7 @@ def load_arguments(self, _):
13391336
"--nat-gateway-outbound-ip-prefixes",
13401337
"--nat-gw-prefixes",
13411338
],
1342-
nargs="+",
1343-
help="Space-separated public IP prefix resource IDs "
1339+
help="Comma-separated public IP prefix resource IDs "
13441340
"for the cluster NAT gateway. V2 only.",
13451341
)
13461342
c.argument("network_dataplane", arg_type=get_enum_type(network_dataplanes))

src/aks-preview/azext_aks_preview/tests/latest/test_natgateway.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,51 @@ def test_v2_with_managed_outbound_ipv6_count(self):
122122
self.assertEqual(profile.idle_timeout_in_minutes, 30)
123123

124124
def test_v2_with_outbound_ip_ids(self):
125-
ip_ids = ["/subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/ip1"]
125+
ip_ids = "/subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/ip1"
126126
profile = natgateway.create_nat_gateway_profile(
127127
None, None, models=self.nat_gateway_models,
128128
outbound_ip_ids=ip_ids,
129129
)
130130
self.assertIsNotNone(profile)
131131
self.assertEqual(len(profile.outbound_i_ps.public_i_ps), 1)
132-
self.assertEqual(profile.outbound_i_ps.public_i_ps[0], ip_ids[0])
132+
self.assertEqual(profile.outbound_i_ps.public_i_ps[0], ip_ids)
133+
134+
def test_v2_with_multiple_outbound_ip_ids(self):
135+
ip_ids = "/sub/rg/ip1,/sub/rg/ip2"
136+
profile = natgateway.create_nat_gateway_profile(
137+
None, None, models=self.nat_gateway_models,
138+
outbound_ip_ids=ip_ids,
139+
)
140+
self.assertEqual(len(profile.outbound_i_ps.public_i_ps), 2)
141+
self.assertEqual(profile.outbound_i_ps.public_i_ps[0], "/sub/rg/ip1")
142+
self.assertEqual(profile.outbound_i_ps.public_i_ps[1], "/sub/rg/ip2")
143+
144+
def test_v2_with_outbound_ip_ids_whitespace(self):
145+
ip_ids = "/sub/rg/ip1, /sub/rg/ip2"
146+
profile = natgateway.create_nat_gateway_profile(
147+
None, None, models=self.nat_gateway_models,
148+
outbound_ip_ids=ip_ids,
149+
)
150+
self.assertEqual(len(profile.outbound_i_ps.public_i_ps), 2)
151+
self.assertEqual(profile.outbound_i_ps.public_i_ps[1], "/sub/rg/ip2")
152+
153+
def test_v2_with_outbound_ip_ids_trailing_comma(self):
154+
ip_ids = "/sub/rg/ip1,"
155+
profile = natgateway.create_nat_gateway_profile(
156+
None, None, models=self.nat_gateway_models,
157+
outbound_ip_ids=ip_ids,
158+
)
159+
self.assertEqual(len(profile.outbound_i_ps.public_i_ps), 1)
133160

134161
def test_v2_with_outbound_ip_prefix_ids(self):
135-
prefix_ids = ["/subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Network/publicIPPrefixes/prefix1"]
162+
prefix_ids = "/subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Network/publicIPPrefixes/prefix1"
136163
profile = natgateway.create_nat_gateway_profile(
137164
None, None, models=self.nat_gateway_models,
138165
outbound_ip_prefix_ids=prefix_ids,
139166
)
140167
self.assertIsNotNone(profile)
141168
self.assertEqual(len(profile.outbound_ip_prefixes.public_ip_prefixes), 1)
142-
self.assertEqual(profile.outbound_ip_prefixes.public_ip_prefixes[0], prefix_ids[0])
169+
self.assertEqual(profile.outbound_ip_prefixes.public_ip_prefixes[0], prefix_ids)
143170

144171
def test_v2_only_ipv6_count(self):
145172
profile = natgateway.create_nat_gateway_profile(
@@ -171,7 +198,7 @@ def test_v2_update_with_ipv6_count(self):
171198

172199
def test_v2_update_with_outbound_ip_ids(self):
173200
origin_profile = self.nat_gateway_models.ManagedClusterNATGatewayProfile(idle_timeout_in_minutes=4)
174-
ip_ids = ["/subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/ip1"]
201+
ip_ids = "/subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/ip1"
175202
profile = natgateway.update_nat_gateway_profile(
176203
None, None, origin_profile, models=self.nat_gateway_models,
177204
outbound_ip_ids=ip_ids,
@@ -196,11 +223,11 @@ def test_only_ipv6_count(self):
196223
self.assertTrue(result)
197224

198225
def test_only_outbound_ip_ids(self):
199-
result = natgateway.is_nat_gateway_profile_provided(None, None, outbound_ip_ids=["/sub/ip1"])
226+
result = natgateway.is_nat_gateway_profile_provided(None, None, outbound_ip_ids="/sub/ip1")
200227
self.assertTrue(result)
201228

202229
def test_only_outbound_ip_prefix_ids(self):
203-
result = natgateway.is_nat_gateway_profile_provided(None, None, outbound_ip_prefix_ids=["/sub/prefix1"])
230+
result = natgateway.is_nat_gateway_profile_provided(None, None, outbound_ip_prefix_ids="/sub/prefix1")
204231
self.assertTrue(result)
205232

206233
def test_all_none(self):

src/aks-preview/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from setuptools import find_packages, setup
1111

12-
VERSION = "19.0.0b29"
12+
VERSION = "19.0.0b30"
1313

1414
CLASSIFIERS = [
1515
"Development Status :: 4 - Beta",

0 commit comments

Comments
 (0)