Skip to content

Commit fa2b1dd

Browse files
authored
Add parameter --rotation-poll-interval for Azure Keyvault Secrets Provider Addon (#3999)
Signed-off-by: Ji An Liu <[email protected]>
1 parent 215720a commit fa2b1dd

13 files changed

+2085
-2461
lines changed

src/aks-preview/HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Release History
44
===============
5+
0.5.38
6+
+++++
7+
* Add parameter `--rotation-poll-interval` for Azure Keyvault Secrets Provider Addon.
8+
59
0.5.37
610
+++++
711
* Add Windows gMSA v2 support. Add parameters `--enable-windows-gmsa`, `--gmsa-dns-server` and `--gmsa-root-domain-name`

src/aks-preview/azext_aks_preview/_consts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
# Azure Keyvault Secrets Provider configuration keys
7070
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME = "azureKeyvaultSecretsProvider"
7171
CONST_SECRET_ROTATION_ENABLED = "enableSecretRotation"
72+
CONST_ROTATION_POLL_INTERVAL = "rotationPollInterval"
7273

7374
# Scale Down Mode
7475
CONST_SCALE_DOWN_MODE_DELETE = "Delete"

src/aks-preview/azext_aks_preview/_help.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@
349349
- name: --enable-secret-rotation
350350
type: bool
351351
short-summary: Enable secret rotation. Use with azure-keyvault-secrets-provider addon.
352+
- name: --rotation-poll-interval
353+
type: string
354+
short-summary: Set interval of rotation poll. Use with azure-keyvault-secrets-provider addon.
352355
- name: --disable-local-accounts
353356
type: bool
354357
short-summary: (Preview) If set to true, getting static credential will be disabled for this cluster.
@@ -571,6 +574,9 @@
571574
- name: --disable-secret-rotation
572575
type: bool
573576
short-summary: Disable secret rotation. Use with azure-keyvault-secrets-provider addon.
577+
- name: --rotation-poll-interval
578+
type: string
579+
short-summary: Set interval of rotation poll. Use with azure-keyvault-secrets-provider addon.
574580
- name: --tags
575581
type: string
576582
short-summary: The tags of the managed cluster. The managed cluster instance and all resources managed by the cloud provider will be tagged.
@@ -1174,6 +1180,9 @@
11741180
- name: --enable-secret-rotation
11751181
type: bool
11761182
short-summary: Enable secret rotation. Use with azure-keyvault-secrets-provider addon.
1183+
- name: --rotation-poll-interval
1184+
type: string
1185+
short-summary: Set interval of rotation poll. Use with azure-keyvault-secrets-provider addon.
11771186
examples:
11781187
- name: Enable a Kubernetes addon. (autogenerated)
11791188
text: az aks addon enable --addon virtual-node --name MyManagedCluster --resource-group MyResourceGroup --subnet-name VirtualNodeSubnet
@@ -1226,6 +1235,9 @@
12261235
- name: --enable-secret-rotation
12271236
type: bool
12281237
short-summary: Enable secret rotation. Use with azure-keyvault-secrets-provider addon.
1238+
- name: --rotation-poll-interval
1239+
type: string
1240+
short-summary: Set interval of rotation poll. Use with azure-keyvault-secrets-provider addon.
12291241
examples:
12301242
- name: Update a Kubernetes addon. (autogenerated)
12311243
text: az aks addon update --addon virtual-node --name MyManagedCluster --resource-group MyResourceGroup --subnet-name VirtualNodeSubnet
@@ -1291,6 +1303,9 @@
12911303
- name: --enable-secret-rotation
12921304
type: bool
12931305
short-summary: Enable secret rotation. Use with azure-keyvault-secrets-provider addon.
1306+
- name: --rotation-poll-interval
1307+
type: string
1308+
short-summary: Set interval of rotation poll. Use with azure-keyvault-secrets-provider addon.
12941309
examples:
12951310
- name: Enable Kubernetes addons. (autogenerated)
12961311
text: az aks enable-addons --addons virtual-node --name MyManagedCluster --resource-group MyResourceGroup --subnet-name VirtualNodeSubnet

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def load_arguments(self, _):
143143
c.argument('enable_encryption_at_host', arg_type=get_three_state_flag(), help='Enable EncryptionAtHost.')
144144
c.argument('enable_ultra_ssd', action='store_true')
145145
c.argument('enable_secret_rotation', action='store_true')
146+
c.argument('rotation_poll_interval', type=str)
146147
c.argument('assign_kubelet_identity', type=str, validator=validate_assign_kubelet_identity)
147148
c.argument('disable_local_accounts', action='store_true')
148149
c.argument('gpu_instance_profile', arg_type=get_enum_type(gpu_instance_profiles))
@@ -183,6 +184,7 @@ def load_arguments(self, _):
183184
c.argument('disable_pod_identity', action='store_true')
184185
c.argument('enable_secret_rotation', action='store_true')
185186
c.argument('disable_secret_rotation', action='store_true')
187+
c.argument('rotation_poll_interval', type=str)
186188
c.argument('windows_admin_password', options_list=['--windows-admin-password'])
187189
c.argument('disable_local_accounts', action='store_true')
188190
c.argument('enable_local_accounts', action='store_true')
@@ -281,6 +283,7 @@ def load_arguments(self, _):
281283
c.argument('appgw_subnet_id', options_list=['--appgw-subnet-id'], arg_group='Application Gateway')
282284
c.argument('appgw_watch_namespace', options_list=['--appgw-watch-namespace'], arg_group='Application Gateway')
283285
c.argument('enable_secret_rotation', action='store_true')
286+
c.argument('rotation_poll_interval', type=str)
284287
c.argument('workspace_resource_id')
285288
c.argument('enable_msi_auth_for_monitoring', arg_type=get_three_state_flag(), is_preview=True)
286289

@@ -299,6 +302,7 @@ def load_arguments(self, _):
299302
c.argument('appgw_subnet_id', options_list=['--appgw-subnet-id'], arg_group='Application Gateway')
300303
c.argument('appgw_watch_namespace', options_list=['--appgw-watch-namespace'], arg_group='Application Gateway')
301304
c.argument('enable_secret_rotation', action='store_true')
305+
c.argument('rotation_poll_interval', type=str)
302306
c.argument('workspace_resource_id')
303307
c.argument('enable_msi_auth_for_monitoring', arg_type=get_three_state_flag(), is_preview=True)
304308

@@ -317,6 +321,7 @@ def load_arguments(self, _):
317321
c.argument('appgw_subnet_id', options_list=['--appgw-subnet-id'], arg_group='Application Gateway')
318322
c.argument('appgw_watch_namespace', options_list=['--appgw-watch-namespace'], arg_group='Application Gateway')
319323
c.argument('enable_secret_rotation', action='store_true')
324+
c.argument('rotation_poll_interval', type=str)
320325
c.argument('workspace_resource_id')
321326
c.argument('enable_msi_auth_for_monitoring', arg_type=get_three_state_flag(), is_preview=True)
322327

src/aks-preview/azext_aks_preview/addonconfiguration.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
CONST_VIRTUAL_NODE_SUBNET_NAME, CONST_INGRESS_APPGW_ADDON_NAME, CONST_INGRESS_APPGW_APPLICATION_GATEWAY_NAME, \
2121
CONST_INGRESS_APPGW_SUBNET_CIDR, CONST_INGRESS_APPGW_APPLICATION_GATEWAY_ID, CONST_INGRESS_APPGW_SUBNET_ID, \
2222
CONST_INGRESS_APPGW_WATCH_NAMESPACE, CONST_OPEN_SERVICE_MESH_ADDON_NAME, CONST_CONFCOM_ADDON_NAME, \
23-
CONST_ACC_SGX_QUOTE_HELPER_ENABLED, CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME, CONST_SECRET_ROTATION_ENABLED, \
23+
CONST_ACC_SGX_QUOTE_HELPER_ENABLED, CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME, CONST_SECRET_ROTATION_ENABLED, CONST_ROTATION_POLL_INTERVAL, \
2424
CONST_KUBE_DASHBOARD_ADDON_NAME
2525

2626
logger = get_logger(__name__)
@@ -42,6 +42,7 @@ def enable_addons(cmd,
4242
appgw_watch_namespace=None,
4343
enable_sgxquotehelper=False,
4444
enable_secret_rotation=False,
45+
rotation_poll_interval=None,
4546
no_wait=False,
4647
enable_msi_auth_for_monitoring=False):
4748
instance = client.get(resource_group_name, name)
@@ -57,7 +58,7 @@ def enable_addons(cmd,
5758
appgw_subnet_cidr=appgw_subnet_cidr, appgw_id=appgw_id, appgw_subnet_id=appgw_subnet_id,
5859
appgw_watch_namespace=appgw_watch_namespace,
5960
enable_sgxquotehelper=enable_sgxquotehelper,
60-
enable_secret_rotation=enable_secret_rotation, no_wait=no_wait)
61+
enable_secret_rotation=enable_secret_rotation, rotation_poll_interval=rotation_poll_interval, no_wait=no_wait)
6162

