|
| 1 | +:_content-type: PROCEDURE |
| 2 | +:description: Configuring a number of replicas |
| 3 | +:keywords: administration-guide, configuring-number-of-replicas |
| 4 | +:navtitle: Configuring a number of replicas {prod-cli} |
| 5 | +:page-aliases: |
| 6 | + |
| 7 | +[id="configuring-number-of-replicas"] |
| 8 | += Configuring the number of replicas |
| 9 | + |
| 10 | +To configure the number of replicas for {prod-short} operands using {kubernetes} `HorizontalPodAutoscaler` |
| 11 | +(HPA), you can define an `HPA` resource for deployment. The `HPA` dynamically adjusts the number |
| 12 | +of replicas based on specified metrics. |
| 13 | + |
| 14 | +.Procedure |
| 15 | + |
| 16 | +. Create an `HPA` resource for a deployment, specifying the target metrics and desired replica count. |
| 17 | ++ |
| 18 | +[source,yaml,subs="+attributes,+quotes"] |
| 19 | +---- |
| 20 | +apiVersion: autoscaling/v2 |
| 21 | +kind: HorizontalPodAutoscaler |
| 22 | +metadata: |
| 23 | + name: scaler |
| 24 | + namespace: {prod-namespace} |
| 25 | +spec: |
| 26 | + scaleTargetRef: |
| 27 | + apiVersion: apps/v1 |
| 28 | + kind: Deployment |
| 29 | + name: __<deployment_name>__ <1> |
| 30 | + ... |
| 31 | +---- |
| 32 | +<1> The `__<deployment_name>__` corresponds to the one following deployments: |
| 33 | +* `{prod-deployment}` |
| 34 | +* `che-gateway` |
| 35 | +* `{prod-deployment}-dashboard` |
| 36 | +* `plugin-registry` |
| 37 | +* `devfile-registry` |
| 38 | + |
| 39 | +.Create a `HorizontalPodAutoscaler` for {prod-deployment} deployment: |
| 40 | +==== |
| 41 | +[source,yaml,subs="+attributes,+quotes"] |
| 42 | +---- |
| 43 | +apiVersion: autoscaling/v2 |
| 44 | +kind: HorizontalPodAutoscaler |
| 45 | +metadata: |
| 46 | + name: {prod-deployment}-scaler |
| 47 | + namespace: {prod-namespace} |
| 48 | +spec: |
| 49 | + scaleTargetRef: |
| 50 | + apiVersion: apps/v1 |
| 51 | + kind: Deployment |
| 52 | + name: {prod-deployment} |
| 53 | + minReplicas: 2 |
| 54 | + maxReplicas: 5 |
| 55 | + metrics: |
| 56 | + - type: Resource |
| 57 | + resource: |
| 58 | + name: cpu |
| 59 | + target: |
| 60 | + type: Utilization |
| 61 | + averageUtilization: 75 |
| 62 | +---- |
| 63 | +In this example, the HPA is targeting the Deployment named {prod-deployment}, with a minimum of 2 replicas, a maximum of 5 replicas |
| 64 | +and scaling based on CPU utilization. |
| 65 | +==== |
| 66 | + |
| 67 | +.Additional resources |
| 68 | +* link:https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale[Horizontal Pod Autoscaling] |
0 commit comments