“error: no kind is registered for the type v2beta2.HorizontalPodAutoscaler” when deploying an HorizontalPodAutoscaler in OpenShift Container Platform 4

Solution Verified - Updated -

Issue

An error will be returned when trying to deploy using oc new-app CLI and a Template with HorizontalPodAutoscaler autoscaling/v2beta2 on the Template object list:

error: no kind is registered for the type v2beta2.HorizontalPodAutoscaler in scheme "github.com/openshift/oc/pkg/cli/newapp/scheme.go:23"

Example Template:

kind: Template
apiVersion: template.openshift.io/v1
metadata:
  name: template-ubi
objects:
- kind: DeploymentConfig
  apiVersion: apps.openshift.io/v1
  metadata:
    name: hpa-deploymentconfig
  spec:
    selector:
      app_name: hpa-deploymentconfig
      deploymentconfig: hpa-deploymentconfig
    template:
      metadata:
        labels:
          app_name: hpa-deploymentconfig
          deploymentconfig: hpa-deploymentconfig
        name: hpa-deploymentconfig
      spec:
        containers:
          - image: registry.access.redhat.com/ubi8/ubi:8.5-226
            name: hpa-deploymentconfig
- apiVersion: autoscaling/v2beta2 
  kind: HorizontalPodAutoscaler
  metadata:
    name: hpa-test-hpa-resource-metrics-memory
  spec:
    scaleTargetRef:
      apiVersion: apps.openshift.io/v1
      kind: DeploymentConfig 
      name: hpa-deploymentconfig 
    minReplicas: 1 
    maxReplicas: 10
    metrics: 
    - type: Resource
      resource:
        name: memory 
        target:
          type: Utilization 
          averageUtilization: 70

API autoscaling/v2beta2 it's required to be used for autoscaling based on memory utilization according to Creating a horizontal pod autoscaler object for memory utilization by using the CLI.

Environment

  • OpenShift Container Platform 4

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