Skip to content

Commit

Permalink
Merge pull request Azure#2 from Azure/master
Browse files Browse the repository at this point in the history
Sync with the official repo
  • Loading branch information
ShichaoQiu committed Jan 10, 2020
2 parents f30a597 + f409def commit 46cfb9c
Show file tree
Hide file tree
Showing 55 changed files with 11,485 additions and 218 deletions.
82 changes: 40 additions & 42 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,50 +66,48 @@ jobs:
python ./scripts/ci/test_index.py -v
displayName: "Verify Extensions Index"
# - job: TestsPython27
# displayName: "Tests Python 2.7"
# pool:
# vmImage: 'ubuntu-16.04'
# steps:
# - task: UsePythonVersion@0
# displayName: 'Use Python 2.7'
# inputs:
# versionSpec: 2.7
# - task: Bash@3
# displayName: "Tests Python 2.7"
# inputs:
# targetType: 'filePath'
# filePath: scripts/ci/test_source.sh
- job: SourceTests
displayName: "Integration Tests, Build Tests"
pool:
vmImage: 'ubuntu-16.04'
strategy:
matrix:
Python36:
python.version: '3.6'
Python38:
python.version: '3.8'
steps:
- task: UsePythonVersion@0
displayName: 'Use Python $(python.version)'
inputs:
versionSpec: '$(python.version)'
- bash: pip install wheel==0.30.0
displayName: 'Install wheel==0.30.0'
- bash: ./scripts/ci/test_source.sh
displayName: 'Run integration test and build test'
env:
ADO_PULL_REQUEST_LATEST_COMMIT: $(System.PullRequest.SourceCommitId)
ADO_PULL_REQUEST_TARGET_BRANCH: $(System.PullRequest.TargetBranch)

- job: LintModifiedExtensions
displayName: "CLI Linter on Modified Extensions"
pool:
vmImage: 'ubuntu-16.04'
steps:
- task: UsePythonVersion@0
displayName: 'Use Python 3.6'
inputs:
versionSpec: 3.6
- bash: |
set -ev
# - job: TestsPython37
# displayName: "Tests Python 3.7"
# pool:
# vmImage: 'ubuntu-16.04'
# steps:
# - task: UsePythonVersion@0
# displayName: 'Use Python 3.7'
# inputs:
# versionSpec: 3.7
# - task: Bash@3
# displayName: "Tests Python 3.7"
# inputs:
# targetType: 'filePath'
# filePath: scripts/ci/test_source.sh
# prepare and activate virtualenv
pip install virtualenv
python -m virtualenv venv/
source ./venv/bin/activate
# - job: LintModifiedExtensions
# displayName: "CLI Linter on Modified Extensions"
# pool:
# vmImage: 'ubuntu-16.04'
# steps:
# - task: UsePythonVersion@0
# displayName: 'Use Python 3.7'
# inputs:
# versionSpec: 3.7
# - task: Bash@3
# displayName: "CLI Linter on Modified Extension"
# inputs:
# targetType: 'filePath'
# filePath: scripts/ci/verify_modified_index.sh
./scripts/ci/verify_modified_index.sh
displayName: "CLI Linter on Modified Extension"
- job: IndexRefDocVerify
displayName: "Verify Ref Docs"
Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ disable=missing-docstring,

[TYPECHECK]
# For Azure CLI extensions, we ignore some import errors as they'll be available in the environment of the CLI
ignored-modules=azure,azure.cli,azure.cli.core,azure.cli.core.commands,knack,msrestazure,argcomplete
ignored-modules=azure,azure.cli,azure.cli.core,azure.cli.core.commands,knack,msrestazure,argcomplete,azure_devtools

[FORMAT]
max-line-length=120
Expand Down
10 changes: 10 additions & 0 deletions scripts/ci/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import tempfile
import unittest
import shutil
import shlex
from subprocess import check_output, check_call, CalledProcessError

import mock
Expand All @@ -34,6 +35,15 @@
if commit_range and not check_output(['git', '--no-pager', 'diff', '--name-only', commit_range, '--', src_d_full]):
continue

