Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AKS]customizing node resource group #636

Merged
merged 5 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
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.3.2
+++++
* Add support of customizing node resource group

0.3.1
+++++
* Add support of pod security policy.
Expand Down
7 changes: 6 additions & 1 deletion src/aks-preview/azext_aks_preview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ def load_command_table(self, args):
return self.command_table

def load_arguments(self, command):
super(ContainerServiceCommandsLoader, self).load_arguments(command)
from sys import version_info
if version_info[0] < 3:
super(ContainerServiceCommandsLoader, self).load_arguments(command)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax works on Python 3 as well. There's no need for this if statement.

Copy link
Member Author

@zqingqing1 zqingqing1 Apr 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about that? Since my teammate and I have problem to use super(ContainerServiceCommandsLoader, self).load_arguments(command), It failed with

The command failed with an unexpected error. Here is the traceback:

super(type, obj): obj must be an instance or subtype of type
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.0.63/libexec/lib/python3.7/site-packages/knack/cli.py", line 206, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/local/Cellar/azure-cli/2.0.63/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 445, in execute
    self.commands_loader.load_arguments(command)
  File "/usr/local/Cellar/azure-cli/2.0.63/libexec/lib/python3.7/site-packages/azure/cli/core/__init__.py", line 268, in load_arguments
    loader.load_arguments(command)  # this adds entries to the argument registries
  File "/Users/qizhe/cli-extension/azure-cli-extensions/src/aks-preview/azext_aks_preview/__init__.py", line 34, in load_arguments
    super(ContainerServiceCommandsLoader, self).load_arguments(command)
TypeError: super(type, obj): obj must be an instance or subtype of type

so I decide to use the if else statement to unblock us.

Copy link
Member

@tjprescott tjprescott Apr 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nowhere else in the CLI or any extension does anyone do this, so the true problem is likely something else. I mean, this isn't the initial release of this extension, and it was working just like this before. That being said, I have no problem merging this, but it shouldn't be necessary.

else:
super().load_arguments(command)

from ._params import load_arguments
load_arguments(self, command)

Expand Down
3 changes: 3 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@
- name: --enable-pod-security-policy
type: bool
short-summary: (PREVIEW) Enable pod security policy.
- name: --node-resource-group
type: string
short-summary: The node resource group is the resource group where all customer's resources will be created in, such as virtual machines.
examples:
- name: Create a Kubernetes cluster with an existing SSH public key.
text: az aks create -g MyResourceGroup -n MyManagedCluster --ssh-key-value /path/to/publickey
Expand Down
1 change: 1 addition & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def load_arguments(self, _):
c.argument('enable_vmss', action='store_true')
c.argument('node_zones', zones_type, options_list='--node-zones', help='(PREVIEW) Space-separated list of availability zones where agent nodes will be placed.')
c.argument('enable_pod_security_policy', action='store_true')
c.argument('node_resource_group')

with self.argument_context('aks update') as c:
c.argument('enable_cluster_autoscaler', options_list=["--enable-cluster-autoscaler", "-e"], action='store_true')
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 @@ -385,6 +385,7 @@ def aks_create(cmd, client, resource_group_name, name, ssh_key_value, # pylint:
node_zones=None,
generate_ssh_keys=False, # pylint: disable=unused-argument
enable_pod_security_policy=False,
node_resource_group=None,
no_wait=False):
if not no_ssh_key:
try:
Expand Down Expand Up @@ -515,6 +516,9 @@ def aks_create(cmd, client, resource_group_name, name, ssh_key_value, # pylint:
aad_profile=aad_profile,
enable_pod_security_policy=bool(enable_pod_security_policy))

if node_resource_group:
mc.node_resource_group = node_resource_group

# Due to SPN replication latency, we do a few retries here
max_retry = 30
retry_exception = Exception(None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class ManagedCluster(Resource):
'provisioning_state': {'readonly': True},
'max_agent_pools': {'readonly': True},
'fqdn': {'readonly': True},
'node_resource_group': {'readonly': True},
}

