Skip to content

Commit

Permalink
feat(kroki): add horizontal pod autoscaling (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-prudhomme authored Jun 22, 2024
1 parent 289a95e commit 0ea61d3
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 30 deletions.
4 changes: 2 additions & 2 deletions charts/kroki/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ name: kroki
sources:
- https://github.com/yuzutech/kroki
- https://github.com/cowboysysop/charts/tree/master/charts/kroki
version: 5.2.0
version: 5.3.0
dependencies:
- name: common
version: 2.19.0
version: 2.20.3
repository: https://charts.bitnami.com/bitnami/
annotations:
artifacthub.io/signKey: |
Expand Down
8 changes: 8 additions & 0 deletions charts/kroki/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ The command deletes the release named `my-release` and frees all the kubernetes
| `serviceAccount.create` | Specifies whether a service account should be created | `true` |
| `serviceAccount.annotations` | Service account annotations | `{}` |
| `serviceAccount.name` | The name of the service account to use (Generated using the `kroki.fullname` template if not set) | `nil` |
| `deploymentAnnotations` | Additional deployment annotations | `{}` |
| `podAnnotations` | Additional pod annotations | `{}` |
| `podLabels` | Additional pod labels | `{}` |
| `podSecurityContext` | Pod security context | `{}` |
Expand Down Expand Up @@ -146,6 +147,8 @@ The command deletes the release named `my-release` and frees all the kubernetes
| `service.annotations` | Service annotations | `{}` |
| `service.type` | Service type | `ClusterIP` |
| `service.clusterIP` | Static cluster IP address or None for headless service when service type is ClusterIP | `nil` |
| `service.sessionAffinity` | Control where client requests go, to the same pod or round-robin | `None` |
| `service.sessionAffinityConfig` | Additional settings for the sessionAffinity | `{}` |
| `service.loadBalancerIP` | Static load balancer IP address when service type is LoadBalancer | `nil` |
| `service.loadBalancerSourceRanges` | Source IP address ranges when service type is LoadBalancer | `nil` |
| `service.externalTrafficPolicy` | External traffic routing policy when service type is LoadBalancer or NodePort | `Cluster` |
Expand All @@ -166,6 +169,11 @@ The command deletes the release named `my-release` and frees all the kubernetes
| `extraEnvVars` | Additional container environment variables | `[]` |
| `extraEnvVarsCM` | Name of existing ConfigMap containing additional container environment variables | `nil` |
| `extraEnvVarsSecret` | Name of existing Secret containing additional container environment variables | `nil` |
| `autoscaling.hpa.enabled` | Enable HPA | `false` |
| `autoscaling.hpa.minReplicas` | Minimum number of replicas | `""` |
| `autoscaling.hpa.maxReplicas` | Maximum number of replicas | `""` |
| `autoscaling.hpa.targetCPU` | Target CPU utilization percentage | `""` |
| `autoscaling.hpa.targetMemory` | Target Memory utilization percentage | `""` |

### BPMN parameters

Expand Down
8 changes: 5 additions & 3 deletions charts/kroki/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ metadata:
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- if or .Values.deploymentAnnotations .Values.commonAnnotations }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.deploymentAnnotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.autoscaling.hpa.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "kroki.selectorLabels" . | nindent 6 }}
Expand Down
46 changes: 46 additions & 0 deletions charts/kroki/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{- if .Values.autoscaling.hpa.enabled }}
apiVersion: {{ include "common.capabilities.hpa.apiVersion" ( dict "context" $ ) }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "kroki.fullname" . }}
labels:
{{- include "kroki.labels" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
scaleTargetRef:
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
name: {{ include "kroki.fullname" . }}
minReplicas: {{ .Values.autoscaling.hpa.minReplicas }}
maxReplicas: {{ .Values.autoscaling.hpa.maxReplicas }}
metrics:
{{- if .Values.autoscaling.hpa.targetMemory }}
- type: Resource
resource:
name: memory
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
targetAverageUtilization: {{ .Values.autoscaling.hpa.targetMemory }}
{{- else }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.hpa.targetMemory }}
{{- end }}
{{- end }}
{{- if .Values.autoscaling.hpa.targetCPU }}
- type: Resource
resource:
name: cpu
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
targetAverageUtilization: {{ .Values.autoscaling.hpa.targetCPU }}
{{- else }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.hpa.targetCPU }}
{{- end }}
{{- end }}
{{- end }}
11 changes: 3 additions & 8 deletions charts/kroki/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.ingress.enabled -}}
{{- if .Values.ingress.enabled }}
apiVersion: {{ include "common.capabilities.ingress.apiVersion" . }}
kind: Ingress
metadata:
Expand All @@ -9,13 +9,8 @@ metadata:
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if or .Values.ingress.annotations .Values.commonAnnotations }}
annotations:
{{- if .Values.ingress.annotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.ingress.annotations "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.ingress.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.ingressClassName (eq "true" (include "common.ingress.supportsIngressClassname" .)) }}
Expand Down
3 changes: 1 addition & 2 deletions charts/kroki/templates/pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ metadata:
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
annotations:
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- if .Values.pdb.minAvailable }}
Expand Down
17 changes: 9 additions & 8 deletions charts/kroki/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ metadata:
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if or .Values.service.annotations .Values.commonAnnotations }}
annotations:
{{- if .Values.service.annotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.service.annotations "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.service.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if and (eq .Values.service.type "ClusterIP") .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }}
{{- end }}
{{- if .Values.service.sessionAffinity }}
sessionAffinity: {{ .Values.service.sessionAffinity }}
{{- end }}
{{- if .Values.service.sessionAffinityConfig }}
sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.service.sessionAffinityConfig "context" $) | nindent 4 }}
{{- end }}
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
Expand All @@ -29,7 +30,7 @@ spec:
{{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
{{- if or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
{{- end }}
ports:
- port: {{ .Values.service.ports.http }}
Expand Down
9 changes: 2 additions & 7 deletions charts/kroki/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ metadata:
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- if or .Values.serviceAccount.annotations .Values.commonAnnotations }}
annotations:
{{- if .Values.serviceAccount.annotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.serviceAccount.annotations "context" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.serviceAccount.annotations .Values.commonAnnotations ) "context" . ) }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $ ) | nindent 4 }}
{{- end }}
{{- end -}}
26 changes: 26 additions & 0 deletions charts/kroki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ serviceAccount:
## @param serviceAccount.name The name of the service account to use (Generated using the `kroki.fullname` template if not set)
name:

