-
Notifications
You must be signed in to change notification settings - Fork 20
Enable AdoptedResource using latest code-gen logic for ScalableTarget #47
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 3 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 |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| ack_generate_info: | ||
| build_date: "2021-09-13T20:41:14Z" | ||
| build_hash: c6e8ce29423336f827d2ca5c737595561c84539c | ||
| build_date: "2021-09-14T01:33:26Z" | ||
| build_hash: 5a4809a4882a9beb39c737529907a3ebaff3910c | ||
| go_version: go1.14.14 | ||
| version: v0.13.2 | ||
| version: v0.14.0 | ||
| api_directory_checksum: a13caf20935ebb6193efdee1ab377cae33311ad7 | ||
| api_version: v1alpha1 | ||
| aws_sdk_go_version: v1.37.10 | ||
| generator_config_info: | ||
| file_checksum: 968c7d8481a61c0299fc373cc6d1692a52b55868 | ||
| file_checksum: f8ed39c2c7a95648bd194f7db3e2e2d8afdbe724 | ||
| original_file_name: generator.yaml | ||
| last_modification: | ||
| reason: API generation |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
mbaijal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
| # not use this file except in compliance with the License. A copy of the | ||
| # License is located at | ||
| # | ||
| # http://aws.amazon.com/apache2.0/ | ||
| # | ||
| # or in the "license" file accompanying this file. This file is distributed | ||
| # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| # express or implied. See the License for the specific language governing | ||
| # permissions and limitations under the License. | ||
|
|
||
|
|
||
| import boto3 | ||
|
|
||
| def application_autoscaling_client(): | ||
| return boto3.client("application-autoscaling") | ||
|
|
||
| def sagemaker_endpoint_register_scalable_target(resource_id): | ||
| target_input = { | ||
| "ServiceNamespace": "sagemaker", | ||
| "ResourceId": resource_id, | ||
| "ScalableDimension": "sagemaker:variant:DesiredInstanceCount", | ||
| "MinCapacity": 1, | ||
| "MaxCapacity": 2, | ||
| } | ||
|
|
||
| target_response = application_autoscaling_client().register_scalable_target(**target_input) | ||
| return target_response | ||
|
|
||
| def sagemaker_endpoint_put_scaling_policy(resource_id, policy_name): | ||
| policy_input = { | ||
| "PolicyName": policy_name, | ||
| "ServiceNamespace": "sagemaker", | ||
| "ResourceId": resource_id, | ||
| "ScalableDimension": "sagemaker:variant:DesiredInstanceCount", | ||
| "PolicyType": "TargetTrackingScaling", | ||
| "TargetTrackingScalingPolicyConfiguration": { | ||
| "TargetValue": 70.0, | ||
| "ScaleInCooldown": 700, | ||
| "ScaleOutCooldown": 300, | ||
| "PredefinedMetricSpecification": { | ||
| "PredefinedMetricType": "SageMakerVariantInvocationsPerInstance", | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| policy_response = application_autoscaling_client().put_scaling_policy(**policy_input) | ||
| return policy_response | ||
|
|
||
| def sagemaker_endpoint_deregister_scalable_target(resource_id): | ||
| target_input = { | ||
| "ServiceNamespace": "sagemaker", | ||
| "ResourceId": resource_id, | ||
| "ScalableDimension": "sagemaker:variant:DesiredInstanceCount", | ||
| } | ||
|
|
||
| target_response = application_autoscaling_client().deregister_scalable_target(**target_input) | ||
| return target_response | ||
|
|
||
| def sagemaker_endpoint_delete_scaling_policy(resource_id, policy_name): | ||
| policy_input = { | ||
| "ServiceNamespace": "sagemaker", | ||
| "ResourceId": resource_id, | ||
| "ScalableDimension": "sagemaker:variant:DesiredInstanceCount", | ||
| "PolicyName": policy_name | ||
| } | ||
|
|
||
| policy_response = application_autoscaling_client().delete_scaling_policy(**policy_input) | ||
| return policy_response | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| apiVersion: services.k8s.aws/v1alpha1 | ||
| kind: AdoptedResource | ||
| metadata: | ||
| name: $ADOPTED_POLICY_NAME | ||
| spec: | ||
| aws: | ||
| nameOrID: $RESOURCE_ID | ||
| additionalKeys: | ||
| serviceNamespace: sagemaker | ||
| kubernetes: | ||
| group: applicationautoscaling.services.k8s.aws | ||
| kind: ScalingPolicy | ||
| metadata: | ||
| name: $ADOPTED_POLICY_NAME |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| apiVersion: services.k8s.aws/v1alpha1 | ||
| kind: AdoptedResource | ||
| metadata: | ||
| name: $ADOPTED_TARGET_NAME | ||
| spec: | ||
| aws: | ||
| nameOrID: $RESOURCE_ID | ||
| additionalKeys: | ||
| serviceNamespace: "sagemaker" | ||
| scalableDimension: "sagemaker:variant:DesiredInstanceCount" | ||
| kubernetes: | ||
| group: applicationautoscaling.services.k8s.aws | ||
| kind: ScalableTarget | ||
| metadata: | ||
| name: $ADOPTED_TARGET_NAME |
Uh oh!
There was an error while loading. Please reload this page.