# Running in Azure DevOps
cmd_tpl = 'git --no-pager diff --name-only origin/{commit_start} {commit_end} {code_dir}'
ado_branch_last_commit = os.environ.get('ADO_PULL_REQUEST_LATEST_COMMIT')
ado_target_branch = os.environ.get('ADO_PULL_REQUEST_TARGET_BRANCH')
if ado_branch_last_commit and ado_target_branch:
cmd = cmd_tpl.format(commit_start=ado_target_branch, commit_end=ado_branch_last_commit, code_dir=src_d_full)
if not check_output(shlex.split(cmd)):
continue

# Find the package and check it has tests
if pkg_name and os.path.isdir(os.path.join(src_d_full, pkg_name, 'tests')):
ALL_TESTS.append((pkg_name, src_d_full))
Expand Down
11 changes: 10 additions & 1 deletion src/aks-preview/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@

Release History
===============
0.4.26
+++++
* Update to use 2020-01-01 api-version
* Support cluster creation with server side encryption using customer managed key

0.4.25
+++++
* List credentials for different users via parameter `--user`

0.4.24
+++++
* added custom header support

0.4.23
+++++
* Enable GA support of apiserver authorized IP ranges via paramater `--api-server-authorized-ip-ranges` in `az aks create` and `az aks update`
* Enable GA support of apiserver authorized IP ranges via parameter `--api-server-authorized-ip-ranges` in `az aks create` and `az aks update`

0.4.21
+++++
Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/azext_aks_preview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ContainerServiceCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
register_resource_type('latest', CUSTOM_MGMT_AKS_PREVIEW, '2019-10-01')
register_resource_type('latest', CUSTOM_MGMT_AKS_PREVIEW, '2020-01-01')

