Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion k8s-custom-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ stages:

- bash : |
echo "Downloading the kind script"
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.9.0/kind-linux-amd64
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
chmod +x ./kind
./kind create cluster
displayName: "Create and Start the Kind cluster"
Expand Down
4 changes: 4 additions & 0 deletions src/k8s-extension/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.5.1
++++++++++++++++++
* Remove pyhelm which was causing users to have git installed

0.5.0
++++++++++++++++++
* Add microsoft.openservicemesh customization to check distros
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
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

Expand Down Expand Up @@ -69,7 +67,7 @@ def Create(self, cmd, client, resource_group_name, cluster_name, name, cluster_t
# 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)
# _validate_tested_distro(cmd, resource_group_name, cluster_name, version)

extension_instance = ExtensionInstance(
extension_type=extension_type,
Expand Down Expand Up @@ -107,58 +105,58 @@ 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):
# 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)
# 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
# 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)
# 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)
# 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()
# 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
# 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)
# 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)
# 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):
# 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)
)
# 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)
# values = chart_arc.get_values()
# values_yaml = yaml.load(values.raw, Loader=yaml.FullLoader)

try:
return values_yaml['OpenServiceMesh']['testedDistros']
except KeyError:
return None
# try:
# return values_yaml['OpenServiceMesh']['testedDistros']
# except KeyError:
# return None
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import unittest

from azure.cli.core.azclierror import InvalidArgumentValueError
from azext_k8s_extension.partner_extensions.OpenServiceMesh import _get_tested_distros
# from azext_k8s_extension.partner_extensions.OpenServiceMesh import _get_tested_distros

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

class TestOpenServiceMesh(unittest.TestCase):
def test_bad_osm_arc_version(self):
version = "0.7.1"
err = "Invalid version \'" + str(version) + "\' for microsoft.openservicemesh"
with self.assertRaises(InvalidArgumentValueError) as argError:
_get_tested_distros(version)
self.assertEqual(str(argError.exception), err)
# version = "0.7.1"
# err = "Invalid version \'" + str(version) + "\' for microsoft.openservicemesh"
# with self.assertRaises(InvalidArgumentValueError) as argError:
# _get_tested_distros(version)
# self.assertEqual(str(argError.exception), err)
pass
6 changes: 2 additions & 4 deletions src/k8s-extension/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@
]

# TODO: Add any additional SDK dependencies here
DEPENDENCIES = [
'pyhelm'
]
DEPENDENCIES = []

VERSION = "0.5.0"
VERSION = "0.5.1"

with open('README.rst', 'r', encoding='utf-8') as f:
README = f.read()
Expand Down
18 changes: 9 additions & 9 deletions testing/Bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@ if (-not (Test-Path -Path $PSScriptRoot/tmp)) {
if (!$SkipInstall) {
Write-Host "Removing the old connnectedk8s extension..."
az extension remove -n connectedk8s
$connectedk8sVersion = $ENVCONFIG.extensionVersion.connectedk8s
if (!$connectedk8sVersion) {
Write-Host "connectedk8s extension version wasn't specified" -ForegroundColor Red
Exit 1
}
Write-Host "Installing connectedk8s version $connectedk8sVersion..."
az extension add --source ./bin/connectedk8s-$connectedk8sVersion-py3-none-any.whl
Write-Host "Installing connectedk8s..."
az extension add -n connectedk8s

Choose a reason for hiding this comment

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

You want to always install the official release, is it? Is there a reason to stop supporting private version?

Copy link
Author

Choose a reason for hiding this comment

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

We can't keep up with private version, we have to do the manual update. This way it's fire and forget

if (!$?) {
Write-Host "Unable to find connectedk8s version $connectedk8sVersion, exiting..."
Write-Host "Unable to install connectedk8s, exiting..."
exit 1
}
}
Expand Down Expand Up @@ -76,5 +71,10 @@ if ($?)

Write-Host "Connecting the cluster to Arc with connectedk8s..."
$Env:KUBECONFIG="$PSScriptRoot/tmp/KUBECONFIG"
$Env:HELMVALUESPATH="$PSScriptRoot/bin/connectedk8s-values.yaml"
az connectedk8s connect -g $ENVCONFIG.resourceGroup -n $ENVCONFIG.arcClusterName
if (!$?)
{
kubectl get pods -A
Exit 1
}
Write-Host "Successfully onboarded the cluster to Azure"
Binary file removed testing/bin/connectedk8s-1.0.0-py3-none-any.whl
Binary file not shown.
3 changes: 0 additions & 3 deletions testing/bin/connectedk8s-values.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions testing/settings.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

"extensionVersion": {
"k8s-extension": "0.3.0",
"k8s-extension-private": "0.1.0",
"connectedk8s": "1.0.0"
"k8s-extension-private": "0.1.0"
}
}