16.4 Deploying HPA

The steps below show how to configure and run Horizontal Pod Autoscaler (HPA) to scale Oracle Access Management (OAM), based on the CPU or memory utilization resource metrics.

The default OAM deployment creates the cluster accessdomain-oam-cluster which starts one OAM managed server (oam_server1). The deployment also creates, but doesn’t start, four extra OAM Managed Servers (oam-server2 to oam-server5).

In the following example an HPA resource is created, cluster resource accessdomain-oam-cluster. This resource will autoscale OAM managed server from a minimum of 1 cluster member up to 5 cluster members. Scaling up will occur when the average CPU is consistently over 70%. Scaling down will occur when the average CPU is consistently below 70%.

  1. Navigate to the $WORKDIR/kubernetes/hpa and create an autoscalehpa.yaml file that contains the following:
    #
    #
    apiVersion: autoscaling/v2
    kind: HorizontalPodAutoscaler
    metadata:
      name: accessdomain-oam-cluster-hpa
      namespace: oamns
    spec:
      scaleTargetRef:
        apiVersion: weblogic.oracle/v1
        kind: Cluster
        name: accessdomain-oam-cluster
      behavior:
        scaleDown:
          stabilizationWindowSeconds: 60
        scaleUp:
          stabilizationWindowSeconds: 60
      minReplicas: 1
      maxReplicas: 5
      metrics:
      - type: Resource
        resource:
          name: cpu
          target:
            type: Utilization
            averageUtilization: 70
    
    where:
    • accessdomain is the <domainUID>
    • oamns is the <domain_namespace>.
    • minReplicas and maxReplicas should match your current domain setting.

    Note:

    For setting HPA based on Memory Metrics, update the metrics block with the following content. Please note, Oracle recommends using only CPU or Memory, not both:
    metrics:
    - type: Resource
      resource:
        name: memory
        target:
          type: Utilization
          averageUtilization: 70
  2. Run the following command to create the autoscaler:
    kubectl apply -f autoscalehpa.yaml
    The output will look similar to the following:
    horizontalpodautoscaler.autoscaling/accessdomain-oam-cluster-hpa created
    
  3. Verify the status of the autoscaler by running the following:
    kubectl get hpa -n oamns
    
    The output will look similar to the following:
    NAME                           REFERENCE                          TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
    accessdomain-oam-cluster-hpa   Cluster/accessdomain-oam-cluster   5%/70%    1         5         1          21s
    In the example above, this shows that CPU is currently running at 5% for the accessdomain-oam-cluster-hpa.