15.4 Deploying HPA

The steps below show how to configure and run an HPA to scale Oracle Identity Governance (OIG), based on the CPU or memory utilization resource metrics.

The default OIG deployment creates the cluster governancedomain-oim-cluster which starts one OIG managed server (oim_server1). The deployment also creates, but doesn’t start, four extra OIG Managed Servers (oig-server2 to oig-server5).

In the following example an HPA resource is created, cluster resource governancedomain-oim-cluster. This resource will autoscale OIG 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: governancedomain-oim-cluster-hpa
      namespace: oigns
    spec:
      scaleTargetRef:
        apiVersion: weblogic.oracle/v1
        kind: Cluster
        name: governancedomain-oim-cluster
      behavior:
        scaleDown:
          stabilizationWindowSeconds: 60
        scaleUp:
          stabilizationWindowSeconds: 60
      minReplicas: 1
      maxReplicas: 5
      metrics:
      - type: Resource
        resource:
          name: cpu
          target:
            type: Utilization
            averageUtilization: 70
    
    where:
    • governancedomain is the <domainUID>
    • oigns 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/governancedomain-oim-cluster-hpa created
  3. Verify the status of the autoscaler by running the following:
    kubectl get hpa -n oigns
    
    The output will look similar to the following:
    NAME                               REFERENCE                              TARGETS   MINPODS   MAXPODS   REPLICAS   AGE
    governancedomain-oim-cluster-hpa   Cluster/governancedomain-oim-cluster   16%/70%   1         5         1          20s
    In the example above, this shows that CPU is currently running at 16% for the governancedomain-oim-cluster-hpa.