Added HPA and many extra fields

This commit is contained in:
Yurii Vlasov 2023-01-31 10:11:00 +02:00
parent 106dfc96c7
commit 10662cb50d
10 changed files with 148 additions and 41 deletions

View File

@ -1,6 +1,3 @@
apiVersion: v2
type: application
name: vikunja
@ -40,4 +37,3 @@ maintainers:
sources:
- https://kolaente.dev/vikunja/helm-chart
- https://vikunja.io

View File

@ -48,6 +48,9 @@ Selector labels
{{- define "vikunja.selectorLabels" -}}
app.kubernetes.io/name: {{ include "vikunja.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 0 }}
{{- end }}
{{- end }}
{{/*

View File

@ -8,6 +8,9 @@ spec:
{{- if not .Values.api.autoscaling.enabled }}
replicas: {{ .Values.api.replicaCount }}
{{- end }}
{{- with .Values.api.extraDeploymentSpec }}
{{- toYaml . | nindent 2 }}
{{- end }}
selector:
matchLabels:
{{- include "vikunja.apiSelectorLabels" . | nindent 6 }}
@ -29,19 +32,26 @@ spec:
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.api.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
{{- with .Values.api.sidecarContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
- name: api
{{- with .Values.api.securityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- $image := required ".image.repository is not set" .Values.api.image.repository }}
{{- $tag := required ".image.tag is not set" .Values.api.image.tag }}
{{- $tag := default .Chart.AppVersion .Values.api.image.tag | toString }}
image: {{ printf "%s:%s" $image $tag | quote }}
imagePullPolicy: {{ .Values.api.image.pullPolicy }}
ports:
- name: http
containerPort: 5000
containerPort: {{ (.Values.api.config.service.interface | split ":")._1 | int }}
protocol: TCP
{{- with .Values.api.env }}
env:

32
templates/api/hpa.yaml Normal file
View File

@ -0,0 +1,32 @@
{{- if .Values.api.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "vikunja.apiFullname" . }}
labels:
{{- include "vikunja.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "vikunja.apiFullname" . }}
minReplicas: {{ int .Values.api.autoscaling.minReplicas }}
maxReplicas: {{ int .Values.api.autoscaling.maxReplicas }}
metrics:
{{- if .Values.api.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ int .Values.api.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.api.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ int .Values.api.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

View File

@ -13,3 +13,6 @@ spec:
name: http
selector:
{{- include "vikunja.apiSelectorLabels" . | nindent 4 }}
{{- with .Values.api.service.extraSpec }}
{{- toYaml . | nindent 2 }}
{{- end }}

View File

@ -8,6 +8,9 @@ spec:
{{- if not .Values.frontend.autoscaling.enabled }}
replicas: {{ .Values.frontend.replicaCount }}
{{- end }}
{{- with .Values.frontend.extraDeploymentSpec }}
{{- toYaml . | nindent 2 }}
{{- end }}
selector:
matchLabels:
{{- include "vikunja.frontendSelectorLabels" . | nindent 6 }}
@ -29,29 +32,21 @@ spec:
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.frontend.initContainers }}
initContainers:
- name: permissions
image: alpine:3.16.3
imagePullPolicy: IfNotPresent
command: ["/bin/sh", "-c"]
args:
- |-
cd /var/cache/nginx
for i in client_temp proxy_temp fastcgi_temp uwsgi_temp csgi_temp scgi_temp; do
mkdir -p "$i"
chown -Rv 1000:1000 "$i"
done
volumeMounts:
- name: nginx-cache
mountPath: /var/cache/nginx
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
{{- with .Values.frontend.sidecarContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
- name: frontend
{{- with .Values.frontend.securityContext }}
securityContext:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- $image := required ".image.repository is not set" .Values.frontend.image.repository }}
{{- $tag := required ".image.tag is not set" .Values.frontend.image.tag }}
{{- $tag := default .Chart.AppVersion .Values.frontend.image.tag | toString }}
image: {{ printf "%s:%s" $image $tag | quote }}
imagePullPolicy: {{ .Values.frontend.image.pullPolicy }}
ports:
@ -89,16 +84,12 @@ spec:
volumeMounts:
- name: tmp
mountPath: /tmp
- name: nginx-cache
mountPath: /var/cache/nginx
{{- with .Values.frontend.extraVolumeMounts }}
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: tmp
emptyDir: {}
- name: nginx-cache
emptyDir: {}
{{- with .Values.frontend.extraVolumes }}
{{- toYaml . | nindent 6 }}
{{- end }}

View File

@ -0,0 +1,32 @@
{{- if .Values.frontend.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "vikunja.frontendFullname" . }}
labels:
{{- include "vikunja.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "vikunja.frontendFullname" . }}
minReplicas: {{ int .Values.frontend.autoscaling.minReplicas }}
maxReplicas: {{ int .Values.frontend.autoscaling.maxReplicas }}
metrics:
{{- if .Values.frontend.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ int .Values.frontend.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.frontend.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ int .Values.frontend.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

View File

@ -1,7 +1,7 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "vikunja.fullname" . }}
name: {{ include "vikunja.frontendFullname" . }}
labels:
{{- include "vikunja.labels" . | nindent 4 }}
spec:
@ -13,3 +13,6 @@ spec:
name: http
selector:
{{- include "vikunja.frontendSelectorLabels" . | nindent 4 }}
{{- with .Values.frontend.service.extraSpec }}
{{- toYaml . | nindent 2 }}
{{- end }}

View File

@ -5,6 +5,9 @@ metadata:
name: {{ include "vikunja.serviceAccountName" . }}
labels:
{{- include "vikunja.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}

View File

@ -10,15 +10,21 @@ serviceAccount:
create: true
# Annotations to add to the service account
annotations: {}
# Extra labels
extraLabels: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
# Extra labels that will be added to all resources
extraLabels: {}
# ┬─┐┬─┐┌─┐┌┐┐┌┐┐┬─┐┌┐┐┬─┐
# ├─ │┬┘│ ││││ │ ├─ ││││ │
# ┘ ┘└┘┘─┘┘└┘ ┘ ┴─┘┘└┘┘─┘
frontend:
# Public API URL that client's browser will reach
apiUrl: ""
replicaCount: 1
@ -27,11 +33,7 @@ frontend:
repository: vikunja/frontend
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: 0.20.2
imagePullSecrets: []
podAnnotations: {}
tag: ""
podSecurityContext:
fsGroup: 1000
@ -47,6 +49,8 @@ frontend:
service:
type: ClusterIP
port: 80
# If you want to set other fields, like externalName, externalTrafficPolicy, etc.
extraSpec: {}
ingress:
enabled: false
@ -83,6 +87,18 @@ frontend:
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
initContainers: []
sidecarContainers: []
# Extra keys to set in deployment.spec.
# Useful if you want to set minReadySeconds, progressDeadlineSeconds, strategy
extraDeploymentSpec: {}
imagePullSecrets: []
podAnnotations: {}
nodeSelector: {}
tolerations: []
@ -115,6 +131,7 @@ frontend:
# ┘ ┘┘ ┘
api:
# Values for this config are described here https://vikunja.io/docs/config-options/
config:
service:
JWTSecret: ""
@ -163,14 +180,7 @@ api:
repository: vikunja/api
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: 0.20.1
imagePullSecrets: []
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 1000
tag: ""
securityContext:
capabilities:
@ -183,6 +193,8 @@ api:
service:
type: ClusterIP
port: 80
# If you want to set other fields, like externalName, externalTrafficPolicy, etc.
extraSpec: {}
ingress:
enabled: false
@ -219,6 +231,21 @@ api:
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
initContainers: []
sidecarContainers: []
# Extra keys to set in deployment.spec.
# Useful if you want to set minReadySeconds, progressDeadlineSeconds, strategy
extraDeploymentSpec: {}
imagePullSecrets: []
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 1000
nodeSelector: {}
tolerations: []
@ -261,3 +288,10 @@ postgresql: {}
redisEnabled: true
# Please refer to Redis subchart for a full list of possible values
redis: {}
# ┬─┐┬─┐┐ ┬
# │┬┘│─┤│││
# ┘└┘┘ ┘└┴┘
# You can create custom resources from the plaintext definition
raw: []