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:


  1. 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)
  2. action: Choose the action to be performed with the "do_not_scale_down" label. Valid choices are "get", "add", and "delete".
  3. clusterName: Select the target cluster where the Kubernetes namespace is located.
  4. projectName: Select the target project where the Kubernetes namespace is located.

Actions

  1. 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.   

  2. Add: Adds the "do_not_scale_down" tag to the specified Kubernetes namespace.

  3. Delete: Removes the "do_not_scale_down" tag from the specified Kubernetes namespace.

Usage

  1. Select the Jenkins job and click on "Build with Parameters" to provide the required input.
  2. 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)

  3. Choose the desired action from the available options: "get", "add", or "delete".

  4. Select the target cluster by choosing the appropriate option from the "clusterName" parameter dropdown.

  5. Select the target project by choosing the appropriate option from the "projectName" parameter dropdown.

  6. Click on "Build" to execute the job with the provided parameters

Examples

  1. 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.

  2. 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.

  3. 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.