_attribute_map = {
Expand Down Expand Up @@ -128,7 +127,7 @@ def __init__(self, **kwargs):
self.windows_profile = kwargs.get('windows_profile', None)
self.service_principal_profile = kwargs.get('service_principal_profile', None)
self.addon_profiles = kwargs.get('addon_profiles', None)
self.node_resource_group = None
self.node_resource_group = kwargs.get('node_resource_group', None)
self.enable_rbac = kwargs.get('enable_rbac', None)
self.enable_pod_security_policy = kwargs.get('enable_pod_security_policy', None)
self.network_profile = kwargs.get('network_profile', None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class ManagedCluster(Resource):
'provisioning_state': {'readonly': True},
'max_agent_pools': {'readonly': True},
'fqdn': {'readonly': True},
'node_resource_group': {'readonly': True},
}

_attribute_map = {
Expand All @@ -116,7 +115,7 @@ class ManagedCluster(Resource):
'api_server_authorized_ip_ranges': {'key': 'properties.apiServerAuthorizedIPRanges', 'type': '[str]'},
}

def __init__(self, *, location: str, tags=None, kubernetes_version: str=None, dns_prefix: str=None, agent_pool_profiles=None, linux_profile=None, windows_profile=None, service_principal_profile=None, addon_profiles=None, enable_rbac: bool=None, enable_pod_security_policy: bool=None, network_profile=None, aad_profile=None, api_server_authorized_ip_ranges=None, **kwargs) -> None:
def __init__(self, *, location: str, tags=None, kubernetes_version: str=None, dns_prefix: str=None, node_resource_group: str=None, agent_pool_profiles=None, linux_profile=None, windows_profile=None, service_principal_profile=None, addon_profiles=None, enable_rbac: bool=None, enable_pod_security_policy: bool=None, network_profile=None, aad_profile=None, api_server_authorized_ip_ranges=None, **kwargs) -> None:
super(ManagedCluster, self).__init__(location=location, tags=tags, **kwargs)
self.provisioning_state = None
self.max_agent_pools = None
Expand All @@ -128,7 +127,7 @@ def __init__(self, *, location: str, tags=None, kubernetes_version: str=None, dn
self.windows_profile = windows_profile
self.service_principal_profile = service_principal_profile
self.addon_profiles = addon_profiles
self.node_resource_group = None
self.node_resource_group = node_resource_group
self.enable_rbac = enable_rbac
self.enable_pod_security_policy = enable_pod_security_policy
self.network_profile = network_profile
Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open as open1
from setuptools import setup, find_packages

VERSION = "0.3.1"
VERSION = "0.3.2"
CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
Expand Down
8 changes: 4 additions & 4 deletions src/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
],
"aks-preview": [
{
"downloadUrl": "https://azurecliaks.blob.core.windows.net/azure-cli-extension/aks_preview-0.2.3-py2.py3-none-any.whl",
"filename": "aks_preview-0.2.3-py2.py3-none-any.whl",
"downloadUrl": "https://azurecliaks.blob.core.windows.net/azure-cli-extension/aks_preview-0.3.2-py2.py3-none-any.whl",
"filename": "aks_preview-0.3.2-py2.py3-none-any.whl",
"metadata": {
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.0.49",
Expand Down Expand Up @@ -88,9 +88,9 @@
"metadata_version": "2.0",
"name": "aks-preview",
"summary": "Provides a preview for upcoming AKS features",
"version": "0.2.3"
"version": "0.3.2"
},
"sha256Digest": "455d3c5a99627ae8b5870897852c09b41056d42d4a46719134cb4852754fc9d2"
"sha256Digest": "5839622f96bd4e42c4542eefb55a22c589f0d858924be790e1d5818e95912881"
},
{
"downloadUrl": "https://azurecliaks.blob.core.windows.net/azure-cli-extension/aks_preview-0.3.0-py2.py3-none-any.whl",
Expand Down