kubernetesdevspace

devspace: how to auto-scale deployments?


My deployment never auto-scale on DigitalOcean. I have on my devspace.yaml

deployments:
- name: app
  namespace: "mynamespace"
  helm:
    componentChart: true
    values:
      replicas: 1
      autoScaling:
        horizontal:
          maxReplicas: 3
          averageCPU: 5m
          # averageRelativeCPU: 1
      containers:
      - name: app
        image: pablorsk/app

Always has 1 replica. I try with small values on averageCPU like 5m o averageRelativeCPU like 1, but never upgrade replicas on cluster.

$ kubectl get hpa
NAME     REFERENCE           TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
app      Deployment/app      <unknown>/5m   1         3         1          13d

This is my node configuration on DigitalOcean:

enter image description here


Solution

  • HPA installation is required for auto-scale deployments.

    kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
    

    Then, you can see values for TARGETS

    $ kubectl get hpa
    NAME     REFERENCE           TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
    app      Deployment/app      216/5m          1         3         1          1d
    

    More information on metrics-server repository.