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%.
- Navigate to the
$WORKDIR/kubernetes/hpa
and create anautoscalehpa.yaml
file that contains the following:
where:# # 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
-
accessdomain
is the<domainUID>
oamns
is the<domain_namespace>
.-
minReplicas
andmaxReplicas
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
-
- Run the following command to create the
autoscaler:
The output will look similar to the following:kubectl apply -f autoscalehpa.yaml
horizontalpodautoscaler.autoscaling/accessdomain-oam-cluster-hpa created
- Verify the status of the autoscaler by running the
following:
The output will look similar to the following:kubectl get hpa -n oamns
In the example above, this shows that CPU is currently running at 5% for theNAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE accessdomain-oam-cluster-hpa Cluster/accessdomain-oam-cluster 5%/70% 1 5 1 21s
accessdomain-oam-cluster-hpa
.