Skip to content

Commit

Permalink
feat: Add autoscaling and PDB templates to Helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
achetronic committed Sep 11, 2024
1 parent 3961574 commit b887b70
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/doorkeeper/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type: application
description: >-
A Helm chart for Doorkeeper, a tiny HTTP server to be used as
external authentication service for Envoy
version: &chartVersion 0.1.6
version: &chartVersion 0.2.0
appVersion: *chartVersion
kubeVersion: ">=1.22.0-0"
home: https://github.com/freepik-company/doorkeeper
Expand Down
62 changes: 62 additions & 0 deletions charts/doorkeeper/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{- if .Values.server.autoscaling }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "doorkeeper.fullname" . }}
labels:
{{- include "doorkeeper.labels" . | nindent 4 }}
{{- with .Values.server.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}

{{- with .Values.server.autoscaling.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}

spec:
{{- if .Values.server.autoscaling.behavior }}
behavior:
{{- toYaml .Values.server.autoscaling.behavior | nindent 4 }}
{{- end }}

# Match the generated Deployment by reference
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "doorkeeper.fullname" . }}

{{- with .Values.server.autoscaling }}
minReplicas: {{ .minReplicas }}
maxReplicas: {{ .maxReplicas }}

metrics:
# Changing the order of the metrics will cause ArgoCD
# to go into a sync loop memory needs to be first.
# More info in: https://github.com/argoproj/argo-cd/issues/1079
{{- with .targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}

{{- with .targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}

{{- if .customRules -}}
{{- toYaml .customRules | nindent 4}}
{{- end }}

{{- end }}

---
{{- end }}
35 changes: 35 additions & 0 deletions charts/doorkeeper/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

{{- if .Values.server.disruption }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ include "doorkeeper.fullname" . }}
labels:
{{- include "doorkeeper.labels" . | nindent 4 }}
{{- with .Values.server.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}

{{- with .Values.server.disruption.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}


spec:
{{- with .Values.server.disruption.minAvailable }}
minAvailable: {{ . }}
{{- end }}

{{- with .Values.server.disruption.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}

selector:
matchLabels:
{{- include "doorkeeper.selectorLabels" . | nindent 4 }}
{{- with .Values.server.extraLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
---
{{- end }}
22 changes: 22 additions & 0 deletions charts/doorkeeper/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,28 @@ server:

affinity: {}

# Pod Disruption Budget configurations
disruption:
annotations: {}
minAvailable: 2
#maxUnavailable: 1

# Horizontal Pod Autoscaling configurations
autoscaling:
annotations: {}
minReplicas: 1
maxReplicas: 5

targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

## see https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics
customRules: []

## see https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-configurable-scaling-behavior
behavior: {}


# Define some extra resources to be created
# This section is useful when you need ExternalResource or Secrets, etc.
extraResources: []
Expand Down

0 comments on commit b887b70

Please sign in to comment.