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

[k8s-extension] Release v0.4.3 #3491

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
828f9d3
Create pull.yml
jonathan-innis Mar 10, 2021
1436bfc
Update pull.yml
jonathan-innis Mar 10, 2021
6cffd96
Update azure-pipelines.yml
jonathan-innis Mar 10, 2021
db0f4bd
Initial commit of k8s-extension
jonathan-innis Mar 10, 2021
3e2ea64
Update pipelines file
jonathan-innis Mar 10, 2021
9bbc0e4
Update CODEOWNERS
jonathan-innis Mar 10, 2021
8d46cbc
Update private preview pipelines
jonathan-innis Mar 11, 2021
6c3ba41
Remove open service mesh from public release
jonathan-innis Mar 11, 2021
a98e996
Merge pull request #6 from Azure/master
jonathan-innis Mar 11, 2021
43c6796
Update pipeline files
jonathan-innis Mar 11, 2021
009a83e
Update public extension pipeline
jonathan-innis Mar 12, 2021
8e058c5
Change condition variable
jonathan-innis Mar 12, 2021
dea40c1
Add version to public preview/private preview
jonathan-innis Mar 12, 2021
69269e0
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
jonathan-innis Mar 12, 2021
e81e010
Update pipelines
jonathan-innis Mar 12, 2021
9621a48
Add different testing based on private branch
jonathan-innis Mar 12, 2021
862a035
Add annotations to extension model
jonathan-innis Mar 12, 2021
e1c3d12
Update k8s-custom-pipelines.yml
jonathan-innis Mar 15, 2021
3e309bf
Update SDKs with Updated Swagger Spec for 2020-07-01-preview (#13)
jonathan-innis Mar 16, 2021
1df2ef5
remove py2 bdist support
jonathan-innis Mar 16, 2021
054a903
Add custom table formatting
jonathan-innis Mar 16, 2021
b298252
Remove unnecessary files
jonathan-innis Mar 16, 2021
afb4046
Fix style issues
jonathan-innis Mar 16, 2021
49b7eac
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 17, 2021
a13304d
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 17, 2021
aa078b0
Merge branch 'release' into k8s-extension/public
jonathan-innis Mar 17, 2021
21dff06
Fix branch based on comments
jonathan-innis Mar 17, 2021
93919f2
Update identity piece manually
jonathan-innis Mar 17, 2021
a88127a
Merge branch 'k8s-extension/public' of github.com:AzureArcForKubernet…
jonathan-innis Mar 17, 2021
7e40b3a
Don't handle defaults at the CLI level
jonathan-innis Mar 17, 2021
483202c
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 17, 2021
d1befa8
Remove defaults from CLI client
jonathan-innis Mar 17, 2021
c7bd93f
Merge branch 'release' into k8s-extension/public
jonathan-innis Mar 17, 2021
076827c
Check null target namespace with namespace scope
jonathan-innis Mar 17, 2021
550eea1
Update style
jonathan-innis Mar 17, 2021
1a17f1b
Merge branch 'k8s-extension/public' of github.com:AzureArcForKubernet…
jonathan-innis Mar 17, 2021
fbab3be
Add cassandra operator and location to model
jonathan-innis Mar 17, 2021
9aade9f
Stage Public Version of k8s-extension 0.2.0 for official release (#15)
jonathan-innis Mar 18, 2021
7f79cfb
Remove custom pipelines file
jonathan-innis Mar 18, 2021
1337996
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 19, 2021
f6e68e9
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 20, 2021
f57af40
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 20, 2021
e75f329
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 23, 2021
a47b63a
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 23, 2021
6c4e0e6
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 24, 2021
bb88024
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 24, 2021
9f06b49
Update extension description, remove private const
jonathan-innis Mar 24, 2021
a063594
Merge branch 'release' into k8s-extension/public
jonathan-innis Mar 24, 2021
eb4c58b
Update pipeline file
jonathan-innis Mar 24, 2021
20d809c
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 25, 2021
9524cda
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 25, 2021
16489b8
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 26, 2021
ee395f2
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 26, 2021
fbd331c
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 27, 2021
9c86220
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 27, 2021
89828c5
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Mar 31, 2021
bed066c
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Mar 31, 2021
8011213
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Apr 1, 2021
491c1e5
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Apr 1, 2021
cfd267d
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Apr 2, 2021
b9d1778
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Apr 2, 2021
3290f6e
Disable refs docs
jonathan-innis Apr 2, 2021
22c8e92
Update to include better create warning logs and remove update contex…
jonathan-innis Apr 2, 2021
12212f1
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Apr 3, 2021
010e9a8
Merge branch 'release' of https://github.com/AzureArcForKubernetes/az…
Apr 3, 2021
6bbf418
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Apr 11, 2021
df82dd8
Fix k8s-extension conflict with private version
jonathan-innis Apr 14, 2021
0228851
Fix style errors
jonathan-innis Apr 14, 2021
db4c5b2
Fix filename
jonathan-innis Apr 14, 2021
2971d69
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Apr 18, 2021
5077192
add customization for microsoft.azureml.kubernetes (#23)
yuyue9284 Apr 23, 2021
dc0c178
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
Apr 25, 2021
3d15151
Add E2E Testing from Separate branch into internal code (#26)
jonathan-innis Apr 26, 2021
1ded405
Inference CLI validation for Scoring FE (#24)
liakaz Apr 27, 2021
53303d5
legal warning added (#27)
liakaz Apr 27, 2021
3370264
Remove deprecated method logger.warn
jonathan-innis Apr 27, 2021
4c66aef
Update k8s-custom-pipelines.yml for Azure Pipelines
jonathan-innis Apr 27, 2021
e8651f2
Update k8s-custom-pipelines.yml for Azure Pipelines
jonathan-innis Apr 27, 2021
9de1e4e
Add Azure Defender to E2E testing (#28)
jonathan-innis Apr 28, 2021
9c0317d
Add configuration testing
jonathan-innis Apr 28, 2021
4c21482
Fix pipeline failures
jonathan-innis Apr 28, 2021
3e2fb15
Make test script more intuitive
jonathan-innis Apr 29, 2021
4dca64d
Remove parameter from testing
jonathan-innis Apr 29, 2021
c93e958
Fix wrong location for k8s config whl
jonathan-innis Apr 29, 2021
27e9b4a
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
jonathan-innis May 3, 2021
cb30f9d
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
May 3, 2021
7276f4a
Merge branch 'k8s-extension/public' of github.com:AzureArcForKubernet…
jonathan-innis May 6, 2021
3dafc08
Fix pip upgrade issue
jonathan-innis May 6, 2021
c5bd1c2
Fix pip install upgrade issue
jonathan-innis May 6, 2021
d9e8760
Fix pip install issue
jonathan-innis May 6, 2021
9709504
delete resurce in testcase (#29)
yuyue9284 May 7, 2021
3f620a8
Check Provider is Registered with Subscription Before Making Requests…
jonathan-innis May 7, 2021
cf95612
only validate scoring fe when inference is enabled (#31)
yuyue9284 May 11, 2021
fea6e00
Provider registration case insensitive
jonathan-innis May 11, 2021
877868c
do not validate against scoring fe if inference is not enabled. (#33)
yuyue9284 May 13, 2021
7ea157b
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
jonathan-innis May 13, 2021
a50ade7
Merge branch 'k8s-extension/public' of github.com:AzureArcForKubernet…
jonathan-innis May 13, 2021
9b1bedd
Add OSM as Public Preview Extension (#34)
jonathan-innis May 13, 2021
257dbf3
Fix release train check in update
jonathan-innis May 14, 2021
a203575
Parallelize E2E Testing (#36)
jonathan-innis May 14, 2021
8d65189
Fix azureml deletion
jonathan-innis May 14, 2021
ec14c6d
Merge branch 'k8s-extension/public' of github.com:AzureArcForKubernet…
jonathan-innis May 14, 2021
918bc02
Fix private build (#40)
jonathan-innis May 21, 2021
8b2490d
change amlk8s to amlarc (#42)
yuyue9284 May 25, 2021
724acde
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
jonathan-innis May 27, 2021
9100ff5
Servicebus client model changes (#44)
jonathan-innis May 27, 2021
6955567
Read SSL cert and key from files (#38)
liakaz Jun 2, 2021
a46235b
Upgrade release version
jonathan-innis Jun 2, 2021
b0f25af
Merge branch 'master' of https://github.com/Azure/azure-cli-extension…
jonathan-innis Jun 2, 2021
2889d53
Liakaz/inference read ssl from file (#47)
liakaz Jun 3, 2021
67babd8
Fix style issues (#51)
jonathan-innis Jun 4, 2021
590e642
Fixed scoring fe related extension param names (#49)
liakaz Jun 8, 2021
e4abec6
Remove unneeded files
jonathan-innis Jun 10, 2021
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
5 changes: 5 additions & 0 deletions src/k8s-extension/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Release History
===============

0.4.3
++++++++++++++++++
* Add SSL support for AzureML


0.4.2
++++++++++++++++++

Expand Down
2 changes: 0 additions & 2 deletions src/k8s-extension/azext_k8s_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import json
from knack.log import get_logger

from msrestazure.azure_exceptions import CloudError

from azure.cli.core.azclierror import ResourceNotFoundError, MutuallyExclusiveArgumentError, \
InvalidArgumentValueError, CommandNotFoundError, RequiredArgumentMissingError
from azure.cli.core.commands.client_factory import get_subscription_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# --------------------------------------------------------------------------------------------

# pylint: disable=unused-argument
# pylint: disable=line-too-long
# pylint: disable=too-many-locals

import copy
from hashlib import md5
from typing import Any, Dict, List, Tuple
Expand All @@ -17,22 +20,27 @@
import azure.mgmt.storage.models
import azure.mgmt.loganalytics
import azure.mgmt.loganalytics.models
from ..vendored_sdks.models import (
ExtensionInstance, ExtensionInstanceUpdate, Scope, ScopeCluster)
from azure.cli.core.azclierror import InvalidArgumentValueError
from azure.cli.core.azclierror import InvalidArgumentValueError, MutuallyExclusiveArgumentError
from azure.cli.core.commands.client_factory import get_mgmt_service_client, get_subscription_id
from azure.mgmt.resource.locks.models import ManagementLockObject
from knack.log import get_logger
from msrestazure.azure_exceptions import CloudError

from .._client_factory import cf_resources
from .PartnerExtensionModel import PartnerExtensionModel
from ..vendored_sdks.models import (
ExtensionInstance,
ExtensionInstanceUpdate,
Scope,
ScopeCluster
)

logger = get_logger(__name__)

resource_tag = {'created_by': 'Azure Arc-enabled ML'}


# pylint: disable=too-many-instance-attributes
class AzureMLKubernetes(PartnerExtensionModel):
def __init__(self):
# constants for configuration settings.
Expand Down Expand Up @@ -66,6 +74,14 @@ def __init__(self):
self.SERVICE_BUS_JOB_STATE_TOPIC = 'jobstate-updatedby-computeprovider'
self.SERVICE_BUS_JOB_STATE_SUB = 'compute-scheduler-jobstate'

# constants for enabling SSL in inference
self.sslKeyPemFile = 'sslKeyPemFile'
self.sslCertPemFile = 'sslCertPemFile'
self.allowInsecureConnections = 'allowInsecureConnections'
self.privateEndpointILB = 'privateEndpointILB'
self.privateEndpointNodeport = 'privateEndpointNodeport'
self.inferenceLoadBalancerHA = 'inferenceLoadBalancerHA'

# reference mapping
self.reference_mapping = {
self.RELAY_SERVER_CONNECTION_STRING: [self.RELAY_CONNECTION_STRING_KEY, self.RELAY_CONNECTION_STRING_DEPRECATED_KEY],
Expand Down Expand Up @@ -151,7 +167,7 @@ def __validate_config(self, configuration_settings, configuration_protected_sett
config_keys = configuration_settings.keys()
config_protected_keys = configuration_protected_settings.keys()
dup_keys = set(config_keys) & set(config_protected_keys)
if len(dup_keys) > 0:
if dup_keys:
for key in dup_keys:
logger.warning(
'Duplicate keys found in both configuration settings and configuration protected setttings: %s', key)
Expand All @@ -168,6 +184,7 @@ def __validate_config(self, configuration_settings, configuration_protected_sett
if enable_inference:
logger.warning("The installed AzureML extension for AML inference is experimental and not covered by customer support. Please use with discretion.")
self.__validate_scoring_fe_settings(configuration_settings, configuration_protected_settings)
self.__set_up_inference_ssl(configuration_settings, configuration_protected_settings)
elif not (enable_training or enable_inference):
raise InvalidArgumentValueError(
"Please create Microsoft.AzureML.Kubernetes extension instance either "
Expand All @@ -181,33 +198,63 @@ def __validate_config(self, configuration_settings, configuration_protected_sett
configuration_protected_settings.pop(self.ENABLE_INFERENCE, None)

def __validate_scoring_fe_settings(self, configuration_settings, configuration_protected_settings):
clusterPurpose = _get_value_from_config_protected_config(
'clusterPurpose', configuration_settings, configuration_protected_settings)
if clusterPurpose and clusterPurpose not in ["DevTest", "FastProd"]:
raise InvalidArgumentValueError(
"Accepted values for '--configuration-settings clusterPurpose' "
"are 'DevTest' and 'FastProd'")

feSslCert = _get_value_from_config_protected_config(
'scoringFe.sslCert', configuration_settings, configuration_protected_settings)
sslKey = _get_value_from_config_protected_config(
'scoringFe.sslKey', configuration_settings, configuration_protected_settings)
isTestCluster = _get_value_from_config_protected_config(
self.inferenceLoadBalancerHA, configuration_settings, configuration_protected_settings)
isTestCluster = str(isTestCluster).lower() == 'false'
if isTestCluster:
configuration_settings['clusterPurpose'] = 'DevTest'
else:
configuration_settings['clusterPurpose'] = 'FastProd'
feSslCertFile = configuration_protected_settings.get(self.sslCertPemFile)
feSslKeyFile = configuration_protected_settings.get(self.sslKeyPemFile)
allowInsecureConnections = _get_value_from_config_protected_config(
'allowInsecureConnections', configuration_settings, configuration_protected_settings)
self.allowInsecureConnections, configuration_settings, configuration_protected_settings)
allowInsecureConnections = str(allowInsecureConnections).lower() == 'true'
if (not feSslCert or not sslKey) and not allowInsecureConnections:
if (not feSslCertFile or not feSslKeyFile) and not allowInsecureConnections:
raise InvalidArgumentValueError(
"Provide ssl certificate and key. "
"Otherwise explicitly allow insecure connection by specifying "
"'--configuration-settings allowInsecureConnections=true'")

feIsNodePort = _get_value_from_config_protected_config(
self.privateEndpointNodeport, configuration_settings, configuration_protected_settings)
feIsNodePort = str(feIsNodePort).lower() == 'true'
feIsInternalLoadBalancer = _get_value_from_config_protected_config(
'scoringFe.serviceType.internalLoadBalancer', configuration_settings, configuration_protected_settings)
self.privateEndpointILB, configuration_settings, configuration_protected_settings)
feIsInternalLoadBalancer = str(feIsInternalLoadBalancer).lower() == 'true'
if feIsInternalLoadBalancer:

if feIsNodePort and feIsInternalLoadBalancer:
raise MutuallyExclusiveArgumentError(
"Specify either privateEndpointNodeport=true or privateEndpointILB=true, but not both.")
elif feIsNodePort:
configuration_settings['scoringFe.serviceType.nodePort'] = feIsNodePort
elif feIsInternalLoadBalancer:
configuration_settings['scoringFe.serviceType.internalLoadBalancer'] = feIsInternalLoadBalancer
logger.warning(
'Internal load balancer only supported on AKS and AKS Engine Clusters.')

def __set_up_inference_ssl(self, configuration_settings, configuration_protected_settings):
allowInsecureConnections = _get_value_from_config_protected_config(
self.allowInsecureConnections, configuration_settings, configuration_protected_settings)
allowInsecureConnections = str(allowInsecureConnections).lower() == 'true'
if not allowInsecureConnections:
import base64
feSslCertFile = configuration_protected_settings.get(self.sslCertPemFile)
feSslKeyFile = configuration_protected_settings.get(self.sslKeyPemFile)
with open(feSslCertFile) as f:
cert_data = f.read()
cert_data_bytes = cert_data.encode("ascii")
ssl_cert = base64.b64encode(cert_data_bytes).decode()
configuration_protected_settings['scoringFe.sslCert'] = ssl_cert
with open(feSslKeyFile) as f:
key_data = f.read()
key_data_bytes = key_data.encode("ascii")
ssl_key = base64.b64encode(key_data_bytes).decode()
configuration_protected_settings['scoringFe.sslKey'] = ssl_key
else:
logger.warning(
'SSL is not enabled. Allowing insecure connections to the deployed services.')

def __create_required_resource(
self, cmd, configuration_settings, configuration_protected_settings, subscription_id, resource_group_name,
cluster_name, cluster_location):
Expand All @@ -222,9 +269,8 @@ def __create_required_resource(
configuration_settings[self.AZURE_LOG_ANALYTICS_CUSTOMER_ID_KEY] = ws_costumer_id
configuration_protected_settings[self.AZURE_LOG_ANALYTICS_CONNECTION_STRING] = shared_key

if not configuration_settings.get(
self.RELAY_SERVER_CONNECTION_STRING) and not configuration_protected_settings.get(
self.RELAY_SERVER_CONNECTION_STRING):
if not configuration_settings.get(self.RELAY_SERVER_CONNECTION_STRING) and \
not configuration_protected_settings.get(self.RELAY_SERVER_CONNECTION_STRING):
logger.info('==== BEGIN RELAY CREATION ====')
relay_connection_string, hc_resource_id, hc_name = _get_relay_connection_str(
cmd, subscription_id, resource_group_name, cluster_name, cluster_location, self.RELAY_HC_AUTH_NAME)
Expand All @@ -233,9 +279,8 @@ def __create_required_resource(
configuration_settings[self.HC_RESOURCE_ID_KEY] = hc_resource_id
configuration_settings[self.RELAY_HC_NAME_KEY] = hc_name

if not configuration_settings.get(
self.SERVICE_BUS_CONNECTION_STRING) and not configuration_protected_settings.get(
self.SERVICE_BUS_CONNECTION_STRING):
if not configuration_settings.get(self.SERVICE_BUS_CONNECTION_STRING) and \
not configuration_protected_settings.get(self.SERVICE_BUS_CONNECTION_STRING):
logger.info('==== BEGIN SERVICE BUS CREATION ====')
topic_sub_mapping = {
self.SERVICE_BUS_COMPUTE_STATE_TOPIC: self.SERVICE_BUS_COMPUTE_STATE_SUB,
Expand All @@ -252,7 +297,7 @@ def __create_required_resource(

def _get_valid_name(input_name: str, suffix_len: int, max_len: int) -> str:
normalized_str = ''.join(filter(str.isalnum, input_name))
assert len(normalized_str) > 0, "normalized name empty"
assert normalized_str, "normalized name empty"

if len(normalized_str) <= max_len:
return normalized_str
Expand All @@ -267,6 +312,7 @@ def _get_valid_name(input_name: str, suffix_len: int, max_len: int) -> str:
return new_name


# pylint: disable=broad-except
def _lock_resource(cmd, lock_scope, lock_level='CanNotDelete'):
lock_client: azure.mgmt.resource.locks.ManagementLockClient = get_mgmt_service_client(
cmd.cli_ctx, azure.mgmt.resource.locks.ManagementLockClient)
Expand All @@ -275,14 +321,13 @@ def _lock_resource(cmd, lock_scope, lock_level='CanNotDelete'):
try:
lock_client.management_locks.create_or_update_by_scope(
scope=lock_scope, lock_name='amlarc-resource-lock', parameters=lock_object)
except:
except Exception:
# try to lock the resource if user has the owner privilege
pass


def _get_relay_connection_str(
cmd, subscription_id, resource_group_name, cluster_name, cluster_location, auth_rule_name) -> Tuple[
str, str, str]:
cmd, subscription_id, resource_group_name, cluster_name, cluster_location, auth_rule_name) -> Tuple[str, str, str]:
relay_client: azure.mgmt.relay.RelayManagementClient = get_mgmt_service_client(
cmd.cli_ctx, azure.mgmt.relay.RelayManagementClient)

Expand Down Expand Up @@ -370,8 +415,7 @@ def _get_service_bus_connection_string(cmd, subscription_id, resource_group_name


def _get_log_analytics_ws_connection_string(
cmd, subscription_id, resource_group_name, cluster_name, cluster_location) -> Tuple[
str, str]:
cmd, subscription_id, resource_group_name, cluster_name, cluster_location) -> Tuple[str, str]:
log_analytics_ws_client: azure.mgmt.loganalytics.LogAnalyticsManagementClient = get_mgmt_service_client(
cmd.cli_ctx, azure.mgmt.loganalytics.LogAnalyticsManagementClient)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from azure.cli.core.commands import LongRunningOperation
from azure.cli.core.commands.client_factory import get_mgmt_service_client, get_subscription_id
from azure.cli.core.util import sdk_no_wait
from msrestazure.azure_exceptions import CloudError
from msrestazure.tools import parse_resource_id, is_valid_resource_id

from ..vendored_sdks.models import ExtensionInstance
Expand Down Expand Up @@ -104,8 +103,7 @@ def _invoke_deployment(cmd, resource_group_name, deployment_name, template, para
if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES):
validation_poller = smc.begin_validate(resource_group_name, deployment_name, deployment)
return LongRunningOperation(cmd.cli_ctx)(validation_poller)
else:
return smc.validate(resource_group_name, deployment_name, deployment)
return smc.validate(resource_group_name, deployment_name, deployment)

return sdk_no_wait(no_wait, smc.begin_create_or_update, resource_group_name, deployment_name, deployment)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dGVzdGNlcnQ=
dGVzdGtleQ==
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testcert
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
testkey
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=protected-access

import os
import unittest

from azext_k8s_extension.partner_extensions.AzureMLKubernetes import AzureMLKubernetes


TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..'))


class TestAzureMlExtension(unittest.TestCase):

def test_set_up_inference_ssl(self):
azremlk8sInstance = AzureMLKubernetes()
config = {'allowInsecureConnections': 'false'}
# read and encode dummy cert and key
sslKeyPemFile = os.path.join(TEST_DIR, 'data', 'azure_ml', 'test_key.pem')
sslCertPemFile = os.path.join(TEST_DIR, 'data', 'azure_ml', 'test_cert.pem')
protected_config = {'sslKeyPemFile': sslKeyPemFile, 'sslCertPemFile': sslCertPemFile}
azremlk8sInstance._AzureMLKubernetes__set_up_inference_ssl(config, protected_config)
self.assertTrue('scoringFe.sslCert' in protected_config)
self.assertTrue('scoringFe.sslKey' in protected_config)
encoded_cert_and_key_file = os.path.join(TEST_DIR, 'data', 'azure_ml', 'cert_and_key_encoded.txt')
with open(encoded_cert_and_key_file, "r") as text_file:
cert = text_file.readline().rstrip()
assert cert == protected_config['scoringFe.sslCert']
key = text_file.readline()
assert key == protected_config['scoringFe.sslKey']
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import os
import unittest
# pylint: disable=line-too-long

import os
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, record_only)


Expand All @@ -27,13 +27,16 @@ def test_k8s_extension(self):
'version': '0.1.0'
})

self.cmd('k8s-extension create -g {rg} -n {name} -c {cluster_name} --cluster-type {cluster_type} --extension-type {extension_type} --release-train {release_train} --version {version}', checks=[
self.check('name', '{name}'),
self.check('releaseTrain', '{release_train}'),
self.check('version', '{version}'),
self.check('resourceGroup', '{rg}'),
self.check('extensionType', '{extension_type}')
])
self.cmd('k8s-extension create -g {rg} -n {name} -c {cluster_name} --cluster-type {cluster_type} '
'--extension-type {extension_type} --release-train {release_train} --version {version}',
checks=[
self.check('name', '{name}'),
self.check('releaseTrain', '{release_train}'),
self.check('version', '{version}'),
self.check('resourceGroup', '{rg}'),
self.check('extensionType', '{extension_type}')
]
)

# Update is disabled for now
# self.cmd('k8s-extension update -g {rg} -n {name} --tags foo=boo', checks=[
Expand Down
2 changes: 1 addition & 1 deletion src/k8s-extension/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# TODO: Add any additional SDK dependencies here
DEPENDENCIES = []

VERSION = "0.4.2"
VERSION = "0.4.3"

with open('README.rst', 'r', encoding='utf-8') as f:
README = f.read()
Expand Down