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

appservice-kube extension #3934

Merged
merged 130 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
8ea8421
add appservice-kube extension
ebencarek May 6, 2020
aa0795f
Retrieving function triggers from the function image
SatishRanjan May 16, 2020
ff3b68f
Retrieving function triggers from the function image
SatishRanjan May 16, 2020
ca0276d
Fix appservice kube list by subscription
ebencarek May 15, 2020
31c796b
Fix transient error when loading arguments
ebencarek May 15, 2020
9a9a90f
Added az webapp up support
sanchitmehta May 11, 2020
b7fb864
Handled code review comments
sanchitmehta May 26, 2020
7b62957
bump up version to 0.1.1
ebencarek May 27, 2020
bb3a2a2
Use custom sdk code for app service plan command sdk
ebencarek Jun 11, 2020
faebbf0
Version 0.1.2
ebencarek Jun 11, 2020
c3c0fd5
Private registry image support and fixig windows to unix line feed ch…
SatishRanjan Jun 27, 2020
2e2ecb4
Removing debugpy.breaspoint() line
SatishRanjan Jun 30, 2020
9a1f432
Update custom.py
SatishRanjan Jul 7, 2020
60a3e9b
Update custom.py
SatishRanjan Jul 7, 2020
694cf05
fixing the condition when the image is from the public registry with …
SatishRanjan Jul 23, 2020
1d3f93c
Update sdk, add BYO AKS cluster to kube create command
ebencarek Sep 18, 2020
2b27df4
Add version 0.1.3
ebencarek Sep 18, 2020
8d4d3f0
Copying getfunctionsjson.sh as part of appservice-kube extension and …
SatishRanjan Oct 2, 2020
9e95f2d
Adding version 0.1.4
ebencarek Oct 5, 2020
714248e
fix
calvinsID Oct 9, 2020
752926b
Update version to 0.1.5
ebencarek Oct 9, 2020
11999bb
Update kube environments SDK
ebencarek Oct 28, 2020
6432dbb
Add version 0.1.6
ebencarek Oct 28, 2020
ff7c355
Update kube environments SDK (using api version 2020-06-01), delete o…
ebencarek Dec 22, 2020
35221e9
Add version 0.1.7
ebencarek Dec 22, 2020
eecafb2
remove azure-cli-core dependency
ebencarek Feb 19, 2021
ffcfc23
Add version 0.1.8
ebencarek Feb 19, 2021
c6b63e6
Add latest changes from cli core (except az webapp up)
calvinsID Mar 24, 2021
bb83774
Bugfix: if ftp deployment profile doesn't exist, zip deploy fails
calvinsID Mar 30, 2021
bb3f860
Bugfix: index.json had weird merge conflict
calvinsID Mar 30, 2021
b2293f6
Bugfix: webapp config container set wasn't setting
calvinsID Mar 30, 2021
5bd7f73
Version 0.1.9
calvinsID Mar 31, 2021
b83b2a2
Add functionapp config container set
calvinsID Apr 6, 2021
db7a304
Start referencing main cli
calvinsID Apr 6, 2021
3bf5215
Functionapp deployment source config-zip command fix (copy over from …
calvinsID Apr 6, 2021
6ead073
Functions CLI should not pull docker image
calvinsID Apr 9, 2021
6ee2fb5
Plan creation should drop --kube-environment and --kube-sku
calvinsID Apr 10, 2021
f03a04c
Change kind to 'linux,kubernetes'
calvinsID Apr 10, 2021
2096657
Help text changes
calvinsID Apr 10, 2021
7cda49f
Publish extension v 0.1.10
calvinsID Apr 12, 2021
5d1d5e6
Version 0.1.11, since broke appservice plan create for non-k8se plans
calvinsID Apr 12, 2021
fa243d7
Allow specifying custom location by name rather than resource ID
calvinsID Apr 13, 2021
e2322a4
az appservice kube create command
calvinsID Apr 13, 2021
18a95f3
Change ASP kind back to K8SE, reserved to None
calvinsID Apr 13, 2021
34992e7
Publish 0.1.12 whl
calvinsID Apr 14, 2021
2be983a
az webapp create doesn't require plan for k8se
calvinsID Apr 20, 2021
42e83d0
Change app service plan kind to 'linux,kubernetes' and reserved=true if
calvinsID Apr 20, 2021
0eac695
Webapp create should pass with ASP kind=linux if SKU is a kube sku
calvinsID Apr 20, 2021
6878773
az functionapp create without plan
calvinsID Apr 20, 2021
fe960bb
Fix bug where if webapp/functionapp create called to update, if --pla…
calvinsID Apr 20, 2021
81aa8db
fix webapp/functionapp create, if calling create again with new custo…
calvinsID Apr 21, 2021
b48e04d
Version 0.1.13
calvinsID Apr 21, 2021
7d96f27
Version 0.1.14 temporary change to stop doing the list in web/func ap…
calvinsID Apr 26, 2021
7fff6b2
Add better help text for appservice create with custom location
calvinsID Apr 30, 2021
03cc4c8
Update appservice SDK for kube extension to 2020-12-01
calvinsID Apr 30, 2021
40aa79d
Clean up az kube create
calvinsID Apr 30, 2021
cb8c593
Update to version 0.1.15
calvinsID May 3, 2021
f93c898
Fix dotnet5 bug
calvinsID May 5, 2021
40afbc4
Converting skus for kubernetes ASPs to the new values
ebencarek May 5, 2021
16ee7bb
Merge pull request #1 from calvinsID/user/ebcarek/new-kube-skus
calvinsID May 5, 2021
96760a2
0.1.16 version
calvinsID May 5, 2021
692e4fa
Set number of workers to 1 when creating ASP
calvinsID May 6, 2021
ed34d7b
Add webapp scale command
calvinsID May 6, 2021
c5c6f6b
Version 0.1.17 with az webapp scale
calvinsID May 7, 2021
859bdf5
rename az webapp scale param
calvinsID May 8, 2021
9105dfd
Move restart in from main CLI, since api returns 202 rather than 200.…
calvinsID May 12, 2021
db89855
Change SDK to have extended location envelope manually - need to see why
calvinsID May 8, 2021
4ce2e59
Pass ExtendedLocationEnvelope to web/functionapp, appservice plan and…
calvinsID May 12, 2021
908dd85
Version 0.1.18
calvinsID May 13, 2021
5f12407
Remove webapp up from extension
calvinsID May 14, 2021
0f85643
Use delete_app_settings function from cli core
calvinsID May 14, 2021
1f2e1d3
Use webapp validator from core CLI
calvinsID May 17, 2021
3cfdb04
Use updated update_app_settings function from core CLI
calvinsID May 17, 2021
17dfd66
0.1.19 version
calvinsID May 17, 2021
02770eb
Fix regression when using main CLI validators
calvinsID May 17, 2021
4ffb55a
0.1.20 version
calvinsID May 17, 2021
5549691
az appservice kube create: better error message when conflict
calvinsID Jun 29, 2021
ba59ea6
Remove vsts_cd_manager
calvinsID Jul 22, 2021
0d174f4
Version 0.1.21
calvinsID Jul 22, 2021
e3afa2d
Merge latest master
calvinsID Jul 22, 2021
97e4b5f
Update index.json
calvinsID Jul 22, 2021
79aff04
K8se master kube env create validations (#3)
calvinsID Jul 22, 2021
86d8a53
Version 0.2.0
calvinsID Jul 22, 2021
9d29882
Use ExtendedLocation property ob object level (#4)
calvinsID Aug 24, 2021
0508a6e
Static ip not required property in kube create
calvinsID Aug 25, 2021
a1ead2f
Version 0.2.1
calvinsID Aug 25, 2021
550a56b
Fix NoneType object has no attribute custom_location error
calvinsID Aug 27, 2021
6ab0f7b
Bugfix: Wrong custom location being used if multiple custom locations…
calvinsID Sep 2, 2021
d119388
Merge branch 'k8se-master' of https://github.com/calvinsID/azure-cli-…
calvinsID Sep 2, 2021
7ccd608
Version 0.2.2
calvinsID Sep 2, 2021
f158c95
remove old SDK and start 'az appservice kube' rewrite
StrawnSC Sep 8, 2021
e1b8a14
rewrite 'az appservice kube show'
StrawnSC Sep 8, 2021
d7df221
rewrite 'az appservice kube list'
StrawnSC Sep 8, 2021
defcbad
rewrite 'az appservice kube delete'
StrawnSC Sep 8, 2021
af91efa
re-add appservice kube create checks and start appservice kube update…
StrawnSC Sep 9, 2021
afbac84
raise exception for 'az appservice kube update'
StrawnSC Sep 10, 2021
75b6efe
add 'az appservice kube wait'
StrawnSC Sep 10, 2021
a245c55
add kube list pagination
StrawnSC Sep 10, 2021
597c305
fix 'az appservice create'
StrawnSC Sep 13, 2021
084a0ae
fix 'az appservice plan update'
StrawnSC Sep 13, 2021
c333051
fix 'az webapp create'
StrawnSC Sep 17, 2021
e941fa5
fix az webapp show/restart
StrawnSC Sep 17, 2021
ebb6a9c
remove 'az webapp config container set'
StrawnSC Sep 23, 2021
cb66bff
remove uneeded TODOs
StrawnSC Sep 27, 2021
7fc671e
format results of 'az appservice kube show/list'
StrawnSC Sep 27, 2021
110081f
remove TODOs and fix 'az webapp show -s'
StrawnSC Sep 29, 2021
6731f84
add misc style fixes
StrawnSC Sep 30, 2021
e2344c8
fix more style issues
StrawnSC Sep 30, 2021
68d70e4
revert src/index.json to master version
StrawnSC Sep 30, 2021
1f640fc
add summary
StrawnSC Sep 30, 2021
a91b053
merge master and fix merge conflict
StrawnSC Sep 30, 2021
6f4319c
fix linter issues
StrawnSC Sep 30, 2021
9382be0
remove out-of-date test
StrawnSC Sep 30, 2021
0b8c1dd
fix appservice kube CLI linter issues
StrawnSC Sep 30, 2021
2256638
fix ASP sku validation
StrawnSC Oct 1, 2021
8345bdf
fix style
StrawnSC Oct 1, 2021
34aeafa
increment appservice-kube release number and fix service_name.json
StrawnSC Oct 1, 2021
2d03c5d
fix hardcoded 'verify_linter.py'
StrawnSC Oct 1, 2021
02d2e2e
add testing -- WIP
StrawnSC Oct 5, 2021
d614ed8
update codeowners and fix 'az appservice kube list' bug
StrawnSC Oct 25, 2021
aa1a81b
remove unfinished tests
StrawnSC Oct 25, 2021
da8fc36
remove unnecessary branching
StrawnSC Oct 26, 2021
386c31e
remove unnecessary options lists
StrawnSC Oct 26, 2021
aecde8a
use specific CLI error types
StrawnSC Oct 26, 2021
aa79f3c
use more specific error type
StrawnSC Oct 26, 2021
6b4ab5e
fix more error types
StrawnSC Oct 26, 2021
66f1f8b
use HttpResponseError
StrawnSC Oct 26, 2021
0dc7a9d
fix style
StrawnSC Oct 26, 2021
aa2a822
revert version and erase history
StrawnSC Oct 26, 2021
b469377
Merge branch 'main' into lima-extension-remove-local-sdk
StrawnSC Oct 27, 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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@

/src/kusto/ @ilayr @orhasban @astauben

/src/appservice-kube/ @ebencarek @calcha @StrawnSC

/src/custom-providers/ @jsntcy

/src/costmanagement/ @kairu-ms @jsntcy
Expand Down
9 changes: 9 additions & 0 deletions src/appservice-kube/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. :changelog:

Release History
===============


0.1.0
++++++
* Initial public preview release.
5 changes: 5 additions & 0 deletions src/appservice-kube/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Microsoft Azure CLI 'appservice-kube' Extension
==========================================

The appservice-kube extension adds support for controlling App Service Kubernetes Environments.
See here for more information: https://docs.microsoft.com/en-us/azure/app-service/manage-create-arc-environment?tabs=bash
33 changes: 33 additions & 0 deletions src/appservice-kube/azext_appservice_kube/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader

from azext_appservice_kube._help import helps # pylint: disable=unused-import


class AppserviceCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azure.cli.core.profiles import ResourceType
appservice_custom = CliCommandType(operations_tmpl='azext_appservice_kube.custom#{}')
super().__init__(cli_ctx=cli_ctx,
custom_command_type=appservice_custom,
resource_type=ResourceType.MGMT_APPSERVICE)

def load_command_table(self, args):
super().load_command_table(args)
from azext_appservice_kube.commands import load_command_table
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
super().load_arguments(command)
from azext_appservice_kube._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = AppserviceCommandsLoader
21 changes: 21 additions & 0 deletions src/appservice-kube/azext_appservice_kube/_appservice_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from ._client_factory import web_client_factory


def _generic_site_operation(cli_ctx, resource_group_name, name, operation_name, slot=None,
extra_parameter=None, client=None):
client = client or web_client_factory(cli_ctx)
operation = getattr(client.web_apps,
operation_name if slot is None else operation_name + '_slot')
if slot is None:
return (operation(resource_group_name, name)
if extra_parameter is None else operation(resource_group_name,
name, extra_parameter))

return (operation(resource_group_name, name, slot)
if extra_parameter is None else operation(resource_group_name,
name, extra_parameter, slot))
54 changes: 54 additions & 0 deletions src/appservice-kube/azext_appservice_kube/_client_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.cli.command_modules.appservice._client_factory import web_client_factory
from azure.cli.core.profiles import ResourceType


# pylint: disable=inconsistent-return-statements
def ex_handler_factory(creating_plan=False, no_throw=False):
def _polish_bad_errors(ex):
import json
from azure.cli.core.azclierror import ValidationError
try:
detail = json.loads(ex.response.text)['Message']
if creating_plan:
if 'Requested features are not supported in region' in detail:
detail = ("Plan with linux worker is not supported in current region. For " +
"supported regions, please refer to https://docs.microsoft.com/"
"azure/app-service-web/app-service-linux-intro")
elif 'Not enough available reserved instance servers to satisfy' in detail:
detail = ("Plan with Linux worker can only be created in a group " +
"which has never contained a Windows worker, and vice versa. " +
"Please use a new resource group. Original error:" + detail)
ex = ValidationError(detail)
except Exception: # pylint: disable=broad-except
pass
if no_throw:
return ex
raise ex
return _polish_bad_errors


def customlocation_client_factory(cli_ctx, **_):
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_CUSTOMLOCATION)


def resource_client_factory(cli_ctx, **_):
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES)


def cf_plans(cli_ctx, *_):
return web_client_factory(cli_ctx).app_service_plans


def cf_compute_service(cli_ctx, *_):
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_COMPUTE)


