Skip to content

Commit

Permalink
[k8s-extension] Release v0.5.0 of extension customizations (Azure#3545)
Browse files Browse the repository at this point in the history
* Create pull.yml

* Update pull.yml

* Update azure-pipelines.yml

* Initial commit of k8s-extension

* Update pipelines file

* Update CODEOWNERS

* Update private preview pipelines

* Remove open service mesh from public release

* Update pipeline files

* Update public extension pipeline

* Change condition variable

* Add version to public preview/private preview

* Update pipelines

* Add different testing based on private branch

* Add annotations to extension model

* Update k8s-custom-pipelines.yml

* Update SDKs with Updated Swagger Spec for 2020-07-01-preview (#13)

* Update sdks with updated swagger spec

* Update version and history rst

* Reorder release history timeline

* Fix ExtensionInstanceForCreate for import

* remove py2 bdist support

* Add custom table formatting

* Remove unnecessary files

* Fix style issues

* Fix branch based on comments

* Update identity piece manually

* Don't handle defaults at the CLI level

* Remove defaults from CLI client

* Check null target namespace with namespace scope

* Update style

* Add cassandra operator and location to model

* Stage Public Version of k8s-extension 0.2.0 for official release (#15)

* Create pull.yml

* Update pull.yml

* Update azure-pipelines.yml

* Initial commit of k8s-extension

* Update pipelines file

* Update CODEOWNERS

* Update private preview pipelines

* Remove open service mesh from public release

* Update pipeline files

* Update public extension pipeline

* Change condition variable

* Add version to public preview/private preview

* Update pipelines

* Add different testing based on private branch

* Add annotations to extension model

* Update k8s-custom-pipelines.yml

* Update SDKs with Updated Swagger Spec for 2020-07-01-preview (#13)

* Update sdks with updated swagger spec

* Update version and history rst

* Reorder release history timeline

* Fix ExtensionInstanceForCreate for import

* remove py2 bdist support

* Add custom table formatting

* Remove unnecessary files

* Fix style issues

* Fix branch based on comments

* Update identity piece manually

* Don't handle defaults at the CLI level

* Remove defaults from CLI client

* Check null target namespace with namespace scope

* Update style

* Add cassandra operator and location to model

Co-authored-by: [email protected] <Action - Fork Sync>

* Remove custom pipelines file

* Update extension description, remove private const

* Update pipeline file

* Disable refs docs

* Update to include better create warning logs and remove update context (#20)

* Update to include better create warning logs and remove update context

* Remove help text for update

* Fix spelling error

* Update message

* Fix k8s-extension conflict with private version

* Fix style errors

* Fix filename

* add customization for microsoft.azureml.kubernetes (#23)

* add customization for microsoft.azureml.kubernetes

* Update release history

Co-authored-by: Yue Yu <[email protected]>
Co-authored-by: jonathan-innis <[email protected]>

* Add E2E Testing from Separate branch into internal code (#26)

* Add internal e2e testing

* Change to testing folder

* Inference CLI validation for Scoring FE (#24)

* cli validation starter

* added the call to the fe validation function

* nodeport validation not required

* test fix

Co-authored-by: Jonathan Innis <[email protected]>

* legal warning added (#27)

* Remove deprecated method logger.warn

* Update k8s-custom-pipelines.yml for Azure Pipelines

* Update k8s-custom-pipelines.yml for Azure Pipelines

* Add Azure Defender to E2E testing (#28)

* Add azure defender testing to e2e

* Remove the debug flag

* Add configuration testing

* Fix pipeline failures

* Make test script more intuitive

* Remove parameter from testing

* Fix wrong location for k8s config whl

* Fix pip upgrade issue

* Fix pip install upgrade issue

* Fix pip install issue

* delete resurce in testcase (#29)

Co-authored-by: Yue Yu <[email protected]>
Co-authored-by: Jonathan Innis <[email protected]>

* Check Provider is Registered with Subscription Before Making Requests (#18)

* Add check for KubernetesConfiguration

* Disable pylint and rename

* Update provider registration link

* Update version

* Remove extra blank line

* Fix bug in import

* only validate scoring fe when inference is enabled (#31)

* only validate scoring fe when inference is enabled

* Fix versioning

Co-authored-by: Yue Yu <[email protected]>
Co-authored-by: jonathan-innis <[email protected]>

* Provider registration case insensitive

* do not validate against scoring fe if inference is not enabled. (#33)

* do not validate against scoring fe if inference is not enabled.

* add inference enabled scenario

* refine

* increase sleeping time

* fix

Co-authored-by: Yue Yu <[email protected]>
Co-authored-by: Jonathan Innis <[email protected]>

* Add OSM as Public Preview Extension (#34)

* Add OSM as public preview extension

* Add osm testing

* Add release train to tests

* Fix failing osm test

* Upgrade pip in integration testing

* Remove ununsed import

* Fix release train check in update

* Parallelize E2E Testing (#36)

* Add OSM as public preview extension

* Add osm testing

* Update test logic to parallelize

* Fix test success checking

* Parallelize extension testing

* Better error checking logic

* Fix azureml deletion

* Fix private build (#40)

* change amlk8s to amlarc (#42)

Co-authored-by: Yue Yu <[email protected]>

* Servicebus client model changes (#44)

* Servicebus client model changes

* Fix testing script

* Update history file and pipeline

* Update min cli core version for track 2 updates

* Read SSL cert and key from files (#38)

* first sketch of the change

fixes

removed extra blank lines

changes regarding param renaming

added ssl tests

added more detail to the unit test

additional import

moved pem files out of public folder

fixed import

chenged import

changed import

unit tests fix

unit test fix

fixed unit tests

fixed unit test

unit test fix

changes int test cert and key

* test protected config

* fix test typo

* temporary changes reverted

* fixing tests

* fixed file paths

* removed accidentally added file

* changes according to review comments

* more changes according to review comments

* changes according to review comments

Co-authored-by: Jonathan Innis <[email protected]>

* Upgrade release version

* Liakaz/inference read ssl from file (#47)

* first sketch of the change

fixes

removed extra blank lines

changes regarding param renaming

added ssl tests

added more detail to the unit test

additional import

moved pem files out of public folder

fixed import

chenged import

changed import

unit tests fix

unit test fix

fixed unit tests

fixed unit test

unit test fix

changes int test cert and key

* test protected config

* fix test typo

* temporary changes reverted

* fixing tests

* fixed file paths

* removed accidentally added file

* changes according to review comments

* more changes according to review comments

* changes according to review comments

* fixed decode error

* renamed the experimental param

Co-authored-by: Jonathan Innis <[email protected]>

* Fix style issues (#51)

* Fixed scoring fe related extension param names (#49)

* fixed scoring fe related extension params

* bug fix and style fixes

* variable rename

* fixed the error type

* set cluster to prod by default

* Add distro validation for osm-arc (#50)

* Add distro validation for osm-arc

* fixed indentation

* Fix linting

* Resolve comments

* Add unit test

* fix lint

Co-authored-by: Jonathan Innis <[email protected]>

* Add distro validation for osm-arc (#50)

* Add distro validation for osm-arc

* fixed indentation

* Fix linting

* Resolve comments

* Add unit test

* fix lint

Co-authored-by: Jonathan Innis <[email protected]>

* Add distro validation for osm-arc (#53)

removed release-train logic

* Add Custom Delete Logic for Partners (#54)

* Add custom delete logic

* Fix failing unit tests

* Add warning message when deleting amlarc extension (#55)

* add warning message

* fix indentation

* Update release version

Co-authored-by: [email protected] <Action - Fork Sync>
Co-authored-by: yuyue9284 <[email protected]>
Co-authored-by: Yue Yu <[email protected]>
Co-authored-by: Lia Kazakova <[email protected]>
Co-authored-by: Niranjan Shankar <[email protected]>
Co-authored-by: jingyizhu99 <[email protected]>
  • Loading branch information
6 people authored Jul 7, 2021
1 parent b4e0709 commit 4bf9017
Show file tree
Hide file tree
Showing 13 changed files with 291 additions and 62 deletions.
6 changes: 5 additions & 1 deletion src/k8s-extension/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
Release History
===============

0.5.0
++++++++++++++++++
* Add microsoft.openservicemesh customization to check distros
* Delete customization for partners

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


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

Expand Down
11 changes: 11 additions & 0 deletions src/k8s-extension/azext_k8s_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,17 @@ def delete_k8s_extension(client, resource_group_name, cluster_name, name, cluste
"""
# Determine ClusterRP
cluster_rp = __get_cluster_rp(cluster_type)
extension = None
try:
extension = client.get(resource_group_name, cluster_rp, cluster_type, cluster_name, name)
except ErrorResponseException:
logger.warning("No extension with name '%s' found on cluster '%s', so nothing to delete", cluster_name, name)
return None
extension_class = ExtensionFactory(extension.extension_type.lower())

# If there is any custom delete logic, this will call the logic
extension_class.Delete(client, resource_group_name, cluster_name, name, cluster_type)

return client.delete(resource_group_name, cluster_rp, cluster_type, cluster_name, name)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version):
release_train=release_train,
version=version
)

def Delete(self, client, resource_group_name, cluster_name, name, cluster_type):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version):
version=version
)

def Delete(self, client, resource_group_name, cluster_name, name, cluster_type):
# Give a warning message
logger.warning("If nvidia.com/gpu or fuse resource is not recognized by kubernetes after this deletion, "
"you probably have installed nvidia-device-plugin or fuse-device-plugin before installing AMLArc extension. "
"Please try to reinstall device plugins to fix this issue.")

def __validate_config(self, configuration_settings, configuration_protected_settings):
# perform basic validation of the input config
config_keys = configuration_settings.keys()
Expand Down Expand Up @@ -226,7 +232,7 @@ def __validate_scoring_fe_settings(self, configuration_settings, configuration_p
if feIsNodePort and feIsInternalLoadBalancer:
raise MutuallyExclusiveArgumentError(
"Specify either privateEndpointNodeport=true or privateEndpointILB=true, but not both.")
elif feIsNodePort:
if feIsNodePort:
configuration_settings['scoringFe.serviceType.nodePort'] = feIsNodePort
elif feIsInternalLoadBalancer:
configuration_settings['scoringFe.serviceType.internalLoadBalancer'] = feIsInternalLoadBalancer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version):
release_train=release_train,
version=version
)

def Delete(self, client, resource_group_name, cluster_name, name, cluster_type):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version):
version=version
)

def Delete(self, client, resource_group_name, cluster_name, name, cluster_type):
pass


# Custom Validation Logic for Container Insights

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version):
release_train=release_train,
version=version
)

def Delete(self, client, resource_group_name, cluster_name, name, cluster_type):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,39 @@
# --------------------------------------------------------------------------------------------

# pylint: disable=unused-argument
# pylint: disable=redefined-outer-name
# pylint: disable=no-member

from azure.cli.core.azclierror import InvalidArgumentValueError, RequiredArgumentMissingError
from knack.log import get_logger

from ..vendored_sdks.models import ExtensionInstance
from ..vendored_sdks.models import ExtensionInstanceUpdate
from ..vendored_sdks.models import ScopeCluster
from ..vendored_sdks.models import Scope
from azure.cli.core.azclierror import InvalidArgumentValueError, RequiredArgumentMissingError
from azure.cli.core.commands.client_factory import get_subscription_id

from pyhelm.chartbuilder import ChartBuilder
from pyhelm.repo import VersionError
from packaging import version
import yaml

from ..partner_extensions import PartnerExtensionModel

from .PartnerExtensionModel import PartnerExtensionModel

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

from .._client_factory import cf_resources

logger = get_logger(__name__)


class OpenServiceMesh(PartnerExtensionModel):
CHART_NAME = "osm-arc"
CHART_LOCATION = "https://azure.github.io/osm-azure"

def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_type, extension_type,
scope, auto_upgrade_minor_version, release_train, version, target_namespace,
release_namespace, configuration_settings, configuration_protected_settings,
Expand All @@ -38,30 +56,21 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t
scope_cluster = ScopeCluster(release_namespace=release_namespace)
ext_scope = Scope(cluster=scope_cluster, namespace=None)

valid_release_trains = ['staging', 'pilot']
# If release-train is not input, set it to 'stable'
if release_train is None:
# version is a mandatory if release-train is staging or pilot
if version is None:
raise RequiredArgumentMissingError(
"A release-train must be provided. Valid values are 'staging', 'pilot'."
)

if release_train.lower() in valid_release_trains:
# version is a mandatory if release-train is staging or pilot
if version is None:
raise RequiredArgumentMissingError(
"A version must be provided for release-train {}.".format(release_train)
)
# If the release-train is 'staging' or 'pilot' then auto-upgrade-minor-version MUST be set to False
if auto_upgrade_minor_version or auto_upgrade_minor_version is None:
auto_upgrade_minor_version = False
logger.warning("Setting auto-upgrade-minor-version to False since release-train is '%s'", release_train)
else:
raise InvalidArgumentValueError(
"Invalid release-train '{}'. Valid values are 'staging', 'pilot'.".format(release_train)
"A version must be provided for release-train {}.".format(release_train)
)
# If the release-train is 'staging' or 'pilot' then auto-upgrade-minor-version MUST be set to False
if auto_upgrade_minor_version or auto_upgrade_minor_version is None:
auto_upgrade_minor_version = False
logger.warning("Setting auto-upgrade-minor-version to False since release-train is '%s'", release_train)

# NOTE-2: Return a valid ExtensionInstance object, Instance name and flag for Identity
create_identity = False

_validate_tested_distro(cmd, resource_group_name, cluster_name, version)

extension_instance = ExtensionInstance(
extension_type=extension_type,
auto_upgrade_minor_version=auto_upgrade_minor_version,
Expand Down Expand Up @@ -93,3 +102,63 @@ def Update(self, extension, auto_upgrade_minor_version, release_train, version):
release_train=release_train,
version=version
)

def Delete(self, client, resource_group_name, cluster_name, name, cluster_type):
pass


def _validate_tested_distro(cmd, cluster_resource_group_name, cluster_name, extension_version):

field_unavailable_error = '\"testedDistros\" field unavailable for version {0} of microsoft.openservicemesh, ' \
'cannot determine if this Kubernetes distribution has been properly tested'.format(extension_version)

if version.parse(str(extension_version)) <= version.parse("0.8.3"):
logger.warning(field_unavailable_error)
return

subscription_id = get_subscription_id(cmd.cli_ctx)
resources = cf_resources(cmd.cli_ctx, subscription_id)

cluster_resource_id = '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Kubernetes' \
'/connectedClusters/{2}'.format(subscription_id, cluster_resource_group_name, cluster_name)

resource = resources.get_by_id(cluster_resource_id, '2020-01-01-preview')
cluster_distro = resource.properties['distribution'].lower()

if cluster_distro == "general":
logger.warning('Unable to determine if distro has been tested for microsoft.openservicemesh, '
'kubernetes distro: \"general\"')
return

tested_distros = _get_tested_distros(extension_version)

if tested_distros is None:
logger.warning(field_unavailable_error)
elif cluster_distro not in tested_distros.split():
logger.warning('Untested kubernetes distro for microsoft.openservicemesh, Kubernetes distro is %s',
cluster_distro)


def _get_tested_distros(chart_version):

try:
chart_arc = ChartBuilder({
"name": OpenServiceMesh.CHART_NAME,
"version": str(chart_version),
"source": {
"type": "repo",
"location": OpenServiceMesh.CHART_LOCATION
}
})
except VersionError:
raise InvalidArgumentValueError(
"Invalid version '{}' for microsoft.openservicemesh".format(chart_version)
)

values = chart_arc.get_values()
values_yaml = yaml.load(values.raw, Loader=yaml.FullLoader)

try:
return values_yaml['OpenServiceMesh']['testedDistros']
except KeyError:
return None
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ def Create(self, cmd, client, resource_group_name: str, cluster_name: str, name:
def Update(self, extension: ExtensionInstance, auto_upgrade_minor_version: bool,
release_train: str, version: str) -> ExtensionInstanceUpdate:
pass

@abstractmethod
def Delete(self, client, resource_group_name: str, cluster_name: str, name: str, cluster_type: str):
pass
Loading

0 comments on commit 4bf9017

Please sign in to comment.