Add wekan chart

This commit is contained in:
2024-02-09 22:55:39 +08:00
parent b9e633bce1
commit d8d75be4be
19 changed files with 428 additions and 109 deletions
+13 -7
View File
@@ -62,21 +62,27 @@ Create the name of the service account to use for the api component
Create a default fully qualified mongodb-replicaset name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "wekan.mongodb-replicaset.fullname" -}}
{{- $name := default "mongodb-replicaset" (index .Values "mongodb-replicaset" "nameOverride") -}}
{{- define "wekan.mongodb.svcname" -}}
{{- $name := default "mongodb" (index .Values "mongodb" "nameOverride") -}}
{{- if eq .Values.mongodb.architecture "replicaset" }}
{{- printf "%s-%s-headless" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{/*
Create the MongoDB URL. If MongoDB is installed as part of this chart, use k8s service discovery,
else use user-provided URL.
*/}}
{{- define "mongodb-replicaset.url" -}}
{{- if (index .Values "mongodb-replicaset" "enabled") -}}
{{- $count := (int (index .Values "mongodb-replicaset" "replicas")) -}}
{{- define "mongodb.url" -}}
{{- if (index .Values "mongodb" "enabled") -}}
{{- $count := (int (index .Values "mongodb" "replicaCount")) -}}
{{- $release := .Release.Name -}}
mongodb://{{ $release }}-mongodb-replicaset:27017/admin?replicaSet={{ index .Values "mongodb-replicaset" "replicaSetName" }}
{{- $replicaSetName := (index .Values "mongodb" "replicaSetName") -}}
{{- $mongodbSvcName := include "wekan.mongodb.svcname" . -}}
mongodb://{{- range $v := until $count }}{{ $release }}-mongodb-{{ $v }}.{{ $mongodbSvcName }}:27017{{ if ne $v (sub $count 1) }},{{- end -}}{{- end -}}/{{ .Values.dbname }}?replicaSet={{ $replicaSetName }}
{{- else -}}
{{- index .Values "mongodb-replicaset" "url" -}}
{{- index .Values "mongodb" "url" -}}
{{- end -}}
{{- end -}}
+26
View File
@@ -0,0 +1,26 @@
{{- if .Values.sharedDataFolder.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ template "wekan.fullname" . }}-shared-data
labels:
app: {{ template "wekan.name" . }}
chart: {{ template "wekan.chart" . }}
component: wekan
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
spec:
accessModes:
{{- if .Values.sharedDataFolder.accessMode }}
- {{ .Values.sharedDataFolder.accessMode }}
{{- else }}
- ReadWriteMany
{{- end }}
{{- if .Values.sharedDataFolder.storageClass }}
storageClassName: {{ .Values.sharedDataFolder.storageClass | quote }}
{{- end }}
{{- with .Values.sharedDataFolder.resources }}
resources:
{{- toYaml . | nindent 4 }}
{{- end }}
{{ end }}
+55 -4
View File
@@ -8,6 +8,9 @@ metadata:
component: wekan
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.deploymentLabels }}
{{- toYaml .Values.deploymentLabels | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
@@ -22,8 +25,21 @@ spec:
app: {{ template "wekan.name" . }}
component: wekan
release: {{ .Release.Name }}
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "wekan.serviceAccountName" . }}
{{- if ne .Values.platform "openshift" }}
initContainers:
- name: volume-permissions
image: busybox
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ['sh', '-c', 'chown -R 999:999 /data']
volumeMounts:
- name: shared-data-volume
mountPath: /data
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
@@ -31,23 +47,52 @@ spec:
terminationMessagePolicy: FallbackToLogsOnError
ports:
- name: http
containerPort: 8080
containerPort: {{ .Values.service.port }}
env:
- name: ROOT_URL
value: {{ .Values.root_url | default "https://wekan.local" | quote }}
value: {{ .Values.root_url | quote }}
{{- $mongo_url_is_secret := false }}
{{- range $key := .Values.secretEnv }}
{{- if eq .name "MONGO_URL" }}
{{- $mongo_url_is_secret = true }}
{{- end }}
{{- end }}
{{- if not $mongo_url_is_secret }}
- name: MONGO_URL
value: "{{ template "mongodb-replicaset.url" . }}"
value: "{{ template "mongodb.url" . }}"
{{- end }}
{{- range $key := .Values.env }}
{{- if .value }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}
{{- end }}
{{- range $key := .Values.secretEnv }}
- name: {{ .name }}
valueFrom:
secretKeyRef:
name: {{ template "wekan.fullname" $ }}-secret
key: {{ .name }}
{{- end }}
envFrom:
{{- with .Values.extraEnvFrom }}
{{- tpl . $ | nindent 10 }}
{{- end }}
readinessProbe:
httpGet:
path: /
port: {{ .Values.service.port }}
initialDelaySeconds: 20
livenessProbe:
httpGet:
path: /
port: 8080
port: {{ .Values.service.port }}
initialDelaySeconds: 60
{{ if .Values.sharedDataFolder.enabled }}
volumeMounts:
- name: shared-data-volume
mountPath: /data
{{ end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
@@ -62,3 +107,9 @@ spec:
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{ if .Values.sharedDataFolder.enabled }}
volumes:
- name: shared-data-volume
persistentVolumeClaim:
claimName: {{ template "wekan.fullname" . }}-shared-data
{{ end }}
+4
View File
@@ -0,0 +1,4 @@
{{- range .Values.extraDeploy }}
---
{{ toYaml . }}
{{- end }}
+7 -3
View File
@@ -2,7 +2,8 @@
{{- $fullName := include "wekan.fullname" . -}}
{{- $servicePort := .Values.service.port -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
{{- $ingressPathType := .Values.ingress.pathtype -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
@@ -33,8 +34,11 @@ spec:
http:
paths:
- path: {{ $ingressPath }}
pathType: {{ $ingressPathType }}
backend:
serviceName: {{ $fullName }}
servicePort: 80
service:
name: {{ $fullName }}
port:
number: 8080
{{- end }}
{{- end }}
+13
View File
@@ -0,0 +1,13 @@
{{ if .Values.secretEnv }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "wekan.fullname" $ }}-secret
type: Opaque
data:
{{- range $key := .Values.secretEnv -}}
{{ if $key.value }}
{{ $key.name | indent 2 }}: {{ $key.value | b64enc }}
{{- end }}
{{- end }}
{{ end }}
-14
View File
@@ -1,14 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "wekan.fullname" . }}
labels:
app: {{ template "wekan.name" . }}
chart: {{ template "wekan.chart" . }}
component: wekan
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
type: Opaque
data:
accessKey: {{ .Values.credentials.accessKey | b64enc }}
secretKey: {{ .Values.credentials.secretKey | b64enc }}
@@ -1,27 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: {{ template "wekan.fullname" . }}-test
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: {{ template "wekan.fullname" . }}-test
imagePullPolicy: IfNotPresent
image: "docker.io/mesosphere/aws-cli:1.14.5"
command:
- sh
- -c
- aws s3 --endpoint-url=http://{{ include "wekan.fullname" . }} --region=us-east-1 ls
env:
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: {{ template "wekan.fullname" . }}
key: accessKey
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ template "wekan.fullname" . }}
key: secretKey
restartPolicy: Never
+19
View File
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ template "wekan.fullname" . }}-test-http"
labels:
app: {{ template "wekan.name" . }}
chart: {{ template "wekan.chart" . }}
component: wekan
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget', '-O', '/dev/stdout']
args: ['{{ template "wekan.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never