Skip to content

Commit 246d291

Browse files
committed
[AKS] Remove --enable-pod-security-policy as it's deprecated
1 parent a5204c5 commit 246d291

File tree

7 files changed

+6
-209
lines changed

7 files changed

+6
-209
lines changed

linter_exclusions.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ aks create:
3737
node_public_ip_prefix_id:
3838
rule_exclusions:
3939
- option_length_too_long
40-
enable_pod_security_policy:
41-
rule_exclusions:
42-
- option_length_too_long
4340
enable_private_cluster:
4441
rule_exclusions:
4542
- option_length_too_long
@@ -138,9 +135,6 @@ aks update:
138135
disable_pod_security_policy:
139136
rule_exclusions:
140137
- option_length_too_long
141-
enable_pod_security_policy:
142-
rule_exclusions:
143-
- option_length_too_long
144138
load_balancer_idle_timeout:
145139
rule_exclusions:
146140
- option_length_too_long

src/aks-preview/HISTORY.rst

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

15+
18.0.0b1
16+
+++++++
17+
* [BREAKING CHANGE] Remove "--enable-pod-security-policy" as it's deprecated.
18+
1519
17.0.0b2
1620
++++++++
1721
* Add option `--migrate-vmas-to-vms` to `az aks update`

src/aks-preview/azext_aks_preview/_help.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,6 @@
304304
- name: --vm-set-type
305305
type: string
306306
short-summary: Agent pool vm set type. VirtualMachineScaleSets, AvailabilitySet or VirtualMachines(Preview).
307-
- name: --enable-pod-security-policy
308-
type: bool
309-
short-summary: Enable pod security policy.
310-
long-summary: --enable-pod-security-policy is deprecated. See https://aka.ms/aks/psp for details.
311307
- name: --node-resource-group
312308
type: string
313309
short-summary: The node resource group is the resource group where all customer's resources will be created in, such as virtual machines.
@@ -864,10 +860,6 @@
864860
type: string
865861
short-summary: How outbound traffic will be configured for a cluster.
866862
long-summary: This option will change the way how the outbound connections are managed in the AKS cluster. Available options are loadbalancer, managedNATGateway, userAssignedNATGateway, userDefinedRouting, none and block. For custom vnet, loadbalancer, userAssignedNATGateway and userDefinedRouting are supported. For aks managed vnet, loadbalancer, managedNATGateway and userDefinedRouting are supported.
867-
- name: --enable-pod-security-policy
868-
type: bool
869-
short-summary: Enable pod security policy.
870-
long-summary: --enable-pod-security-policy is deprecated. See https://aka.ms/aks/psp for details.
871863
- name: --disable-pod-security-policy
872864
type: bool
873865
short-summary: Disable pod security policy

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -767,13 +767,6 @@ def load_arguments(self, _):
767767
c.argument("pod_cidrs")
768768
c.argument("service_cidrs")
769769
c.argument("load_balancer_managed_outbound_ipv6_count", type=int)
770-
c.argument(
771-
"enable_pod_security_policy",
772-
action="store_true",
773-
deprecate_info=c.deprecate(
774-
target="--enable-pod-security-policy", hide=True
775-
),
776-
)
777770
c.argument("enable_pod_identity", action="store_true")
778771
c.argument("enable_pod_identity_with_kubenet", action="store_true")
779772
c.argument("enable_workload_identity", action="store_true")
@@ -1196,13 +1189,6 @@ def load_arguments(self, _):
11961189
)
11971190
c.argument("load_balancer_managed_outbound_ipv6_count", type=int)
11981191
c.argument("outbound_type", arg_type=get_enum_type(outbound_types))
1199-
c.argument(
1200-
"enable_pod_security_policy",
1201-
action="store_true",
1202-
deprecate_info=c.deprecate(
1203-
target="--enable-pod-security-policy", hide=True
1204-
),
1205-
)
12061192
c.argument("disable_pod_security_policy", action="store_true", is_preview=True)
12071193
c.argument("enable_pod_identity", action="store_true")
12081194
c.argument("enable_pod_identity_with_kubenet", action="store_true")