6263
if CONST_MONITORING_ADDON_NAME in instance.addon_profiles and instance.addon_profiles[
6364
CONST_MONITORING_ADDON_NAME].enabled:
@@ -141,6 +142,7 @@ def update_addons(cmd, # pylint: disable=too-many-branches,too-many-statements
141142
appgw_watch_namespace=None,
142143
enable_sgxquotehelper=False,
143144
enable_secret_rotation=False,
145+
rotation_poll_interval=None,
144146
no_wait=False): # pylint: disable=unused-argument
145147
# parse the comma-separated addons argument
146148
addon_args = addons.split(',')
@@ -242,9 +244,11 @@ def update_addons(cmd, # pylint: disable=too-many-branches,too-many-statements
242244
f'"az aks disable-addons -a azure-keyvault-secrets-provider -n {name} -g {resource_group_name}" '
243245
'before enabling it again.')
244246
addon_profile = ManagedClusterAddonProfile(
245-
enabled=True, config={CONST_SECRET_ROTATION_ENABLED: "false"})
247+
enabled=True, config={CONST_SECRET_ROTATION_ENABLED: "false", CONST_ROTATION_POLL_INTERVAL: "2m"})
246248
if enable_secret_rotation:
247249
addon_profile.config[CONST_SECRET_ROTATION_ENABLED] = "true"
250+
if rotation_poll_interval is not None:
251+
addon_profile.config[CONST_ROTATION_POLL_INTERVAL] = rotation_poll_interval
248252
addon_profiles[CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME] = addon_profile
249253
addon_profiles[addon] = addon_profile
250254
else:

0 commit comments

Comments
 (0)