Skip to content

Commit

Permalink
Shutdown hours aks doc 2095 (#5069)
Browse files Browse the repository at this point in the history
* Update running-hours.md

* Update set-running-hours.md

* Update set-running-hours.md

* Update running-hours.md

* Update running-hours.md

* Update running-hours.md

* Update set-running-hours.md

* Update set-running-hours.md

* Update set-running-hours.md
  • Loading branch information
rickshar authored Dec 9, 2024
1 parent b032a10 commit 4db8b77
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 46 deletions.
50 changes: 31 additions & 19 deletions src/docs/ocean/features/running-hours.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,58 @@
# Shutdown Hours

Another way to achieve cost savings with Ocean is to use the Shutdown Hours feature. In Ocean, you can build a weekly schedule defining the hours in which your cluster will be up and running. You are charged only for the running hours. In the hours you don't specify, the cluster is down, i.e., the underlying instances of the cluster's nodes are scaled down to zero. You are not charged during this time.
Use shutdown hours to achieve cost savings with Ocean.
You can build a weekly schedule for the hours your cluster is up and running. You are charged only for the running hours.
For the hours you don't specify, the cluster is down so that the underlying instances of the cluster's nodes are scaled down to zero. You are not charged during this time.

The Shutdown Hours feature is recommended for non-production environments (e.g., development, testing, staging) where you are sure you do not require 24 x 7 availability.
Shutdown Hours are recommended for non-production environments (e.g., development, testing, staging) where you are sure you do not require 24/7 availability.

## Sample Weekly Schedule

<img src="/ocean/_media/features-running-hours-00.png" />

The example above shows a weekly schedule with running hours indicated in blue and off hours in gray.
The running hours are in blue, and the off hours are in gray.

- You can define running hours in minimum chunks of 30 minutes.
- The schedule appears in your local time, but Ocean uses UTC time zone internally.
- The schedule appears according to your local time, but Ocean uses the UTC time zone internally.

## Scaling Behavior (Ocean For Kubernetes)
## Scaling Behavior (Kubernetes)

When a period of running time ends, Ocean automatically scales down the entire cluster to 0. During the off time, all nodes are down, the Ocean Controller is down, and it does not report any information to the autoscaler.
When a period of running time ends, Ocean automatically scales down the entire cluster to 0. During the off time, all nodes are down, the Ocean Controller is down, and does not report information to the autoscaler.

At the end of the off time, Ocean starts a single node from a VNG that has no taints. (If all of the VNGs have taints, Ocean would start a node from the default VNG, unless `useAsTemplateOnly` is defined, in which case no node would be started. It would be up to the user to ensure the controller is running, possibly on a node that is not managed by Ocean.)
When off time ends, Ocean starts a single node from a virtual node group without taints.
If all virtual node groups have taints, Ocean starts a node from the default virtual node group unless `useAsTemplateOnly` is defined, in which case no node is started.
In the latter case, check that the controller is running, possibly on a node not managed by Ocean.

Once the node is launched and registered to the Kubernetes cluster, the Ocean Controller is scheduled on that node. (Ocean always schedules the controller first in order to report the cluster state to the autoscaler.)
Once a node is launched and registered to the Kubernetes cluster, the controller is scheduled on that node.
Ocean always first schedules the controller to report the cluster state to the Ocean autoscaler.

The controller immediately reports the unscheduled pods in the cluster to Ocean's autoscaler, and the autoscaler launches the appropriate types and number of nodes to provide the resources required by the current unscheduled pods.
The controller immediately reports unscheduled pods in the cluster to the autoscaler, and the autoscaler launches the appropriate types and number of nodes to provide the resources required by the current unscheduled pods.

At the end of this process, all pods are satisfied, and the cluster is fully functioning in the running hours scheduled.
At the end of this process, all pods are satisfied, and the cluster fully functions in the scheduled running hours.

Note: The Shutdown Hours feature is not supported for GKE clusters with shielded nodes. If you use the Shutdown Hours feature with shielded nodes, you need to ensure that the Ocean controller is available at the end of the off time, by checking that it is running on a node that is not managed by Ocean. This is because the Ocean controller is part of the node registration process and requires an available node to run on.
>**Note:** Shutdown Hours are unsupported for GKE clusters with shielded nodes. If you use shutdown Hours with shielded nodes, ensure that the Ocean controller is available at the end of the off time by checking that it runs on a node that Ocean does not manage. This is because the controller is part of the node registration process and requires an available node to run on.
## Scaling Behavior (Ocean For ECS)
## Scaling Behavior (AWS ECS)

When a period of running time ends, Ocean automatically scales down the entire cluster to 0. During the off time, all container instances are down.

At the end of the off time, the autoscaler launches the appropriate types and number of container instances to provide the resources required by the unscheduled tasks. At the end of this process, all tasks are satisfied, and the cluster is fully functioning in the running hours scheduled.
When off time ends, the autoscaler launches the appropriate types and number of container instances to provide the resources the unscheduled tasks require.
At the end of this process, all tasks are satisfied, and the cluster fully functions in the scheduled running hours.

## Shutdown Hours per VNG (Ocean for Kubernetes AWS)
## Shutdown Hours per Virtual Node Group

You can define shutdown hours per virtual node group (VNG) so that VNGs will shut down at different times. In some cases, different VNGs require different shutdown hours. For example, teams working on different VNGs may need to scale down the infrastructures related to each VNG at different times.
Cloud service provider relevance: <font color="#FC01CC">AWS Kubernetes</font>, <font color="#FC01CC">AKS</font>

### Related VNG and Cluster Behavior
You can define shutdown hours per virtual node group via the Spot API to shutdown groups at different times.
For example, teams working on different virtual node groups may need to scale down the infrastructures related to each group at different times.

- Cluster shutdown hours have higher priority. For example, if the cluster is in its shutdown hours, a scheduled wake-up of the VNG during this time would not happen.
- When a VNG comes back up, it automatically scales to the minimum nodes configured.
### Virtual Node Group and Cluster Priorities

- Cluster shutdown hours have higher priority. For example, if the cluster is in shutdown hours, a scheduled wake-up of a virtual node group in the cluster will not occur during this time.
- When the virtual node group is up again, it automatically scales to the minimum nodes configured.

## Related Topics

[Set Shutdown Hours (Console and API)](https://docs.spot.io/ocean/tutorials/set-running-hours)

This feature is available using the [Create](https://docs.spot.io/api/#operation/OceanAWSLaunchSpecCreate) and [Update](https://docs.spot.io/api/#operation/OceanAWSLaunchSpecUpdate) APIs for AWS. For setup information, see [Set Shutdown Hours per VNG](ocean/tutorials/set-running-hours?id=set-shutdown-hours-per-vng).

52 changes: 25 additions & 27 deletions src/docs/ocean/tutorials/set-running-hours.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,45 @@
# Set Shutdown Hours

This tutorial describes how to build a weekly schedule defining the hours in which the workloads in your cluster will be up and running and the shutdown hours.
>**Important:** Before you set shutdown hours, you must configure the minimum capacity in the Ocean cluster to 0.
## Relevance
## Schedule Shutdown Hours in the Console

This tutorial is relevant for Kubernetes and ECS users.
1. Click **Ocean > Cloud Clusters** on the main menu on the left.
2. Select a cluster from the list of clusters.
3. At the top-right of the screen, click the **Actions** menu and select **Customize Scaling**.
4. Turn on the Cluster Shutdown Hours by moving the slider to the right.

## Prerequisite
![aks-cluster-shutdown-hours](https://github.com/user-attachments/assets/4561cd2f-598f-4896-9f62-43ac6f83184e)

Before you set the shutdown hours, you must configure the minimum capacity in the Ocean cluster to 0.
5. Set your shutdown (off)/running hours by clicking or dragging the mouse in the timetable. The selected chunk changes from blue to gray color.
6. Save your changes.

## Schedule Your Shutdown Hours
>**Note:** If you need to change the schedule during off-hours, you can do so without instantly waking up the cluster. The cluster will wake up only when you activate it manually by making a capacity change.
To schedule your Shutdown hours, do the following:
## Schedule Shutdown Hours in the API for the Cluster

1. In your Ocean cluster, click Actions and choose Customize Scaling.
You can schedule shutdown hours with the Spot API parameter `cluster.scheduling.shutdownHours`.
The time range defined in the API represents the ranges in which the cluster will be scaled to zero.
The API uses this mechanism to reduce the chances of a human error that would cause an unwanted scale-down to zero.

<img src="/ocean/_media/tutorials-set-running-hours-01a.png" />
The value defined in the `shutdownHours.timeWindows` field is effective only when the `shutdownHours.isEnabled` field is set to `true`.

2. Click Cluster Shutdown Hours.
## Schedule Shutdown Hours in the API per Virtual Node Group

<img src="/ocean/_media/tutorials-set-running-hours-02b.png" />
Cloud service provider relevance: <font color="#FC01CC">AWS Kubernetes</font>, <font color="#FC01CC">AKS</font>

3. Set your shutdown hours by clicking or dragging the mouse in the timetable.
4. Click Update.
You can use the Spot API to configure [shutdown hours](ocean/features/running-hours?id=shutdown-hours-per-vng) for one or more individual virtual node groups.

## During Off Hours
For AWS Kubernetes, set shutdown hours under: `launchSpec.scheduling.shutdownHours`:
* [Create VNG](https://docs.spot.io/api/#operation/OceanAWSLaunchSpecCreate)
* [Update VNG](https://docs.spot.io/api/#operation/OceanAWSLaunchSpecUpdate)

If you need to change the schedule during the off hours, you can do so without causing the cluster to `wake up` instantly. The cluster will wake up only when you activate it manually by making a capacity change.
>**Note:** `isEnabled` must be set to **True** to turn on shutdown hours.
## Using The API
For AKS, set shutdown hours under:
* [Create VNG](https://docs.spot.io/api/#tag/Ocean-AKS/operation/oceanAKSVirtualNodeGroupCreate)
* [Update VNG](https://docs.spot.io/api/#tag/Ocean-AKS/operation/oceanAKSVirtualNodeGroupUpdate)

You can also configure shutdown hours using the API parameter cluster.scheduling.shutdownHours. The time range defined in the API represents the ranges in which the cluster will be scaled to zero. The API uses this mechanism in order to reduce chances of a human error that would cause an undesired scale-down to zero.

> **Tip**: The value defined in the `shutdownHours.timeWindows` field is effective only when the `shutdownHours.isEnabled` field is set to `true`.

## Set Shutdown Hours per VNG

You can use the API (AWS) to configure [shutdown hours](ocean/features/running-hours?id=shutdown-hours-per-vng) for one or more individual VNGs.

Use the [Create](https://docs.spot.io/api/#operation/OceanAWSLaunchSpecCreate) or the [Update](https://docs.spot.io/api/#operation/OceanAWSLaunchSpecUpdate) VNG API to set up the shutdown hours. Configure it under: `launchSpec.scheduling.shutdownHours` as shown below.

Note that `isEnabled` must be set to True in order to enable the shutdown hours.

<img src="/ocean/_media/tutorials-set-running-hours-03.png" width="278" height="514" />

0 comments on commit 4db8b77

Please sign in to comment.