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 HPA Support for all Pyroscope components #3157

Merged
merged 7 commits into from
Apr 4, 2024

Conversation

weastel
Copy link
Contributor

@weastel weastel commented Apr 2, 2024

As Mentioned in #2445 Added Support for HPA for all pyroscope components similar to loki based schema.
Schema for adding HPA to any component is as follows:

  autoscaling:
    # -- Enable autoscaling for the querier, this is only used if `indexGateway.enabled: true`
    enabled: false
    # -- Minimum autoscaling replicas for the querier
    minReplicas: 1
    # -- Maximum autoscaling replicas for the querier
    maxReplicas: 3
    # -- Target CPU utilisation percentage for the querier
    targetCPUUtilizationPercentage: 60
    # -- Target memory utilisation percentage for the querier
    targetMemoryUtilizationPercentage: null
    # -- Allows one to define custom metrics using the HPA/v2 schema (for example, Pods, Object or External metrics)
    customMetrics: []
    # - type: External
    #   external:
    #     metric:
    #       name: loki_inflight_queries
    #     target:
    #       type: AverageValue
    #       averageValue: 12
    behavior:
      # -- Enable autoscaling behaviours
      enabled: false
      # -- define scale down policies, must conform to HPAScalingRules
      scaleDown: {}
      # -- define scale up policies, must conform to HPAScalingRules
      scaleUp: {}

For eg:

distributor:
  kind: Deployment
  replicaCount: 2
  autoscaling:
    enabled: true
    targetCPUUtilizationPercentage: 40
    minReplicas: 1
    maxReplicas: 5
  resources:
    limits:
      memory: 1Gi
    requests:
      memory: 256Mi
      cpu: 500m

results into:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: temp-up-pyroscope-distributor
  namespace: default
  labels:
    helm.sh/chart: pyroscope-1.5.1
    app.kubernetes.io/name: pyroscope
    app.kubernetes.io/instance: temp-up
    app.kubernetes.io/version: "1.5.0"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: "distributor"
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: temp-up-pyroscope-distributor
  minReplicas: 1
  maxReplicas: 5
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 40

Signed-off-by: Drumil Patel <drumilpatel720@gmail.com>
@simonswine
Copy link
Contributor

You need to run make helm/check and update the static manifests. Also #3159 is useful

weastel and others added 2 commits April 3, 2024 21:09
Signed-off-by: Drumil Patel <drumilpatel720@gmail.com>
@weastel
Copy link
Contributor Author

weastel commented Apr 3, 2024

Updated PR, now it will mostly pass on all checks, A Quick question should I add values-micro-services-hpa.json and respective kubeconform. @simonswine

Signed-off-by: Drumil Patel <drumilpatel720@gmail.com>
@simonswine
Copy link
Contributor

Updated PR, now it will mostly pass on all checks, A Quick question should I add values-micro-services-hpa.json and respective kubeconform. @simonswine

@weastel I think that would be a nice way to test it yes please!

weastel and others added 3 commits April 4, 2024 16:14
Signed-off-by: Drumil Patel <drumilpatel720@gmail.com>
Signed-off-by: Drumil Patel <drumilpatel720@gmail.com>
@weastel
Copy link
Contributor Author

weastel commented Apr 4, 2024

@simonswine As discussed added tests for new HPA based configuration, Can you please review this addition?

Copy link
Contributor

@simonswine simonswine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@simonswine
Copy link
Contributor

@weastel thank you for your work on this ❤️

@simonswine simonswine merged commit 4fdd876 into grafana:main Apr 4, 2024
16 checks passed
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

2 participants