-
Notifications
You must be signed in to change notification settings - Fork 47
K8SPXC-1650 delete resources in azure #3646
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
base: master
Are you sure you want to change the base?
Conversation
…rcona-Lab/jenkins-pipelines into K8SPXC-1650_delete_resources_in_azure
cloud/azure/README.md
Outdated
| @@ -0,0 +1,7 @@ | |||
| # To redeploy function run in cmd folder: | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add to README where this script will be executed, where to check its logs, how to run it.
From DM: this is the only way to redeploy the functions.
It would be to have here smth like:
- The code is deployed and executed at (link)
- Logs of execution are (link/how to check if not obvious from the 1st)
- The script can not be redeployed/changed through interface. To redeploy download the script (how?) and run below (where?)
| @@ -0,0 +1,169 @@ | |||
| # Remove expired AKS clusters (Azure, cluster-only) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to have for future:
- There is a case where the cloud tag is present but the TTL is not correct (creatio time is missing/incorrect format). It would be good to receive a notification about such clusters to recheck why this happens and maybe update scripts corrspondingly.
| @@ -0,0 +1,14 @@ | |||
| 1. In the Azure portal, search for **Function App** (make sure the subscription is set to **eng-cloud-dev**). | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some intro, like: The cleanup scrips runs in Azure, to check it: do and then the steps
| resource_groups_client = ResourceManagementClient(credential, subscription_id) | ||
| aks_client = ContainerServiceClient(credential, subscription_id) | ||
|
|
||
| logging.info("Searching for AKS clusters to remove.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to ensure consistency, we are using 3 terms for the same thing (remove, delete, terminate) can we stick to just one and apply in the whole file?
| logging.info("[DRY-RUN] Would delete cluster %s/%s", rg_name, cluster_name) | ||
| return | ||
|
|
||
| aks_client.managed_clusters.begin_delete(rg_name, cluster_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems that this method returns https://learn.microsoft.com/en-us/python/api/azure-core/azure.core.polling.lropoller?view=azure-python
Any specific reason to have wait_for_cluster_delete and not use this?
aks_client.managed_clusters.begin_delete(rg_name, cluster_name).result(timeout=300) or
aks_client.managed_clusters.begin_delete(rg_name, cluster_name).wait(timeout=300)
PR provides the automatic deletion aks resources based on tags.
To use this script for your aks cluster please add tags during cluster creation:
--tags team=cloud delete-cluster-after-hours=1 creation-time=$(date -u +%s)