Skip to Content
Core InfraWorkload RightsizingInit Containers

Init Containers Optimization
Available in v1.20.6+

Background

In Kubernetes, init containers run sequentially - one after another - before any app containers start. Because of that, Kubernetes does not add up their requests like it does for app containers.

For each init container, Kubernetes notes its CPU and memory requests. The Pod’s effective request for scheduling is the maximum between the highest init container request and the sum of all app container requests. This can cause problems if the application container requests are not aligned with the init container requests, potentially leading to resource waste.

ScaleOps Init Containers Optimization

ScaleOps provides automated optimization for init containers to help prevent resource waste.

Policy Toggle

Init Containers Optimization is controlled via a policy field. This field is enabled by default on all policies.

Init Containers Policy

Recommendation Logic

For each init container, ScaleOps recommends and applies the highest request that does not increase the Pod’s effective requests. This ensures optimal resource allocation while maintaining the same scheduling requirements.

Optimization Notes:

  • ScaleOps respects and keeps the original limits of the init container.
  • Some policy fields are not applied to init containers optimization (headroom, percentiles).

Auto Init Container Healing

If an init container fails, ScaleOps will elevate its requests up to the original declared request to ensure reliable startup.

Visibility and Troubleshooting

Filter for Init Container Workloads

A dedicated filter option is available to quickly display all workloads with init containers.

Init Containers Filter

Init Containers Visibility

Multiple graphs allow visibility into init containers.

Workload

In the workload overview, you can select init container to view init container specific information.

Init Containers Overview

In the workload troubleshoot view you can explore additional graphs to learn more about init containers behavior:

  • Init Container CPU Request Overhead: Graph showing the extra allocated CPU each pod in the workload has due to init containers
  • Init Container Memory Request Overhead: Graph showing the extra allocated memory each pod in the workload has due to init containers
  • Init Containers Exit Codes: Graph showing the init container exit codes over time

Cluster

In the cluster troubleshoot view, you can identify workloads with the most extra allocated resources due to init containers.

  • Init Container Memory Request Overhead Workloads - Showing workloads with the highest init container memory request extra allocation
  • Init Container CPU Request Overhead Workloads - Showing workloads with the highest init container CPU request extra allocation

Custom Owner Grouping Compatibility

ScaleOps supports optimization for all init containers. However, custom owner grouping that includes workloads with different init container names or different init container order is not supported for init container optimization.