Skip to main content

gcp-as

Last updated on

Prerequisite: Set Up Proxy

Set up a proxy or load balancer that will intercept and manage traffic to your resources. This component is what enables the seamless start/stop functionality.

An AutoStopping Proxy is a virtual machine that sits in front of your virtual machines and intelligently starts or stops them based on incoming traffic. It supports both HTTP(S) and TCP connections. Built on the proven, open-source Envoy Proxy, the AutoStopping Proxy is capable of managing traffic for multiple AutoStopping-managed VMs from a single instance

  1. In Harness, go to the Cloud Costs module. Click on AutoStopping Rules from left Navbar.

  2. Click Load Balancers.

  3. Click +Create New Load Balancer. Click Create New AutoStopping Proxy.

  4. Enter a name and select GCP in Cloud Provider.

  5. Choose an existing connector or create a new one.

  6. Enter Autostopping Proxy Configuration.

    • Region: Select the GCP region where your target resources are hosted
    • Zone: Select the zone from the dropdown list.
    • VPC: Select the Virtual Private Cloud where your resources are located
    • Network tags: Select the Network tags to enable ports on the proxy VM which would be receiving traffic or the one that would be used to access the proxy.
    • Subnet: Select the subnet for the proxy deployment
    • Machine type: Select an appropriate AWS instance type for the proxy
      • Choose based on your expected traffic volume and performance needs
    • TLS Certificate Secret Version: Create a secret in your GCP account. Go to Create a secret.
    • TLS Private Key Secret Version: Provide the ARN of your private key secret
    • API Key: Enter a valid NG API key. Choose No Expiration in the Expiration dropdown list while creating this API key. Go to Create an API Key for more information.
    • [OPTIONAL] Enable Allocate Static IP if you need to assign an elastic IP address to make the VM publicly accessible. Update the DNS route to point to the public IP. You don't need to enable this field it is pointing to a private IP provided the DNS resolves. For example, when the DNS resolution is done within the VPC.
  7. Click Save AutoStopping Proxy.

note

Ensure that the file uploaded in the Secret value field is not encrypted or encoded. It must be a plaintext certificate.


Create AutoStopping Rule

  • In Harness, navigate to Cloud Costs > AutoStopping Rules and click New AutoStopping Rule.
  1. Enter a Name for your rule
  2. AutoStopping Type: Choose how you want your resources to be managed automatically. You can either choose Traffic-based with schedules optionally or Schedules only.
    • Traffic-based with schedules optionally: Resources automatically stop when idle and restart when traffic is detected. You can configure schedule overrides in advanced settings.
    • Schedules only: Resources automatically start and stop based on defined schedules. You can configure multiple schedules in advanced settings.
info

Please note: Schedule-only rules ccxcxdan be changed to traffic-based during edit, but traffic-based rules cannot be reverted to schedule-only. (Schedules on traffic-based rules remain editable)

  1. Set the Idle Time - how long an instance should be inactive before stopping
  2. From the Resources to be managed section, choose the resource type you want to manage:

Click on + Add an instance. Add the instances that you want to manage by this rule.


Advanced Configuration (Optional):

  • Hide Progress Page: Toggle this to disable the display of a progress page during instance warm-up.
  • Dry-Run: Toggle this button if you wish to evaluate the feature without terminating your cloud resources.

Link your rule to other AutoStopping rules if resources depend on each other.

  • Click Add Dependency and select a rule from the RULES drop-down list.
  • In DELAY IN SECS, enter the number of seconds the dependent rule should wait after warming up before warming up this rule.
Click to expand advanced configuration details

(Optional) Set up advanced configuration

In this step, you can configure the following settings:

Hide progress page

Toggle the button to disable the display of progress page during instances' warming up process. This option is especially useful when the service is invoked by an automation system, as it prevents misinterpretation of the progress page as the intended response from a service that is onboarded to AutoStopping. By hiding the progress page, the first response of warming up a rule after a downtime will be delayed until the intended service is up and running.

Dry Run

Toggle the button if you wish to evaluate this feature without terminating your cloud resources.

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 dependent on a database server, create two AutoStopping Rules managing both the servers. Add a dependency on the Rule managing the application server to be dependent 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 first Rule 2 (dependent rule) is warmed up, and then there is a delay of 5 seconds before warming up Rule 1.
  4. Once you're done with all the configurations, click Next.

Fixed Schedule

Create fixed uptime or downtime schedules for the resources managed by this AutoStopping Rule. When a resource is configured to go up or down on a fixed schedule, it is unaffected by activity or idleness during that time period.

In certain scenarios, you would not want your resources to go down or up. For example, every Friday at 5 p.m. you want your ABC resource to go down. You can schedule downtime for your ABC resource. During this window, the resource is forced to go down regardless of the defined rule. You can choose to specify uptime for your resources in the same way.

note

The fixed schedule takes precedence over the defined AutoStopping Rule.

note

Harness executes scheduled rules using Dkron, an open-source workload automation service.

To create a fixed schedule for your rule, do the following:

  1. In Fixed Schedules, click Add Fixed Schedule.
  2. In New Fixed Schedule, enter a Name for your schedule.
  3. In Type, select the type for your schedule. You can schedule an Uptime or Downtime for your rule. As per your schedule, the resources go up or down.
  4. Select the Time Zone from the drop-down list.
  5. In Set schedule period, use the date picker to set the start and end time for your schedule.
    1. In Begins on, select the start date and time for your schedule. You can select a date and specify the time.
    2. In Ends on, select the end date and time for your schedule. You can select a date and specify the time. Ensure that Never ends checkbox is unselected to set the end time.
    If you don't specify an end time, the schedule continues to run until you manually update the settings or remove the schedule.
  6. Select the checbox Never ends if you do not want to set end time for your schedule.
  7. You can also set a recurring schedule for the rule. If you want to set a recurring schedule, in Uptime/Downtime in the selected period, in Repeats, select the repeat frequency.
    1. Select which days of the week you'd like your schedule to repeat. You can choose any day between Sunday and Saturday.
    2. Select Everyday, to set the schedule for all seven days of the week.
    3. Set your repeat schedule's beginning and ending time. In the Time field, specify the start and end time for the fixed schedule.
    4. Select All Day, if you wish to set your schedule for the entire day. If you choose All Day for your schedule, you won't be able to choose a start and end time.

GCP AutoStopping Savings Computation

There are two types of exports in GCP: Standard and Detailed. Ensure the billing export is the detailed billing export. It is important to have a billing-enabled connector set up with detailed billing exports. The billing data will be used to compute savings for GCP instance and instance-group-based rules.