|
| 1 | +# With this Horizontal Pod Autoscaler, we want to ensure that there is |
| 2 | +# always at least: |
| 3 | +# - a specific count of jigasi pods available (TARGET_MIN_VALUE) |
| 4 | +# - a specific percentage of jigasi pods available across all jigasi pods (TARGET_PERCENT) |
| 5 | +# |
| 6 | +# The formula applied by HPA to compute the desired replicas is : |
| 7 | +# desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )] |
| 8 | +# (see https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#algorithm-details) |
| 9 | +# |
| 10 | +# If multiple metrics are specified in HPA, the formula is applied for each of |
| 11 | +# them and the higher desiredReplicas is taken into account. |
| 12 | +# |
| 13 | +# To guarantee that we always have at least TARGET_MIN_VALUE pods available, we |
| 14 | +# just have to set this value as minReplicas because the Deployment manages |
| 15 | +# only available jigasis. When a jigasi pod is busy, it gets orphaned and is |
| 16 | +# ignored by the Deployment. |
| 17 | +# |
| 18 | +# To ensure that we have a certain percentage of available pods |
| 19 | +# (TARGET_PERCENT), a rule is defined in this HPA based on the "jigasi_busy" |
| 20 | +# metric, which takes into account all jigasi pods in the namespace (those |
| 21 | +# managed by the deployment + the orphaned pods that are busy) |
| 22 | + |
| 23 | +apiVersion: autoscaling/v2beta2 |
| 24 | +kind: HorizontalPodAutoscaler |
| 25 | +metadata: |
| 26 | + name: jigasi-hpa |
| 27 | +spec: |
| 28 | + scaleTargetRef: |
| 29 | + apiVersion: apps/v1 |
| 30 | + kind: Deployment |
| 31 | + name: jigasi |
| 32 | + minReplicas: 2 |
| 33 | + maxReplicas: 10 |
| 34 | + behavior: |
| 35 | + # We'll allow to scale down 20% of the pods every 30s |
| 36 | + scaleDown: |
| 37 | + stabilizationWindowSeconds: 60 |
| 38 | + policies: |
| 39 | + - type: Percent |
| 40 | + value: 20 |
| 41 | + periodSeconds: 30 |
| 42 | + # We allow to add 2 pods every 2 minutes. |
| 43 | + # FIXME: Adjust this value when cluster autoscaler is enabled. |
| 44 | + # It should give enough time to provision new nodes, but not too much |
| 45 | + # to be able to scale-up in case of high demand. |
| 46 | + scaleUp: |
| 47 | + policies: |
| 48 | + - type: Pods |
| 49 | + value: 2 |
| 50 | + periodSeconds: 120 |
| 51 | + metrics: |
| 52 | + - type: Object |
| 53 | + object: |
| 54 | + metric: |
| 55 | + name: jigasi_busy |
| 56 | + describedObject: |
| 57 | + apiVersion: v1 |
| 58 | + kind: Namespace |
| 59 | + name: jitsi |
| 60 | + target: |
| 61 | + type: Value |
| 62 | + # We want to always have at least 20% of available jigasi instances. |
| 63 | + value: 0.8 |
0 commit comments