src/aks-preview/azext_aks_preview/custom.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ def aks_create(
478478
pod_cidrs=None,
479479
service_cidrs=None,
480480
load_balancer_managed_outbound_ipv6_count=None,
481-
enable_pod_security_policy=False,
482481
enable_pod_identity=False,
483482
enable_pod_identity_with_kubenet=False,
484483
enable_workload_identity=False,
@@ -686,7 +685,6 @@ def aks_update(
686685
network_dataplane=None,
687686
ip_families=None,
688687
pod_cidr=None,
689-
enable_pod_security_policy=False,
690688
disable_pod_security_policy=False,
691689
enable_pod_identity=False,
692690
enable_pod_identity_with_kubenet=False,

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -986,75 +986,23 @@ def get_force_upgrade(self) -> Union[bool, None]:
986986
return not disable_force_upgrade
987987
return None
988988

989-
def _get_enable_pod_security_policy(self, enable_validation: bool = False) -> bool:
990-
"""Internal function to obtain the value of enable_pod_security_policy.
991-
992-
This function supports the option of enable_validation. When enabled, if both enable_pod_security_policy and
993-
disable_pod_security_policy are specified, raise a MutuallyExclusiveArgumentError.
994-
995-
:return: bool
996-
"""
997-
# read the original value passed by the command
998-
enable_pod_security_policy = self.raw_param.get("enable_pod_security_policy")
999-
# In create mode, try to read the property value corresponding to the parameter from the `mc` object.
1000-
if self.decorator_mode == DecoratorMode.CREATE:
1001-
if (
1002-
self.mc and
1003-
self.mc.enable_pod_security_policy is not None
1004-
):
1005-
enable_pod_security_policy = self.mc.enable_pod_security_policy
1006-
1007-
# this parameter does not need dynamic completion
1008-
# validation
1009-
if enable_validation:
1010-
if enable_pod_security_policy and self._get_disable_pod_security_policy(enable_validation=False):
1011-
raise MutuallyExclusiveArgumentError(
1012-
"Cannot specify --enable-pod-security-policy and "
1013-
"--disable-pod-security-policy at the same time."
1014-
)
1015-
return enable_pod_security_policy
1016-
1017-
def get_enable_pod_security_policy(self) -> bool:
1018-
"""Obtain the value of enable_pod_security_policy.
1019-
1020-
This function will verify the parameter by default. If both enable_pod_security_policy and
1021-
disable_pod_security_policy are specified, raise a MutuallyExclusiveArgumentError.
1022-
1023-
:return: bool
1024-
"""
1025-
return self._get_enable_pod_security_policy(enable_validation=True)
1026-
1027-
def _get_disable_pod_security_policy(self, enable_validation: bool = False) -> bool:
989+
def _get_disable_pod_security_policy(self) -> bool:
1028990
"""Internal function to obtain the value of disable_pod_security_policy.
1029991
1030-
This function supports the option of enable_validation. When enabled, if both enable_pod_security_policy and
1031-
disable_pod_security_policy are specified, raise a MutuallyExclusiveArgumentError.
1032-
1033992
:return: bool
1034993
"""
1035994
# read the original value passed by the command
1036995
disable_pod_security_policy = self.raw_param.get("disable_pod_security_policy")
1037996
# We do not support this option in create mode, therefore we do not read the value from `mc`.
1038997

1039-
# this parameter does not need dynamic completion
1040-
# validation
1041-
if enable_validation:
1042-
if disable_pod_security_policy and self._get_enable_pod_security_policy(enable_validation=False):
1043-
raise MutuallyExclusiveArgumentError(
1044-
"Cannot specify --enable-pod-security-policy and "
1045-
"--disable-pod-security-policy at the same time."
1046-
)
1047998
return disable_pod_security_policy
1048999

10491000
def get_disable_pod_security_policy(self) -> bool:
10501001
"""Obtain the value of disable_pod_security_policy.
10511002
1052-
This function will verify the parameter by default. If both enable_pod_security_policy and
1053-
disable_pod_security_policy are specified, raise a MutuallyExclusiveArgumentError.
1054-
10551003
:return: bool
10561004
"""
1057-
return self._get_disable_pod_security_policy(enable_validation=True)
1005+
return self._get_disable_pod_security_policy()
10581006

10591007
# pylint: disable=unused-argument
10601008
def _get_enable_managed_identity(
@@ -3082,16 +3030,6 @@ def set_up_addon_profiles(self, mc: ManagedCluster) -> ManagedCluster:
30823030
mc.addon_profiles = addon_profiles
30833031
return mc
30843032

3085-
def set_up_pod_security_policy(self, mc: ManagedCluster) -> ManagedCluster:
3086-
"""Set up pod security policy for the ManagedCluster object.
3087-
3088-
:return: the ManagedCluster object
3089-
"""
3090-
self._ensure_mc(mc)
3091-
3092-
mc.enable_pod_security_policy = self.context.get_enable_pod_security_policy()
3093-
return mc
3094-
30953033
def set_up_pod_identity_profile(self, mc: ManagedCluster) -> ManagedCluster:
30963034
"""Set up pod identity profile for the ManagedCluster object.
30973035
@@ -3631,8 +3569,6 @@ def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) ->
36313569
# DO NOT MOVE: keep this on top, construct the default ManagedCluster profile
36323570
mc = self.construct_mc_profile_default(bypass_restore_defaults=True)
36333571

3634-
# set up pod security policy
3635-
mc = self.set_up_pod_security_policy(mc)
36363572
# set up pod identity profile
36373573
mc = self.set_up_pod_identity_profile(mc)
36383574
# set up workload identity profile
@@ -4567,9 +4503,6 @@ def update_pod_security_policy(self, mc: ManagedCluster) -> ManagedCluster:
45674503
"""
45684504
self._ensure_mc(mc)
45694505

4570-
if self.context.get_enable_pod_security_policy():
4571-
mc.enable_pod_security_policy = True
4572-
45734506
if self.context.get_disable_pod_security_policy():
45744507
mc.enable_pod_security_policy = False
45754508
return mc

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

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -704,38 +704,6 @@ def test_get_load_balancer_backend_pool_type(self):
704704
)
705705
self.assertEqual(ctx.get_load_balancer_backend_pool_type(), "nodeIP")
706706

707-
def test_get_enable_pod_security_policy(self):
708-
# default
709-
ctx_1 = AKSPreviewManagedClusterContext(
710-
self.cmd,
711-
AKSManagedClusterParamDict({"enable_pod_security_policy": False}),
712-
self.models,
713-
decorator_mode=DecoratorMode.CREATE,
714-
)
715-
self.assertEqual(ctx_1.get_enable_pod_security_policy(), False)
716-
mc = self.models.ManagedCluster(
717-
location="test_location",
718-
enable_pod_security_policy=True,
719-
)
720-
ctx_1.attach_mc(mc)
721-
self.assertEqual(ctx_1.get_enable_pod_security_policy(), True)
722-
723-
# custom value
724-
ctx_2 = AKSPreviewManagedClusterContext(
725-
self.cmd,
726-
AKSManagedClusterParamDict(
727-
{
728-
"enable_pod_security_policy": True,
729-
"disable_pod_security_policy": True,
730-
}
731-
),
732-
self.models,
733-
decorator_mode=DecoratorMode.UPDATE,
734-
)
735-
# fail on mutually exclusive enable_pod_security_policy and disable_pod_security_policy
736-
with self.assertRaises(MutuallyExclusiveArgumentError):
737-
ctx_2.get_enable_pod_security_policy()
738-
739707
def test_get_disable_pod_security_policy(self):
740708
# default
741709
ctx_1 = AKSPreviewManagedClusterContext(
@@ -752,22 +720,6 @@ def test_get_disable_pod_security_policy(self):
752720
ctx_1.attach_mc(mc)
753721
self.assertEqual(ctx_1.get_disable_pod_security_policy(), False)
754722

755-
# custom value
756-
ctx_2 = AKSPreviewManagedClusterContext(
757-
self.cmd,
758-
AKSManagedClusterParamDict(
759-
{
760-
"enable_pod_security_policy": True,
761-
"disable_pod_security_policy": True,
762-
}
763-
),
764-
self.models,
765-
decorator_mode=DecoratorMode.UPDATE,
766-
)
767-
# fail on mutually exclusive enable_pod_security_policy and disable_pod_security_policy
768-
with self.assertRaises(MutuallyExclusiveArgumentError):
769-
ctx_2.get_disable_pod_security_policy()
770-
771723
def test_get_network_plugin(self):
772724
# default
773725
ctx_1 = AKSPreviewManagedClusterContext(
@@ -4643,43 +4595,6 @@ def test_set_up_http_proxy_config(self):
46434595
)
46444596
self.assertEqual(dec_mc_1, ground_truth_mc_1)
46454597

4646-
def test_set_up_pod_security_policy(self):
4647-
# default value in `aks_create`
4648-
dec_1 = AKSPreviewManagedClusterCreateDecorator(
4649-
self.cmd,
4650-
self.client,
4651-
{
4652-
"enable_pod_security_policy": False,
4653-
},
4654-
CUSTOM_MGMT_AKS_PREVIEW,
4655-
)
4656-
mc_1 = self.models.ManagedCluster(location="test_location")
4657-
dec_1.context.attach_mc(mc_1)
4658-
# fail on passing the wrong mc object
4659-
with self.assertRaises(CLIInternalError):
4660-
dec_1.set_up_pod_security_policy(None)
4661-
dec_mc_1 = dec_1.set_up_pod_security_policy(mc_1)
4662-
ground_truth_mc_1 = self.models.ManagedCluster(
4663-
location="test_location", enable_pod_security_policy=False
4664-
)
4665-
self.assertEqual(dec_mc_1, ground_truth_mc_1)
4666-
4667-
# custom value
4668-
dec_2 = AKSPreviewManagedClusterCreateDecorator(
4669-
self.cmd,
4670-
self.client,
4671-
{"enable_pod_security_policy": True},
4672-
CUSTOM_MGMT_AKS_PREVIEW,
4673-
)
4674-
mc_2 = self.models.ManagedCluster(location="test_location")
4675-
dec_2.context.attach_mc(mc_2)
4676-
dec_mc_2 = dec_2.set_up_pod_security_policy(mc_2)
4677-
ground_truth_mc_2 = self.models.ManagedCluster(
4678-
location="test_location",
4679-
enable_pod_security_policy=True,
4680-
)
4681-
self.assertEqual(dec_mc_2, ground_truth_mc_2)
4682-
46834598
def test_set_up_pod_identity_profile(self):
46844599
# default value in `aks_create`
46854600
dec_1 = AKSPreviewManagedClusterCreateDecorator(
@@ -5580,7 +5495,6 @@ def test_construct_mc_profile_preview(self):
55805495
network_profile=network_profile_1,
55815496
identity=identity_1,
55825497
disable_local_accounts=False,
5583-
enable_pod_security_policy=False,
55845498
storage_profile=storage_profile_1,
55855499
sku=baseSKU,
55865500
kind="Base",
@@ -6594,7 +6508,6 @@ def test_update_pod_security_policy(self):
65946508
self.cmd,
65956509
self.client,
65966510
{
6597-
"enable_pod_security_policy": False,
65986511
"disable_pod_security_policy": False,
65996512
},
66006513
CUSTOM_MGMT_AKS_PREVIEW,
@@ -6615,34 +6528,11 @@ def test_update_pod_security_policy(self):
66156528
)
66166529
self.assertEqual(dec_mc_1, ground_truth_mc_1)
66176530

6618-
# custom value
6619-
dec_2 = AKSPreviewManagedClusterUpdateDecorator(
6620-
self.cmd,
6621-
self.client,
6622-
{
6623-
"enable_pod_security_policy": True,
6624-
"disable_pod_security_policy": False,
6625-
},
6626-
CUSTOM_MGMT_AKS_PREVIEW,
6627-
)
6628-
mc_2 = self.models.ManagedCluster(
6629-
location="test_location",
6630-
enable_pod_security_policy=False,
6631-
)
6632-
dec_2.context.attach_mc(mc_2)
6633-
dec_mc_2 = dec_2.update_pod_security_policy(mc_2)
6634-
ground_truth_mc_2 = self.models.ManagedCluster(
6635-
location="test_location",
6636-
enable_pod_security_policy=True,
6637-
)
6638-
self.assertEqual(dec_mc_2, ground_truth_mc_2)
6639-
66406531
# custom value
66416532
dec_3 = AKSPreviewManagedClusterUpdateDecorator(
66426533
self.cmd,
66436534
self.client,
66446535
{
6645-
"enable_pod_security_policy": False,
66466536
"disable_pod_security_policy": True,
66476537
},
66486538
CUSTOM_MGMT_AKS_PREVIEW,

0 commit comments

Comments
 (0)