In order to use custom scaling policies and rules, make sure you disable default NAIS HPA by setting the
.spec.replicas.disableAutoScaling field to
Scaling based on custom metrics¶
A custom metric is based on a direct value or a rate over time. To make the custom metric available for scaling, you have to label it with either hpa="value" or hpa="rate"
Example metric output:
Once the metric is labelled correctly, it can be used in a HorizontalPodAutoscaler Kubernetes object. Refer to the Kubernetes documentation for details.
In the example below, the amount of replicas will be increased once the average of
active_sessions exceeds 150 across all currently running pods.
apiVersion: autoscaling/v2beta2 kind: HorizontalPodAutoscaler metadata: name: hpa-example namespace: team-namespace spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: deployment-name minReplicas: 2 maxReplicas: 10 metrics: - type: Pods pods: metric: name: active_sessions target: type: AverageValue averageValue: 150
The platform provides metrics from the LinkerD sidecar by default:
This metric contains the rate of inbound requests.
Scaling based on external metrics¶
External metrics are provided by the platform for services external to the application, i.e. Kafka lag. If you want your application to scale based on external metrics, replace the metrics section of the previous example with the one below.
Use this command to see a list of available external metrics:
kubectl --raw "/apis/external.metrics.k8s.io/v1beta1" | jq .
You can also override the default behaviour of the autoscaler by configuring the HPA See Kubernetes documentation for details