Skip to content

Commit

Permalink
Add parameter --rotation-poll-interval for Azure Keyvault Secrets P…
Browse files Browse the repository at this point in the history
…rovider Addon (#3999)

Signed-off-by: Ji An Liu <[email protected]>
  • Loading branch information
ZeroMagic authored Oct 21, 2021
1 parent 215720a commit fa2b1dd
Show file tree
Hide file tree
Showing 13 changed files with 2,085 additions and 2,461 deletions.
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Release History
===============
0.5.38
+++++
* Add parameter `--rotation-poll-interval` for Azure Keyvault Secrets Provider Addon.

0.5.37
+++++
* Add Windows gMSA v2 support. Add parameters `--enable-windows-gmsa`, `--gmsa-dns-server` and `--gmsa-root-domain-name`
Expand Down
1 change: 1 addition & 0 deletions src/aks-preview/azext_aks_preview/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
# Azure Keyvault Secrets Provider configuration keys
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME = "azureKeyvaultSecretsProvider"
CONST_SECRET_ROTATION_ENABLED = "enableSecretRotation"
CONST_ROTATION_POLL_INTERVAL = "rotationPollInterval"

# Scale Down Mode
CONST_SCALE_DOWN_MODE_DELETE = "Delete"
Expand Down
15 changes: 15 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@
- name: --enable-secret-rotation
type: bool
short-summary: Enable secret rotation. Use with azure-keyvault-secrets-provider addon.
- name: --rotation-poll-interval
type: string
short-summary: Set interval of rotation poll. Use with azure-keyvault-secrets-provider addon.
- name: --disable-local-accounts
type: bool
short-summary: (Preview) If set to true, getting static credential will be disabled for this cluster.
Expand Down Expand Up @@ -571,6 +574,9 @@
- name: --disable-secret-rotation
type: bool
short-summary: Disable secret rotation. Use with azure-keyvault-secrets-provider addon.
- name: --rotation-poll-interval
type: string
short-summary: Set interval of rotation poll. Use with azure-keyvault-secrets-provider addon.
- name: --tags
type: string
short-summary: The tags of the managed cluster. The managed cluster instance and all resources managed by the cloud provider will be tagged.
Expand Down Expand Up @@ -1174,6 +1180,9 @@
- name: --enable-secret-rotation
type: bool
short-summary: Enable secret rotation. Use with azure-keyvault-secrets-provider addon.
- name: --rotation-poll-interval
type: string
short-summary: Set interval of rotation poll. Use with azure-keyvault-secrets-provider addon.
examples:
- name: Enable a Kubernetes addon. (autogenerated)
text: az aks addon enable --addon virtual-node --name MyManagedCluster --resource-group MyResourceGroup --subnet-name VirtualNodeSubnet
Expand Down Expand Up @@ -1226,6 +1235,9 @@
- name: --enable-secret-rotation
type: bool
short-summary: Enable secret rotation. Use with azure-keyvault-secrets-provider addon.
- name: --rotation-poll-interval
type: string
short-summary: Set interval of rotation poll. Use with azure-keyvault-secrets-provider addon.
examples:
- name: Update a Kubernetes addon. (autogenerated)
text: az aks addon update --addon virtual-node --name MyManagedCluster --resource-group MyResourceGroup --subnet-name VirtualNodeSubnet
Expand Down Expand Up @@ -1291,6 +1303,9 @@
- name: --enable-secret-rotation
type: bool
short-summary: Enable secret rotation. Use with azure-keyvault-secrets-provider addon.
- name: --rotation-poll-interval
type: string
short-summary: Set interval of rotation poll. Use with azure-keyvault-secrets-provider addon.
examples:
- name: Enable Kubernetes addons. (autogenerated)
text: az aks enable-addons --addons virtual-node --name MyManagedCluster --resource-group MyResourceGroup --subnet-name VirtualNodeSubnet
Expand Down
5 changes: 5 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def load_arguments(self, _):
c.argument('enable_encryption_at_host', arg_type=get_three_state_flag(), help='Enable EncryptionAtHost.')
c.argument('enable_ultra_ssd', action='store_true')
c.argument('enable_secret_rotation', action='store_true')
c.argument('rotation_poll_interval', type=str)
c.argument('assign_kubelet_identity', type=str, validator=validate_assign_kubelet_identity)
c.argument('disable_local_accounts', action='store_true')
c.argument('gpu_instance_profile', arg_type=get_enum_type(gpu_instance_profiles))
Expand Down Expand Up @@ -183,6 +184,7 @@ def load_arguments(self, _):
c.argument('disable_pod_identity', action='store_true')
c.argument('enable_secret_rotation', action='store_true')
c.argument('disable_secret_rotation', action='store_true')
c.argument('rotation_poll_interval', type=str)
c.argument('windows_admin_password', options_list=['--windows-admin-password'])
c.argument('disable_local_accounts', action='store_true')
c.argument('enable_local_accounts', action='store_true')
Expand Down Expand Up @@ -281,6 +283,7 @@ def load_arguments(self, _):
c.argument('appgw_subnet_id', options_list=['--appgw-subnet-id'], arg_group='Application Gateway')
c.argument('appgw_watch_namespace', options_list=['--appgw-watch-namespace'], arg_group='Application Gateway')
c.argument('enable_secret_rotation', action='store_true')
c.argument('rotation_poll_interval', type=str)
c.argument('workspace_resource_id')
c.argument('enable_msi_auth_for_monitoring', arg_type=get_three_state_flag(), is_preview=True)

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

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

Expand Down
10 changes: 7 additions & 3 deletions src/aks-preview/azext_aks_preview/addonconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
CONST_VIRTUAL_NODE_SUBNET_NAME, CONST_INGRESS_APPGW_ADDON_NAME, CONST_INGRESS_APPGW_APPLICATION_GATEWAY_NAME, \
CONST_INGRESS_APPGW_SUBNET_CIDR, CONST_INGRESS_APPGW_APPLICATION_GATEWAY_ID, CONST_INGRESS_APPGW_SUBNET_ID, \
CONST_INGRESS_APPGW_WATCH_NAMESPACE, CONST_OPEN_SERVICE_MESH_ADDON_NAME, CONST_CONFCOM_ADDON_NAME, \
CONST_ACC_SGX_QUOTE_HELPER_ENABLED, CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME, CONST_SECRET_ROTATION_ENABLED, \
CONST_ACC_SGX_QUOTE_HELPER_ENABLED, CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME, CONST_SECRET_ROTATION_ENABLED, CONST_ROTATION_POLL_INTERVAL, \
CONST_KUBE_DASHBOARD_ADDON_NAME

logger = get_logger(__name__)
Expand All @@ -42,6 +42,7 @@ def enable_addons(cmd,
appgw_watch_namespace=None,
enable_sgxquotehelper=False,
enable_secret_rotation=False,
rotation_poll_interval=None,
no_wait=False,
enable_msi_auth_for_monitoring=False):
instance = client.get(resource_group_name, name)
Expand All @@ -57,7 +58,7 @@ def enable_addons(cmd,
appgw_subnet_cidr=appgw_subnet_cidr, appgw_id=appgw_id, appgw_subnet_id=appgw_subnet_id,
appgw_watch_namespace=appgw_watch_namespace,
enable_sgxquotehelper=enable_sgxquotehelper,
enable_secret_rotation=enable_secret_rotation, no_wait=no_wait)
enable_secret_rotation=enable_secret_rotation, rotation_poll_interval=rotation_poll_interval, no_wait=no_wait)

if CONST_MONITORING_ADDON_NAME in instance.addon_profiles and instance.addon_profiles[
CONST_MONITORING_ADDON_NAME].enabled:
Expand Down Expand Up @@ -141,6 +142,7 @@ def update_addons(cmd, # pylint: disable=too-many-branches,too-many-statements
appgw_watch_namespace=None,
enable_sgxquotehelper=False,
enable_secret_rotation=False,
rotation_poll_interval=None,
no_wait=False): # pylint: disable=unused-argument
# parse the comma-separated addons argument
addon_args = addons.split(',')
Expand Down Expand Up @@ -242,9 +244,11 @@ def update_addons(cmd, # pylint: disable=too-many-branches,too-many-statements
f'"az aks disable-addons -a azure-keyvault-secrets-provider -n {name} -g {resource_group_name}" '
'before enabling it again.')
addon_profile = ManagedClusterAddonProfile(
enabled=True, config={CONST_SECRET_ROTATION_ENABLED: "false"})
enabled=True, config={CONST_SECRET_ROTATION_ENABLED: "false", CONST_ROTATION_POLL_INTERVAL: "2m"})
if enable_secret_rotation:
addon_profile.config[CONST_SECRET_ROTATION_ENABLED] = "true"
if rotation_poll_interval is not None:
addon_profile.config[CONST_ROTATION_POLL_INTERVAL] = rotation_poll_interval
addon_profiles[CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME] = addon_profile
addon_profiles[addon] = addon_profile
else:
Expand Down
Loading

0 comments on commit fa2b1dd

Please sign in to comment.