Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Pending
* Vendor new SDK and bump API version to 2023-06-02-preview.
* Add `--network-dataplane` to the `az aks update` command.
* Support "VirtualMachines" agent pool type to `az aks create --vm-set-type` and `az aks nodepool add --vm-set-type`. This is internal use only, not for public preview.
* Add plugin CA support for `az aks mesh enable` commands for Azure Service Mesh.
Comment thread
FumingZhang marked this conversation as resolved.

0.5.149
+++++++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
"overlay migration, missing toggle": [
"test_aks_azure_cni_overlay_migration"
],
"service mesh, missing feature registration": [
"test_aks_azure_service_mesh_enable_disable",
Comment thread
deveshdama marked this conversation as resolved.
"test_aks_azure_service_mesh_with_ingress_gateway"
],
"slb to nat gateway": [
"test_aks_update_outbound_from_slb_to_natgateway"
],
Expand Down
22 changes: 22 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2561,6 +2561,28 @@
type: command
short-summary: Enable Azure Service Mesh.
long-summary: This command enables Azure Service Mesh in given cluster.
parameters:
- name: --key-vault-id
type: string
short-summary: The Azure Keyvault id with plugin CA info.
- name: --ca-cert-object-name
type: string
short-summary: Intermediate cert object name in the Azure Keyvault.
- name: --ca-key-object-name
type: string
short-summary: Intermediate key object name in the Azure Keyvault.
- name: --cert-chain-object-name
type: string
short-summary: Cert chain object name in the Azure Keyvault.
- name: --root-cert-object-name
type: string
short-summary: Root cert object name in the Azure Keyvault.
examples:
- name: Enable Azure Service Mesh with selfsigned CA.
text: az aks mesh enable --resource-group MyResourceGroup --name MyManagedCluster
- name: Enable Azure Service Mesh with plugin CA.
text: az aks mesh enable --resource-group MyResourceGroup --name MyManagedCluster --key-vault-id my-akv-id --ca-cert-object-name my-ca-cert --ca-key-object-name my-ca-key --cert-chain-object-name my-cert-chain --root-cert-object-name my-root-cert

"""

helps['aks mesh disable'] = """
Expand Down
9 changes: 8 additions & 1 deletion src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
validate_user,
validate_utc_offset,
validate_vm_set_type,
validate_vnet_subnet_id,
validate_vnet_subnet_id
)
from azure.cli.core.commands.parameters import (
edge_zone_type,
Expand Down Expand Up @@ -902,6 +902,13 @@ def load_arguments(self, _):
c.argument('ingress_gateway_type',
arg_type=get_enum_type(ingress_gateway_types))

with self.argument_context('aks mesh enable') as c:
c.argument('key_vault_id')
c.argument('ca_cert_object_name')
c.argument('ca_key_object_name')
c.argument('root_cert_object_name')
c.argument('cert_chain_object_name')


def _get_default_install_location(exe_name):
system = platform.system()
Expand Down
28 changes: 27 additions & 1 deletion src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
CONST_SPOT_EVICTION_POLICY_DELETE,
CONST_VIRTUAL_NODE_ADDON_NAME,
CONST_VIRTUAL_NODE_SUBNET_NAME,
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME,
)
from azext_aks_preview._helpers import (
get_cluster_snapshot_by_snapshot_id,
Expand Down Expand Up @@ -2403,8 +2404,28 @@ def aks_mesh_enable(
client,
resource_group_name,
name,
key_vault_id=None,
ca_cert_object_name=None,
ca_key_object_name=None,
root_cert_object_name=None,
cert_chain_object_name=None
):
return _aks_mesh_update(cmd, client, resource_group_name, name, enable_azure_service_mesh=True)
instance = client.get(resource_group_name, name)
addon_profiles = instance.addon_profiles
if key_vault_id is not None and ca_cert_object_name is not None and ca_key_object_name is not None and root_cert_object_name is not None and cert_chain_object_name is not None:
if not addon_profiles or not addon_profiles[CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME] or not addon_profiles[CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME].enabled:
raise CLIError('AzureKeyvaultSecretsProvider addon is required for Azure Service Mesh plugin certificate authority feature.')
Comment thread
deveshdama marked this conversation as resolved.

return _aks_mesh_update(cmd,
client,
resource_group_name,
name,
key_vault_id,
ca_cert_object_name,
ca_key_object_name,
root_cert_object_name,
cert_chain_object_name,
enable_azure_service_mesh=True)


def aks_mesh_disable(
Expand Down Expand Up @@ -2454,6 +2475,11 @@ def _aks_mesh_update(
client,
resource_group_name,
name,
key_vault_id=None,
ca_cert_object_name=None,
ca_key_object_name=None,
root_cert_object_name=None,
cert_chain_object_name=None,
enable_azure_service_mesh=None,
disable_azure_service_mesh=None,
enable_ingress_gateway=None,
Expand Down
31 changes: 31 additions & 0 deletions src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,37 @@ def update_azure_service_mesh_profile(self) -> ServiceMeshProfile:
)
updated = True

# deal with plugin ca
key_vault_id = self.raw_param.get("key_vault_id", None)
ca_cert_object_name = self.raw_param.get("ca_cert_object_name", None)
ca_key_object_name = self.raw_param.get("ca_key_object_name", None)
root_cert_object_name = self.raw_param.get("root_cert_object_name", None)
cert_chain_object_name = self.raw_param.get("cert_chain_object_name", None)

if any([key_vault_id, ca_cert_object_name, ca_key_object_name, root_cert_object_name, cert_chain_object_name]):
if key_vault_id is None:
raise InvalidArgumentValueError('--key-vault-id is required to use Azure Service Mesh plugin CA feature.')
if ca_cert_object_name is None:
raise InvalidArgumentValueError('--ca-cert-object-name is required to use Azure Service Mesh plugin CA feature.')
if ca_key_object_name is None:
raise InvalidArgumentValueError('--ca-key-object-name is required to use Azure Service Mesh plugin CA feature.')
if root_cert_object_name is None:
raise InvalidArgumentValueError('--root-cert-object-name is required to use Azure Service Mesh plugin CA feature.')
if cert_chain_object_name is None:
raise InvalidArgumentValueError('--cert-chain-object-name is required to use Azure Service Mesh plugin CA feature.')

if enable_asm and all([key_vault_id, ca_cert_object_name, ca_key_object_name, root_cert_object_name, cert_chain_object_name]):
if new_profile.istio.certificate_authority is None:
new_profile.istio.certificate_authority = self.models.IstioCertificateAuthority()
if new_profile.istio.certificate_authority.plugin is None:
new_profile.istio.certificate_authority.plugin = self.models.IstioPluginCertificateAuthority()
new_profile.istio.certificate_authority.plugin.key_vault_id = key_vault_id
new_profile.istio.certificate_authority.plugin.cert_object_name = ca_cert_object_name
new_profile.istio.certificate_authority.plugin.key_object_name = ca_key_object_name
new_profile.istio.certificate_authority.plugin.root_cert_object_name = root_cert_object_name
new_profile.istio.certificate_authority.plugin.cert_chain_object_name = cert_chain_object_name
updated = True

if updated:
return new_profile
else:
Expand Down
Loading