## @param deploymentAnnotations Additional deployment annotations
deploymentAnnotations: {}

## @param podAnnotations Additional pod annotations
podAnnotations: {}

Expand Down Expand Up @@ -174,6 +177,12 @@ service:
clusterIP:
# clusterIP: 10.43.0.100

## @param service.sessionAffinity Control where client requests go, to the same pod or round-robin
sessionAffinity: None

## @param service.sessionAffinityConfig Additional settings for the sessionAffinity
sessionAffinityConfig: {}

## @param service.loadBalancerIP Static load balancer IP address when service type is LoadBalancer
loadBalancerIP:
# loadBalancerIP: 10.0.0.100
Expand Down Expand Up @@ -255,6 +264,23 @@ extraEnvVarsCM:
## @param extraEnvVarsSecret Name of existing Secret containing additional container environment variables
extraEnvVarsSecret:

autoscaling:
hpa:
## @param autoscaling.hpa.enabled Enable HPA
enabled: false

## @param autoscaling.hpa.minReplicas Minimum number of replicas
minReplicas: ""

## @param autoscaling.hpa.maxReplicas Maximum number of replicas
maxReplicas: ""

## @param autoscaling.hpa.targetCPU Target CPU utilization percentage
targetCPU: ""

## @param autoscaling.hpa.targetMemory Target Memory utilization percentage
targetMemory: ""

## @section BPMN parameters

bpmn:
Expand Down

0 comments on commit 0ea61d3

Please sign in to comment.