Last active
September 7, 2022 07:14
-
-
Save wirwolf/87a7482ac87cf7fd08eeb28051c87a27 to your computer and use it in GitHub Desktop.
hpa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{/* vim: set filetype=mustache: */}} | |
{{/* | |
Create chart name and version as used by the chart label. | |
*/}} | |
{{- define "workers.hpa_metric_name" -}} | |
{{- printf "%s-%s" .Release.Namespace .Release.Name | replace "+" "_" | replace "-" "_" | trunc 63 -}} | |
{{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ if (eq $.Values.autoscaling.enabled true) }} | |
apiVersion: monitoring.coreos.com/v1 | |
kind: PrometheusRule | |
metadata: | |
name: {{ $.Release.Name }} | |
namespace: {{ $.Release.Namespace }} | |
spec: | |
groups: | |
- name: {{ $.Release.Name }}-queue-size # Define the name of your rule | |
rules: | |
- record: {{ include "workers.hpa_metric_name" . }}_messages_waiting_in_queue_name # The name of the metrics you want | |
expr: rabbitmq_queue_messages{queue="{{ $.Values.autoscaling.rabbitmq.queue }}", vhost="{{ $.Values.autoscaling.rabbitmq.vhost }}", namespace="{{ $.Values.autoscaling.rabbitmq.namespace }}" } # Query to make to prometheus | |
labels: | |
namespace: {{ $.Release.Namespace }} | |
--- | |
apiVersion: autoscaling/v2beta2 | |
kind: HorizontalPodAutoscaler | |
metadata: | |
name: {{ $.Release.Name }} | |
spec: | |
scaleTargetRef: | |
apiVersion: apps/v1 | |
kind: Deployment | |
name: {{ $.Release.Name }} | |
minReplicas: {{ $.Values.autoscaling.minReplicas }} | |
maxReplicas: {{ $.Values.autoscaling.maxReplicas }} | |
metrics: | |
- type: Object | |
object: | |
metric: | |
name: {{ include "workers.hpa_metric_name" . }}_messages_waiting_in_queue_name | |
describedObject: | |
apiVersion: v1 | |
kind: Namespace | |
name: {{ $.Release.Namespace }} | |
target: | |
type: Value | |
value: {{ $.Values.autoscaling.rabbitmq.value }} | |
{{- end }} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoscaling: | |
enabled: true | |
rabbitmq: | |
vhost: "/" | |
queue: "test" | |
namespace: "test" | |
value: 1 | |
minReplicas: 1 | |
maxReplicas: 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment