Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for configuring HPA with custom/external metrics #467

Merged
merged 12 commits into from Jun 27, 2023

Conversation

locmai
Copy link
Contributor

@locmai locmai commented Jun 19, 2023

What this PR does:

Add an option to auto-scale on custom and external metrics.

Which issue(s) this PR fixes:
No issue opened yet

Test values.yaml:

nginx:
  autoscaling:
    enabled: true
    customMetrics:
    - type: External
      external:
        metric:
          name: queue_messages_ready
          selector:
            matchLabels:
              queue: "worker_tasks"
        target:
          type: AverageValue
          averageValue: 30
    - type: External
      external:
        metric:
          name: queue_workers_ready
        target:
          type: AverageValue
          averageValue: 10

Result:

---
# Source: cortex/templates/nginx/nginx-hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: release-name-cortex-nginx
  namespace: default
  labels:
    helm.sh/chart: cortex-2.1.0
    app.kubernetes.io/name: cortex
    app.kubernetes.io/instance: release-name
    app.kubernetes.io/version: "v1.15.1"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: nginx
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: release-name-cortex-nginx
  minReplicas: 2
  maxReplicas: 30
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 80
    - external:
        metric:
          name: queue_messages_ready
          selector:
            matchLabels:
              queue: worker_tasks
        target:
          averageValue: 30
          type: AverageValue
      type: External
    - external:
        metric:
          name: queue_workers_ready
        target:
          averageValue: 10
          type: AverageValue
      type: External
---

Checklist

  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Signed-off-by: Loc Mai <locmai0201@gmail.com>
Signed-off-by: Loc Mai <locmai0201@gmail.com>
Signed-off-by: Loc Mai <locmai0201@gmail.com>
Signed-off-by: Loc Mai <locmai0201@gmail.com>
@locmai locmai changed the title feat: option for custom/external metrics HPA Add option for custom/external metrics HPA Jun 19, 2023
@locmai locmai changed the title Add option for custom/external metrics HPA Add option for configuring HPA with custom/external metrics Jun 19, 2023
@locmai
Copy link
Contributor Author

locmai commented Jun 20, 2023

Hi @nschad and @kd7lxl , could you take a look at this PR?

@nschad nschad requested a review from kd7lxl June 22, 2023 06:45
values.yaml Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
values.yaml Outdated Show resolved Hide resolved
values.yaml Outdated Show resolved Hide resolved
Signed-off-by: Loc Mai <locmai0201@gmail.com>
Signed-off-by: Loc Mai <locmai0201@gmail.com>
Signed-off-by: Loc Mai <locmai0201@gmail.com>
Signed-off-by: Loc Mai <locmai0201@gmail.com>
@locmai locmai requested review from kd7lxl and nschad June 26, 2023 12:54
@nschad nschad merged commit d335fe6 into cortexproject:master Jun 27, 2023
2 checks passed
@nschad
Copy link
Collaborator

nschad commented Jun 27, 2023

thanks!

@locmai locmai mentioned this pull request Jan 16, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants