Skip to content

Commit

Permalink
[AKS] Add ossku parameter for cluster and nodepool creation (#3375)
Browse files Browse the repository at this point in the history
* [AKS] Add ossku parameter for cluster and nodepool creation

* Rename arg to os-sku, add completer, update help

* Fix static analysis error

* Rerun ossku tests with edge build of az-cli
  • Loading branch information
hbeberman authored May 20, 2021
1 parent f19ddbe commit 56505e3
Show file tree
Hide file tree
Showing 9 changed files with 3,072 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.5.14
+++++
* Add os-sku argument for cluster and nodepool creation

0.5.13
+++++
* Add compatible logic for the track 2 migration of resource dependence
Expand Down
7 changes: 7 additions & 0 deletions src/aks-preview/azext_aks_preview/_completers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ def get_vm_sizes(cli_ctx, location):
return cf_compute_service(cli_ctx).virtual_machine_sizes.list(location)


@Completer
def get_ossku_completion_list(cmd, prefix, namespace, **kwargs): # pylint: disable=unused-argument
"""Return the list of allowed os-sku values"""

return ["Ubuntu", "CBLMariner"]


def _get_location(cli_ctx, namespace):
"""
Return an Azure location by using an explicit `--location` argument, then by `--resource-group`, and
Expand Down
10 changes: 10 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@
- name: --ppg
type: string
short-summary: The ID of a PPG.
- name: --os-sku
type: string
short-summary: The os-sku of the agent node pool. Ubuntu or CBLMariner.
- name: --enable-fips-image
type: bool
short-summary: Use FIPS-enabled OS on agent nodes.
Expand Down Expand Up @@ -373,6 +376,8 @@
text: az aks create -g MyResourceGroup -n MyManagedCluster --assign-identity <control-plane-identity-resource-id> --assign-kubelet-identity <kubelet-identity-resource-id>
- name: Create a kubernetes cluster with Azure RBAC enabled.
text: az aks create -g MyResourceGroup -n MyManagedCluster --enable-aad --enable-azure-rbac
- name: Create a kubernetes cluster with a specific os-sku
text: az aks create -g MyResourceGroup -n MyManagedCluster --os-sku Ubuntu
""".format(sp_cache=AKS_SERVICE_PRINCIPAL_CACHE)

Expand Down Expand Up @@ -859,6 +864,9 @@
- name: --os-type
type: string
short-summary: The OS Type. Linux or Windows.
- name: --os-sku
type: string
short-summary: The os-sku of the agent node pool. Ubuntu or CBLMariner.
- name: --enable-fips-image
type: bool
short-summary: Use FIPS-enabled OS on agent nodes.
Expand Down Expand Up @@ -915,6 +923,8 @@
text: az aks nodepool add -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --node-osdisk-type Ephemeral --node-osdisk-size 48
- name: Create a nodepool with EncryptionAtHost enabled.
text: az aks nodepool add -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --enable-encryption-at-host
- name: Create a nodepool cluster with a specific os-sku
text: az aks nodepool add -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster --os-sku Ubuntu
"""

helps['aks nodepool scale'] = """
Expand Down
4 changes: 3 additions & 1 deletion src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from knack.arguments import CLIArgumentType

from ._completers import (
get_vm_size_completion_list, get_k8s_versions_completion_list, get_k8s_upgrades_completion_list)
get_vm_size_completion_list, get_k8s_versions_completion_list, get_k8s_upgrades_completion_list, get_ossku_completion_list)
from ._validators import (
validate_cluster_autoscaler_profile, validate_create_parameters, validate_k8s_version, validate_linux_host_name,
validate_ssh_key, validate_nodes_count, validate_ip_ranges,
Expand Down Expand Up @@ -60,6 +60,7 @@ def load_arguments(self, _):
help='Node pool name, upto 12 alphanumeric characters', validator=validate_nodepool_name)
c.argument('nodepool_tags', nargs='*', validator=validate_nodepool_tags, help='space-separated tags: key[=value] [key[=value] ...]. Use "" to clear existing tags.')
c.argument('nodepool_labels', nargs='*', validator=validate_nodepool_labels, help='space-separated labels: key[=value] [key[=value] ...]. You can not change the node labels through CLI after creation. See https://aka.ms/node-labels for syntax of labels.')
c.argument('os_sku', type=str, options_list=['--os-sku'], completer=get_ossku_completion_list)
c.argument('ssh_key_value', required=False, type=file_type, default=os.path.join('~', '.ssh', 'id_rsa.pub'),
completer=FilesCompleter(), validator=validate_ssh_key)
c.argument('aad_client_app_id')
Expand Down Expand Up @@ -206,6 +207,7 @@ def load_arguments(self, _):
c.argument('node_vm_size', options_list=['--node-vm-size', '-s'], completer=get_vm_size_completion_list)
c.argument('max_pods', type=int, options_list=['--max-pods', '-m'])
c.argument('os_type', type=str)
c.argument('os_sku', type=str, options_list=['--os-sku'], completer=get_ossku_completion_list)
c.argument('enable_fips_image', action='store_true', is_preview=True)
c.argument('enable_cluster_autoscaler', options_list=["--enable-cluster-autoscaler", "-e"], action='store_true')
c.argument('node_taints', type=str, validator=validate_taints)
Expand Down
4 changes: 4 additions & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
enable_vmss=None,
vm_set_type=None,
skip_subnet_role_assignment=False,
os_sku=None,
enable_fips_image=False,
enable_cluster_autoscaler=False,
cluster_autoscaler_profile=None,
Expand Down Expand Up @@ -1080,6 +1081,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
count=int(node_count),
vm_size=node_vm_size,
os_type="Linux",
os_sku=os_sku,
mode="System",
vnet_subnet_id=vnet_subnet_id,
pod_subnet_id=pod_subnet_id,
Expand Down Expand Up @@ -2974,6 +2976,7 @@ def aks_agentpool_add(cmd, # pylint: disable=unused-argument,too-many-local
ppg=None,
max_pods=0,
os_type="Linux",
os_sku=None,
enable_fips_image=False,
min_count=None,
max_count=None,
Expand Down Expand Up @@ -3024,6 +3027,7 @@ def aks_agentpool_add(cmd, # pylint: disable=unused-argument,too-many-local
count=int(node_count),
vm_size=node_vm_size,
os_type=os_type,
os_sku=os_sku,
enable_fips=enable_fips_image,
storage_profile=ContainerServiceStorageProfileTypes.managed_disks,
vnet_subnet_id=vnet_subnet_id,
Expand Down
Loading

0 comments on commit 56505e3

Please sign in to comment.