def cf_resource_groups(cli_ctx, subscription_id=None):
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
subscription_id=subscription_id).resource_groups
53 changes: 53 additions & 0 deletions src/appservice-kube/azext_appservice_kube/_completers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core.decorators import Completer
from ._utils import _get_location_from_resource_group
from ._constants import KUBE_DEFAULT_SKU


@Completer
def get_vm_size_completion_list(cmd, prefix, namespace): # pylint: disable=unused-argument
"""Return the intersection of the VM sizes allowed by the ACS SDK with those returned by the Compute Service."""
from azure.mgmt.containerservice.models import ContainerServiceVMSizeTypes

location = _get_location(cmd.cli_ctx, namespace)
result = get_vm_sizes(cmd.cli_ctx, location)
return set(r.name for r in result) & set(c.value for c in ContainerServiceVMSizeTypes)


@Completer
def get_kube_sku_completion_list(cmd, prefix, namespace): # pylint: disable=unused-argument
"""
Return the VM sizes allowed by AKS, or 'ANY'
"""
return get_vm_size_completion_list(cmd, prefix, namespace) & set(KUBE_DEFAULT_SKU)


def get_vm_sizes(cli_ctx, location):
from ._client_factory import cf_compute_service
return cf_compute_service(cli_ctx).virtual_machine_sizes.list(location)


def _get_location(cli_ctx, namespace):
"""
Return an Azure location by using an explicit `--location` argument, then by `--resource-group`, and
finally by the subscription if neither argument was provided.
"""
from azure.core.exceptions import HttpResponseError
from azure.cli.core.commands.parameters import get_one_of_subscription_locations

location = None
if getattr(namespace, 'location', None):
location = namespace.location
elif getattr(namespace, 'resource_group_name', None):
try:
location = _get_location_from_resource_group(cli_ctx, namespace.resource_group_name)
except HttpResponseError as err:
from argcomplete import warn
warn('Warning: {}'.format(err.message))
if not location:
location = get_one_of_subscription_locations(cli_ctx)
return location
84 changes: 84 additions & 0 deletions src/appservice-kube/azext_appservice_kube/_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


KUBE_DEFAULT_SKU = "K1"
KUBE_ASP_KIND = "linux,kubernetes"
KUBE_APP_KIND = "linux,kubernetes,app"
KUBE_CONTAINER_APP_KIND = 'linux,kubernetes,app,container'
KUBE_FUNCTION_APP_KIND = 'linux,kubernetes,functionapp'
KUBE_FUNCTION_CONTAINER_APP_KIND = 'linux,kubernetes,functionapp,container'

LINUX_RUNTIMES = ['dotnet', 'node', 'python', 'java']
WINDOWS_RUNTIMES = ['dotnet', 'node', 'java', 'powershell']

