How to setup the OpenShift's Horizontal Pod Autoscaler (HPA) with Red Hat build of Keycloak ?

Solution Unverified - Updated -

Environment

  • Red Hat build of Keycloak

    • 26.2+
  • Red Hat OpenShift Container Platform (OCP)

    • 4.X
  • Horizontal Pod Autoscaler (HPA)

Issue

  • How is it possible to configure/control horizontal pod autoscaler (HPA) with Red Hat build of Keycloak ?

Resolution

  • Horizontal pod autoscaler (HPA) is now available since RHBK-26.2.

  • Horizontal pod autoscaler (HPA) can now be configured on RHBK Keycloak custom resource to dynamically add or remove pods as demand fluctuates.

Below is an example of HorizontalPodAutoscaler to scale if the average CPU or memory exceeds 80% across pods:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: keycloak-hpa
  namespace: keycloak-cluster
spec:
  scaleTargetRef:
    apiVersion: k8s.keycloak.org/v2alpha1
    kind: Keycloak
    name: keycloak
  minReplicas: 2
  maxReplicas: 10
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 80

Diagnostic Steps

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments