-
Notifications
You must be signed in to change notification settings - Fork 1.6k
spring-cloud: add support to enable/disable MSI #1523
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,6 +147,26 @@ | |
| short-summary: Show logs of an app instance, logs will be streamed when setting '-f/--follow'. | ||
| """ | ||
|
|
||
| helps['spring-cloud app identity'] = """ | ||
| type: group | ||
| short-summary: manage an app's managed service identity | ||
| """ | ||
|
|
||
| helps['spring-cloud app identity assign'] = """ | ||
| type: command | ||
| short-summary: Enable managed service identity on an app. | ||
|
leonard520 marked this conversation as resolved.
|
||
| """ | ||
|
|
||
| helps['spring-cloud app identity remove'] = """ | ||
| type: command | ||
| short-summary: Remove managed service identity from a app. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. examples There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/a/an |
||
| """ | ||
|
|
||
| helps['spring-cloud app identity show'] = """ | ||
| type: command | ||
| short-summary: Display app's managed identity info. | ||
|
leonard520 marked this conversation as resolved.
|
||
| """ | ||
|
|
||
| helps['spring-cloud app set-deployment'] = """ | ||
| type: command | ||
| short-summary: Set production deployment of an app. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,8 @@ def load_arguments(self, _): | |
| with self.argument_context('spring-cloud app create') as c: | ||
| c.argument( | ||
| 'is_public', arg_type=get_three_state_flag(), help='If true, assign public domain', default=False) | ||
| c.argument('assign_identity', arg_type=get_three_state_flag(), | ||
| help='Generate and assign an Azure Active Directory Identity for this app for use with key management services like Azure KeyVault.') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change the help text here too? |
||
|
|
||
| with self.argument_context('spring-cloud app update') as c: | ||
| c.argument('is_public', arg_type=get_three_state_flag(), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,7 +100,8 @@ def app_create(cmd, client, resource_group, service, name, | |
| runtime_version=None, | ||
| jvm_options=None, | ||
| env=None, | ||
| enable_persistent_storage=None): | ||
| enable_persistent_storage=None, | ||
| assign_identity=None): | ||
| apps = _get_all_apps(client, resource_group, service) | ||
| if name in apps: | ||
| raise CLIError("App '{}' already exists.".format(name)) | ||
|
|
@@ -119,8 +120,14 @@ def app_create(cmd, client, resource_group, service, name, | |
| resource = client.services.get(resource_group, service) | ||
| location = resource.location | ||
|
|
||
| app_resource = models.AppResource() | ||
| app_resource.properties = properties | ||
| app_resource.location = location | ||
| if assign_identity is True: | ||
| app_resource.identity = models.ManagedIdentityProperties(type="systemassigned") | ||
|
|
||
| poller = client.apps.create_or_update( | ||
| resource_group, service, name, properties, location) | ||
| resource_group, service, name, app_resource) | ||
| while poller.done() is False: | ||
| sleep(APP_CREATE_OR_UPDATE_SLEEP_INTERVAL) | ||
|
|
||
|
|
@@ -147,7 +154,10 @@ def app_create(cmd, client, resource_group, service, name, | |
| properties = models.AppResourceProperties( | ||
| active_deployment_name=DEFAULT_DEPLOYMENT_NAME, public=is_public) | ||
|
|
||
| app_poller = client.apps.update(resource_group, service, name, properties, location) | ||
| app_resource.properties = properties | ||
| app_resource.location = location | ||
|
|
||
| app_poller = client.apps.update(resource_group, service, name, app_resource) | ||
| logger.warning( | ||
| "[4/4] Updating app '{}' (this operation can take a while to complete)".format(name)) | ||
| while not poller.done() or not app_poller.done(): | ||
|
|
@@ -178,9 +188,13 @@ def app_update(cmd, client, resource_group, service, name, | |
| resource = client.services.get(resource_group, service) | ||
| location = resource.location | ||
|
|
||
| app_resource = models.AppResource() | ||
| app_resource.properties = properties | ||
| app_resource.location = location | ||
|
|
||
| logger.warning("[1/2] updating app '{}'".format(name)) | ||
| poller = client.apps.update( | ||
| resource_group, service, name, properties, location) | ||
| resource_group, service, name, app_resource) | ||
| while poller.done() is False: | ||
| sleep(APP_CREATE_OR_UPDATE_SLEEP_INTERVAL) | ||
|
|
||
|
|
@@ -425,6 +439,37 @@ def app_tail_log(cmd, client, resource_group, service, name, instance=None, foll | |
| raise exceptions[0] | ||
|
|
||
|
|
||
| def app_identity_assign(cmd, client, resource_group, service, name): | ||
| app_resource = models.AppResource() | ||
| identity = models.ManagedIdentityProperties(type="systemassigned") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you have plan to support other type? if yes better to expose type as a param with default value
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not yet. But we can refactor code if we will support in future. |
||
| properties = models.AppResourceProperties() | ||
| resource = client.services.get(resource_group, service) | ||
| location = resource.location | ||
|
|
||
| app_resource.identity = identity | ||
| app_resource.properties = properties | ||
| app_resource.location = location | ||
| return client.apps.update(resource_group, service, name, app_resource) | ||
|
|
||
|
|
||
| def app_identity_remove(cmd, client, resource_group, service, name): | ||
| app_resource = models.AppResource() | ||
| identity = models.ManagedIdentityProperties(type="none") | ||
| properties = models.AppResourceProperties() | ||
| resource = client.services.get(resource_group, service) | ||
| location = resource.location | ||
|
|
||
| app_resource.identity = identity | ||
| app_resource.properties = properties | ||
| app_resource.location = location | ||
| return client.apps.update(resource_group, service, name, app_resource) | ||
|
|
||
|
|
||
| def app_identity_show(cmd, client, resource_group, service, name): | ||
| app = client.apps.get(resource_group, service, name) | ||
| return app.identity | ||
|
|
||
|
|
||
| def app_set_deployment(cmd, client, resource_group, service, name, deployment): | ||
| deployments = _get_all_deployments(client, resource_group, service, name) | ||
| active_deployment = client.apps.get( | ||
|
|
@@ -441,7 +486,11 @@ def app_set_deployment(cmd, client, resource_group, service, name, deployment): | |
| resource = client.services.get(resource_group, service) | ||
| location = resource.location | ||
|
|
||
| return client.apps.update(resource_group, service, name, properties, location) | ||
| app_resource = models.AppResource() | ||
| app_resource.properties = properties | ||
| app_resource.location = location | ||
|
|
||
| return client.apps.update(resource_group, service, name, app_resource) | ||
|
|
||
|
|
||
| def deployment_create(cmd, client, resource_group, service, app, name, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,14 @@ class TraceProxyState(str, Enum): | |
| updating = "Updating" | ||
|
|
||
|
|
||
| class ManagedIdentityType(str, Enum): | ||
|
|
||
| none = "None" | ||
| system_assigned = "SystemAssigned" | ||
| user_assigned = "UserAssigned" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keep |
||
| system_assigned_user_assigned = "SystemAssigned,UserAssigned" | ||
|
|
||
|
|
||
| class TestKeyType(str, Enum): | ||
|
|
||
| primary = "Primary" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.