NODE_VERSION_DEFAULT = "10.14"
NODE_VERSION_NEWER = "12-lts"
NODE_EXACT_VERSION_DEFAULT = "10.14.1"
NETCORE_VERSION_DEFAULT = "2.2"
DOTNET_VERSION_DEFAULT = "4.7"
PYTHON_VERSION_DEFAULT = "3.7"
NETCORE_RUNTIME_NAME = "dotnetcore"
DOTNET_RUNTIME_NAME = "aspnet"
NODE_RUNTIME_NAME = "node"
PYTHON_RUNTIME_NAME = "python"
OS_DEFAULT = "Windows"
STATIC_RUNTIME_NAME = "static" # not an official supported runtime but used for CLI logic
NODE_VERSIONS = ['4.4', '4.5', '6.2', '6.6', '6.9', '6.11', '8.0', '8.1', '8.9', '8.11', '10.1', '10.10', '10.14']
PYTHON_VERSIONS = ['3.7', '3.6', '2.7']
NETCORE_VERSIONS = ['1.0', '1.1', '2.1', '2.2']
DOTNET_VERSIONS = ['3.5', '4.7']

LINUX_SKU_DEFAULT = "P1V2"
FUNCTIONS_VERSIONS = ['2', '3']

# functions version : default node version
FUNCTIONS_VERSION_TO_DEFAULT_NODE_VERSION = {
'2': '~10',
'3': '~12'
}
# functions version -> runtime : default runtime version
FUNCTIONS_VERSION_TO_DEFAULT_RUNTIME_VERSION = {
'2': {
'node': '8',
'dotnet': '2',
'python': '3.7',
'java': '8'
},
'3': {
'node': '12',
'dotnet': '3',
'python': '3.7',
'java': '8'
}
}
# functions version -> runtime : runtime versions
FUNCTIONS_VERSION_TO_SUPPORTED_RUNTIME_VERSIONS = {
'2': {
'node': ['8', '10'],
'python': ['3.6', '3.7'],
'dotnet': ['2'],
'java': ['8']
},
'3': {
'node': ['10', '12'],
'python': ['3.6', '3.7', '3.8'],
'dotnet': ['3'],
'java': ['8']
}
}
# dotnet runtime version : dotnet linuxFxVersion
DOTNET_RUNTIME_VERSION_TO_DOTNET_LINUX_FX_VERSION = {
'2': '2.2',
'3': '3.1'
}

MULTI_CONTAINER_TYPES = ['COMPOSE', 'KUBE']

OS_TYPES = ['Windows', 'Linux']

CONTAINER_APPSETTING_NAMES = ['DOCKER_REGISTRY_SERVER_URL', 'DOCKER_REGISTRY_SERVER_USERNAME',
'DOCKER_REGISTRY_SERVER_PASSWORD', "WEBSITES_ENABLE_APP_SERVICE_STORAGE"]
APPSETTINGS_TO_MASK = ['DOCKER_REGISTRY_SERVER_PASSWORD']
Loading