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 apiVersion: v2
type: application type: application
name: vikunja name: vikunja
@ -40,4 +37,3 @@ maintainers:
sources: sources:
- https://kolaente.dev/vikunja/helm-chart - https://kolaente.dev/vikunja/helm-chart
- https://vikunja.io - https://vikunja.io

View File

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

View File

@ -8,6 +8,9 @@ spec:
{{- if not .Values.api.autoscaling.enabled }} {{- if not .Values.api.autoscaling.enabled }}
replicas: {{ .Values.api.replicaCount }} replicas: {{ .Values.api.replicaCount }}
{{- end }} {{- end }}
{{- with .Values.api.extraDeploymentSpec }}
{{- toYaml . | nindent 2 }}
{{- end }}
selector: selector:
matchLabels: matchLabels:
{{- include "vikunja.apiSelectorLabels" . | nindent 6 }} {{- include "vikunja.apiSelectorLabels" . | nindent 6 }}
@ -29,19 +32,26 @@ spec:
securityContext: securityContext:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
{{- with .Values.api.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers: containers:
- name: {{ .Chart.Name }} {{- with .Values.api.sidecarContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
- name: api
{{- with .Values.api.securityContext }} {{- with .Values.api.securityContext }}
securityContext: securityContext:
{{- toYaml . | nindent 10 }} {{- toYaml . | nindent 10 }}
{{- end }} {{- end }}
{{- $image := required ".image.repository is not set" .Values.api.image.repository }} {{- $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 }} image: {{ printf "%s:%s" $image $tag | quote }}
imagePullPolicy: {{ .Values.api.image.pullPolicy }} imagePullPolicy: {{ .Values.api.image.pullPolicy }}
ports: ports:
- name: http - name: http
containerPort: 5000 containerPort: {{ (.Values.api.config.service.interface | split ":")._1 | int }}
protocol: TCP protocol: TCP
{{- with .Values.api.env }} {{- with .Values.api.env }}
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 name: http
selector: selector:
{{- include "vikunja.apiSelectorLabels" . | nindent 4 }} {{- 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 }} {{- if not .Values.frontend.autoscaling.enabled }}
replicas: {{ .Values.frontend.replicaCount }} replicas: {{ .Values.frontend.replicaCount }}
{{- end }} {{- end }}
{{- with .Values.frontend.extraDeploymentSpec }}
{{- toYaml . | nindent 2 }}
{{- end }}
selector: selector:
matchLabels: matchLabels:
{{- include "vikunja.frontendSelectorLabels" . | nindent 6 }} {{- include "vikunja.frontendSelectorLabels" . | nindent 6 }}
@ -29,29 +32,21 @@ spec:
securityContext: securityContext:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
{{- with .Values.frontend.initContainers }}
initContainers: initContainers:
- name: permissions {{- toYaml . | nindent 8 }}
image: alpine:3.16.3 {{- end }}
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
containers: containers:
- name: {{ .Chart.Name }} {{- with .Values.frontend.sidecarContainers }}
{{- toYaml . | nindent 8 }}
{{- end }}
- name: frontend
{{- with .Values.frontend.securityContext }} {{- with .Values.frontend.securityContext }}
securityContext: securityContext:
{{- toYaml . | nindent 10 }} {{- toYaml . | nindent 10 }}
{{- end }} {{- end }}
{{- $image := required ".image.repository is not set" .Values.frontend.image.repository }} {{- $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 }} image: {{ printf "%s:%s" $image $tag | quote }}
imagePullPolicy: {{ .Values.frontend.image.pullPolicy }} imagePullPolicy: {{ .Values.frontend.image.pullPolicy }}
ports: ports:
@ -89,16 +84,12 @@ spec:
volumeMounts: volumeMounts:
- name: tmp - name: tmp
mountPath: /tmp mountPath: /tmp
- name: nginx-cache
mountPath: /var/cache/nginx
{{- with .Values.frontend.extraVolumeMounts }} {{- with .Values.frontend.extraVolumeMounts }}
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
volumes: volumes:
- name: tmp - name: tmp
emptyDir: {} emptyDir: {}
- name: nginx-cache
emptyDir: {}
{{- with .Values.frontend.extraVolumes }} {{- with .Values.frontend.extraVolumes }}
{{- toYaml . | nindent 6 }} {{- toYaml . | nindent 6 }}
{{- end }} {{- 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 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: {{ include "vikunja.fullname" . }} name: {{ include "vikunja.frontendFullname" . }}
labels: labels:
{{- include "vikunja.labels" . | nindent 4 }} {{- include "vikunja.labels" . | nindent 4 }}
spec: spec:
@ -13,3 +13,6 @@ spec:
name: http name: http
selector: selector:
{{- include "vikunja.frontendSelectorLabels" . | nindent 4 }} {{- 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" . }} name: {{ include "vikunja.serviceAccountName" . }}
labels: labels:
{{- include "vikunja.labels" . | nindent 4 }} {{- include "vikunja.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.serviceAccount.annotations }} {{- with .Values.serviceAccount.annotations }}
annotations: annotations:
{{- toYaml . | nindent 4 }} {{- toYaml . | nindent 4 }}

View File

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