Manage do_not_scale_down Kubernetes tag
This Jenkins job allows you to manage Kubernetes tags, specifically the "do_not_scale_down" label, in a project.
The job provides functionality to get tags, add a tag, and delete a tag from a specified Kubernetes namespace.
Main purpose
The main purpose of this job is to control the shutdown behavior of the namespace based on the presence of the "do_not_scale_down" tag. When the "do_not_scale_down" tag is assigned to a namespace, it prevents the namespace from being shut down during nights and weekends.
Additionally, the tag will be automatically removed on Mondays.
Job Parameters
The job requires the following parameters to be provided when running:
- timeline: Choose what timeline period you would like to keep your environment up and running: tonight - from this night only(from Monday to Thursday), up_to_next_monday - up to next Monday(you could use it from any day of week, for example applying the tag from Tuesday will keep environment up and running until next Monday or untill you remove the tag manually with the Jenkins job)
- action: Choose the action to be performed with the "do_not_scale_down" label. Valid choices are "get", "add", and "delete".
- clusterName: Select the target cluster where the Kubernetes namespace is located.
- projectName: Select the target project where the Kubernetes namespace is located.
Actions
Get: Retrieves the tags from the specified Kubernetes namespace and displays them. If the "do_not_scale_down" tag exists, it will be added to the job description for reference.
Add: Adds the "do_not_scale_down" tag to the specified Kubernetes namespace.
Delete: Removes the "do_not_scale_down" tag from the specified Kubernetes namespace.
Usage
- Select the Jenkins job and click on "Build with Parameters" to provide the required input.
Select what time period you need to keep environment up and running: tonight - from this night only(from Monday to Thursday), up_to_next_monday - up to next Monday(you could use it from any day of week, for example applying the tag from Tuesday will keep environment up and running until next Monday or untill you remove the tag manually with the Jenkins job)
Choose the desired action from the available options: "get", "add", or "delete".
Select the target cluster by choosing the appropriate option from the "clusterName" parameter dropdown.
Select the target project by choosing the appropriate option from the "projectName" parameter dropdown.
Click on "Build" to execute the job with the provided parameters
Examples
Get action:
- timeline: tonight
- action: get
- clusterName: dev
- projectName: unam
This will retrieve the tags from the Kubernetes namespace in the "unam" project of the "dev" cluster. If the "do_not_scale_down" tag exists, it will be displayed in the job description.
Add action:
- timeline: tonight
- action: add
- clusterName: dev
- projectName: unam
This will add the "do_not_scale_down" tag to the Kubernetes namespace in the "unam" project of the "dev" cluster and keep environment up and running during next night.
Delete action:
- timeline: tonight
- action: delete
- clusterName: dev
- projectName: unam
This will remove the "do_not_scale_down" tag from the Kubernetes namespace in the "unam" project of the "dev" cluster.