acs_custom = CliCommandType(operations_tmpl='azext_aks_preview.custom#{}')
super(ContainerServiceCommandsLoader, self).__init__(cli_ctx=cli_ctx,
Expand Down
9 changes: 8 additions & 1 deletion src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
- name: --node-osdisk-size
type: int
short-summary: Size in GB of the OS disk for each node in the node pool. Minimum 30 GB.
- name: --node-osdisk-diskencryptionset-id
type: string
short-summary: ResourceId of the disk encryption set to use for enabling encryption at rest.
- name: --kubernetes-version -k
type: string
short-summary: Version of Kubernetes to use for creating the cluster, such as "1.7.12" or "1.8.7".
Expand Down Expand Up @@ -210,7 +213,8 @@
text: az aks create -g MyResourceGroup -n MyManagedCluster --load-balancer-sku basic --vm-set-type AvailabilitySet
- name: Create a kubernetes cluster with authorized apiserver IP ranges.
text: az aks create -g MyResourceGroup -n MyManagedCluster --api-server-authorized-ip-ranges 193.168.1.0/24,194.168.1.0/24,195.168.1.0
- name: Create a kubernetes cluster with server side encryption using your owned key.
text: az aks create -g MyResourceGroup -n MyManagedCluster --node-osdisk-diskencryptionset-id <disk-encryption-set-resource-id>
""".format(sp_cache=AKS_SERVICE_PRINCIPAL_CACHE)

Expand Down Expand Up @@ -523,6 +527,9 @@
- name: --admin -a
type: bool
short-summary: "Get cluster administrator credentials. Default: cluster user credentials."
- name: --user -u
type: string
short-summary: "Get credentials for the user. Only valid when --admin is False. Default: cluster user credentials."
- name: --file -f
type: string
short-summary: Kubernetes configuration file to update. Use "-" to print YAML to stdout instead.
Expand Down
3 changes: 2 additions & 1 deletion src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
validate_ssh_key, validate_max_pods, validate_nodes_count, validate_ip_ranges,
validate_nodepool_name, validate_vm_set_type, validate_load_balancer_sku,
validate_load_balancer_outbound_ips, validate_load_balancer_outbound_ip_prefixes,
validate_taints, validate_priority, validate_eviction_policy, validate_acr)
validate_taints, validate_priority, validate_eviction_policy, validate_acr, validate_user)


def load_arguments(self, _):
Expand Down Expand Up @@ -142,6 +142,7 @@ def load_arguments(self, _):

with self.argument_context('aks get-credentials') as c:
c.argument('admin', options_list=['--admin', '-a'], default=False)
c.argument('user', options_list=['--user', '-u'], default='clusterUser', validator=validate_user)
c.argument('path', options_list=['--file', '-f'], type=file_type, completer=FilesCompleter(),
default=os.path.join(os.path.expanduser('~'), '.kube', 'config'))

Expand Down
6 changes: 6 additions & 0 deletions src/aks-preview/azext_aks_preview/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,9 @@ def validate_eviction_policy(namespace):
def validate_acr(namespace):
if namespace.attach_acr and namespace.detach_acr:
raise CLIError('Cannot specify "--attach-acr" and "--detach-acr" at the same time.')


def validate_user(namespace):
if namespace.user.lower() != "clusteruser" and \
namespace.user.lower() != "clustermonitoringuser":
raise CLIError("--user can only be clusterUser or clusterMonitoringUser")
49 changes: 28 additions & 21 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,25 @@
KeyCredential,
ServicePrincipalCreateParameters,
GetObjectsParameters)
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ContainerServiceLinuxProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ManagedClusterWindowsProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ContainerServiceNetworkProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ManagedClusterServicePrincipalProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ContainerServiceSshConfiguration
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ContainerServiceSshPublicKey
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ManagedCluster
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ManagedClusterAADProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ManagedClusterAddonProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ManagedClusterAgentPoolProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import AgentPool
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ContainerServiceStorageProfileTypes
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ManagedClusterLoadBalancerProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ManagedClusterLoadBalancerProfileManagedOutboundIPs
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ManagedClusterLoadBalancerProfileOutboundIPPrefixes
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ManagedClusterLoadBalancerProfileOutboundIPs
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ResourceReference
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ManagedClusterIdentity
from .vendored_sdks.azure_mgmt_preview_aks.v2019_10_01.models import ManagedClusterAPIServerAccessProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ContainerServiceLinuxProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ManagedClusterWindowsProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ContainerServiceNetworkProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ManagedClusterServicePrincipalProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ContainerServiceSshConfiguration
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ContainerServiceSshPublicKey
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ManagedCluster
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ManagedClusterAADProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ManagedClusterAddonProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ManagedClusterAgentPoolProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import AgentPool
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ContainerServiceStorageProfileTypes
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ManagedClusterLoadBalancerProfile
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ManagedClusterLoadBalancerProfileManagedOutboundIPs
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ManagedClusterLoadBalancerProfileOutboundIPPrefixes
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ManagedClusterLoadBalancerProfileOutboundIPs
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ResourceReference
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ManagedClusterIdentity
from .vendored_sdks.azure_mgmt_preview_aks.v2020_01_01.models import ManagedClusterAPIServerAccessProfile
from ._client_factory import cf_resource_groups
from ._client_factory import get_auth_management_client
from ._client_factory import get_graph_rbac_management_client
Expand Down Expand Up @@ -643,6 +643,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
kubernetes_version='',
node_vm_size="Standard_DS2_v2",
node_osdisk_size=0,
node_osdisk_diskencryptionset_id='',
node_count=3,
nodepool_name="nodepool1",
service_principal=None, client_secret=None,
Expand Down Expand Up @@ -860,6 +861,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
aad_profile=aad_profile,
enable_pod_security_policy=bool(enable_pod_security_policy),
identity=identity,
disk_encryption_set_id=node_osdisk_diskencryptionset_id,
api_server_access_profile=api_server_access_profile)

if node_resource_group:
Expand Down Expand Up @@ -1069,14 +1071,19 @@ def aks_get_credentials(cmd, # pylint: disable=unused-argument
resource_group_name,
name,
admin=False,
user='clusterUser',
path=os.path.join(os.path.expanduser('~'), '.kube', 'config'),
overwrite_existing=False):
credentialResults = None
if admin:
credentialResults = client.list_cluster_admin_credentials(resource_group_name, name)
else:
credentialResults = client.list_cluster_user_credentials(resource_group_name, name)

if user.lower() == 'clusteruser':
credentialResults = client.list_cluster_user_credentials(resource_group_name, name)
elif user.lower() == 'clustermonitoringuser':
credentialResults = client.list_cluster_monitoring_user_credentials(resource_group_name, name)
else:
raise CLIError("The user is invalid.")
if not credentialResults:
raise CLIError("No Kubernetes credentials found.")

Expand Down
Loading

0 comments on commit 46cfb9c

Please sign in to comment.