HorizontalPodAutoscaler cannot monitor CPU utilization for pods with init containers and pods with init containers do not autoscale in Red Hat OpenShift Container Platform 4.5 and 4.6.

Solution Verified - Updated -

Issue

HorizontalPodAutoscaler cannot monitor CPU utilization for pods with init containers and pods with init containers do not autoscale in Red Hat OpenShift Container Platform 4.5 and 4.6.

oc describe podmetrics shows for the init containers Memory: 0, but no CPU metric::

Name:         test
Namespace:    test
Labels:       <none>
Annotations:  <none>
API Version:  metrics.k8s.io/v1beta1
Containers:
(...)
  Name:     container-name
  Usage:
    Memory:  0                                         # <--------------- absence of CPU metric here indicates the bug
(...)
Kind:        PodMetrics
(...)

oc get hpa shows UNKNOWN CPU utilization:

NAME                                         REFERENCE                                               TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
test                                             Deployment/test                                         <unknown>/80%   2         2         2          7d

oc describe hpa shows:

Events:
  Type     Reason                        Age                    From                       Message
  ----     ------                        ----                   ----                       -------
  Warning  FailedComputeMetricsReplicas  171m (x4026 over 19h)  horizontal-pod-autoscaler  invalid metrics (1 invalid out of 1), first error is: failed to get cpu utilization: did not receive metrics for any ready pods
  Warning  FailedGetResourceMetric       99s (x4705 over 19h)   horizontal-pod-autoscaler  did not receive metrics for any ready pods

Environment

Red Hat OpenShift Container Platform 4.5
Red Hat OpenShift Container Platform 4.6

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content