Create AutoStopping Rules for a Kubernetes Cluster

Updated 1 month ago by Archana Singh

Currently, this feature is in Beta.

AutoStopping Rules make sure that your non-production resources run only when used, and never when idle. It also allows you to run your workloads on fully orchestrated spot instances without any worry of spot interruptions.

In this topic:

Before You Begin

Review: Kubernetes Coverage

The following section lists the support for Kubernetes clusters for AutoStopping Rules:

  • EKS (AWS)
  • GKE (GCP)
  • AKS (Azure)
  • kOps

Prerequisites

Perform the following steps to link your Kubernetes cluster to Harness for creating AutoStopping Rules:

  1. In Cloud Costs, in AutoStopping Rules, click New AutoStopping Rule.
  2. In AutoStopping Rules, select the cloud account. It is the cloud account in which your workloads are running that you want to manage using AutoStopping Rules.

    You can select any of the following cloud account types:
    - AWS
    - Azure
    - GCP

  1. If you have already linked your cloud account and want to use that account, then select your cloud account from the drop-down list.
  2. If you have not added your cloud account, click Connect to your Cloud Account drop-down list. The name of the drop-down list depends on the cloud account type selection. If you select AWS, then the label reads as Connect to your AWS account.

    For the detailed steps, see the Create a Kubernetes Connector for AutoStopping Rules.

Step 2: Add a New AutoStopping Rule

Perform the following steps to add a new AWS AutoStopping rule for Kubernetes clusters:

Step 1: Define an AutoStopping Rule

Perform the following steps to get started with AutoStopping Rule.

  1. In Cloud Costs, in AutoStopping Rules, click New AutoStopping Rule.
  2. In the cloud account type, select your cloud account. For example, AWS. It is the cloud account in which your workloads are running that you want to manage using AutoStopping rules.
  3. Select your cloud account from the Connect to your Cloud Account drop-down list. The name of the drop-down list depends on the cloud account type selection. If you select AWS, then the label reads as Connect to your AWS account.

    For the detailed steps, see Create a Kubernetes Connector for AutoStopping Rules.
  4. In Define your AutoStopping rule, in Name your Rule, enter a name for your rule. This is the name of your AutoStopping rule.
  5. In Idle time, enter the idle time in minutes. This is the time that the AutoStopping rule will wait before stopping the idle instances.

Step 2: Select the Resources to be Managed by the AutoStopping Rule

Select the cloud resources that you want to manage using this rule. AutoStopping Rule will monitor the selected resources and stop them when they are idle beyond the configured idle time.

  1. Select Kubernetes Cluster and then click Add a cluster.
  2. Select the Kubernetes cluster that you want to manage using the AutoStopping rules. If you wish to create a new connector for the Kubernetes cluster, see Create a Kubernetes Connector for AutoStopping Rules.
  3. Once you have finished selecting the Kubernetes cluster, click Add selected.

(Optional) Step 3: Set Up Advanced Configuration

In this step, you can configure the following settings:

Hide Progress Page

Toggle the button to enable or disable the instances warming up progress status. If you turn this ON, the progress status will not be displayed.

Add Dependency

Set dependencies between two or more AutoStopping Rules when you want one Rule to make one or more Rules to be active based on the traffic that it receives. For example for an application server dependant on a database server, create two AutoStopping Rules managing both the servers. Add a dependency on the Rule managing the application server to be dependant on the Rule managing the database server.

  1. Click add dependency to add a dependency on any existing rule.
  2. Select the rule from the RULES drop-down list.
  3. In DELAY IN SECS, enter the number of seconds that rule should wait after warming up the dependent rule. For example, you have Rule 1 dependent on Rule 2 and you have set 5 seconds delay. In that case, when the request is received to warm up Rule 1, then Rule 2 (dependent rule) is warmed up first, and then there will be a delay of 5 seconds before warming up Rule 1.
  4. Once you're done with all the configurations, click Next.

Step 3: Setup Access

In this step, update the resource definition YAML of the Kubernetes AutoStopping Rule that will be applied to the cluster.

Ingress

The specification in the YAML file is the same as a Kubernetes Ingress with additional metadata. These are the configurations to the Ingress that the AutoStopping Rule will create for your Service.

Update the following parameters with the correct HTTP/HTTPS service details:

  • (Optional) host: Enter the domain name. If a host is provided (for example, qa.harness.com), the rule applies to that host. If you do not specify the domain name, the ingress created will match requests to all the domains.
  • name: Enter the name of your Kubernetes service. For example, test.
  • port: Enter the port number. For example, 80.
  • For more information, see The Ingress Resource.

    apiVersion: ccm.harness.io/v1
    kind: AutoStoppingRule
    metadata:
    name: testK8s
    namespace: default
    annotations:
    harness.io/cloud-connector-id: awstest3
    nginx.ingress.kubernetes.io/configuration-snippet: 'more_set_input_headers "AutoStoppingRule: default-testK8s";'
    spec:
    idleTimeMins: 15
    hideProgressPage: false
    ingress:
    rules:
    - host: <replace with your domain name, for example, qa.harness.com>
    http:
    paths:
    - path: /
    pathType: Prefix
    backend:
    service:
    name: <replace your service name, for example, test>
    port:
    number: <replace with your service port, for example, 80>

Non-Ingress

If your workload is non-ingress type, copy the following YAML and edit the metadata. These are the configurations to the Non-Ingress that the AutoStopping Rule will create for your Service.

Edit the metadata with correct service details:

apiVersion: ccm.harness.io/v1
kind: AutoStoppingRule
metadata:
name: <postgres>
namespace: <dev-poc>
annotations:
harness.io/cloud-connector-id: <connector_id>
spec:
idleTimeMins: <40>
workloadName: <postgres>
workloadType: <Deployment>

  1. Once you have updated the YAML file with all the details, click Validate YAML to proceed.
  2. Click Next once the YAML is validated.
  3. Click Save Rule.

Next Step


Please Provide Feedback