CloudNatix logo

Tutorial

Step 3. Optimize Your Kubernetes Clusters and Workloads

CloudNatix provides several optimization technologies, including workload rightsizing, cluster rightsizing, and Spot rebalancing. In this tutorial, we walk through the workload rightsizing and the cluster rightsizing.

Please see this page to understand the optimization technologies provided by CloudNatix in more details.

Please also note that it will take some time until CloudNatix collects sufficient performance metrics and starts generating recommendations.

Step 3.1. Review workload rightsizing recommendations

Workload rightsizing optimizes resource allocation to individual workloads based on their historical usage.

You can review the workload rightsizing recommendations through the insights page. Click the "insights" link at the left navigation bar.

img

Each item indicates a recommendation of a workload. By default, those items are ordered by the amount of estimated savings, but you can change the ordering from the top-right menu and you can filter from the left navigation.

img

When you click the blue text in a card, you will be navigated to the details of the workload page and see more details of the recommendation.

img

In the above screenshot, the purple and the light blue area graph respectively indicates the average and max CPU usage. The dark blue line graph indicates the recommended CPU request while the green line indicates the currently configured CPU request.

Alternatively, you can also review the workload rightsizing recommendation from the workload page. Click the "workloads" link at the left navigation bar, and expand a workload row and go to to the recommendation tab. The tab shows the current CPU/memory usage as well as recommended CPU/memory request. You can review the generated recommendation and check if it is a reasonable one.

img

This shows the same graph and controls; similarly the purple and the light blue area indicates the average and max CPU usage. The dark blue line graph indicates the recommended CPU request.

You can also review all the workload rightsizing recommendations by running the following commands:

cnatix recommendations workloads summary \
  --cluster-name=my-cluster \
  --output=extend

Step 3.2. Apply workload rightsizing recommendations

CloudNatix is not just for reviewing workload rightsizing recommendations. You can apply the recommendations to your workloads easily. The recommendation can be applied with the Autopilot mode, where the recommendation is automatically and continuously applied.

To apply the recommendation, you can take one of the following steps:

  • GUI: Click the "Apply recommendation" or "Enable autopilot" from the recommendation tab.
  • CLI: Run cnatix recommendations workloads apply.
  • K8s annotation: Set the recommendation.cloudnatix.com/mode: auto annotation.

Users can pick up the best option that works for their workflow.

Here is a screenshot for applying Autopilot from GUI.

img

If you switch the mode from "Manual" to "Autopilot" and click "Enable autopilot", the above confirmation dialog shows up.

Here is an example CLI command that enables the Autopilot mode for kindnet.

cnatix recommendations workloads apply \
  --cluster-name my-cluster \
  --kind Daemonset \
  --namespace kube-system \
  --name kindnet

If you manage your workloads via CI/CD pipeline, using a K8s annotation will be the most suited approach since you can manage your Autopilot configuration together with a workload spec.

Here is again an example command that uses the k8s annotation to enable the Autopilot mode.

kubectl annotate daemonset kindnet \
  -n kube-system \
  recommendation.cloudnatix.com/mode=auto

Step 3.3. Review cluster rightsizing recommendations

Cluster rightsizing recommends the optimal configuration of the cluster (e.g., number of nodes, instance type). CloudNatix generates the recommendation by running a scheduling simulation that takes workload historical usage and various scheduling constraints into account.

The generated recommendations can be viewed from the "Recommendations" of the Clusters page.

img

This page shows the recommendation summary, heat-map comparison, and the detailed configuration change.

The Kind cluster has one node of 8 cores, but the cluster rightsizing algorithm recommends one node of 4 cores.

The cluster rightsizing recommendation provides more interesting results when you have heterogeneous complex workloads running in your clusters and you are not sure about the best instance type for the cluster (e.g., should it be generic, compute-intensive, or memory-intensive?).

Previous
Step 2. Interact with Your Workloads
Next
Step 4. Understand Your Infrastructure from Dashboard