From d21ae8a4788c37bfa85c465459592eb922873715 Mon Sep 17 00:00:00 2001 From: fengxsong Date: Wed, 1 Mar 2023 20:17:04 +0800 Subject: [PATCH] feat: support making configs in values.yaml (#1595) Signed-off-by: fengxsong --- manifests/casdoor/templates/configmap.yaml | 23 +++------------ manifests/casdoor/templates/deployment.yaml | 32 +++++++++++++-------- manifests/casdoor/values.yaml | 30 +++++++++++++++++-- 3 files changed, 52 insertions(+), 33 deletions(-) diff --git a/manifests/casdoor/templates/configmap.yaml b/manifests/casdoor/templates/configmap.yaml index 542e0acd..0d93c5cd 100644 --- a/manifests/casdoor/templates/configmap.yaml +++ b/manifests/casdoor/templates/configmap.yaml @@ -1,23 +1,8 @@ apiVersion: v1 kind: ConfigMap metadata: - name: casdoor-config + name: {{ printf "%s-config" (include "casdoor.fullname" .) }} + labels: + {{- include "casdoor.labels" . | nindent 4 }} data: - app.conf: | - appname = casdoor - httpport = 80 - runmode = dev - SessionOn = true - copyrequestbody = true - driverName = mysql - dataSourceName = root:123456@tcp(localhost:3306)/ - dbName = casdoor - redisEndpoint = - defaultStorageProvider = - isCloudIntranet = false - authState = "casdoor" - socks5Proxy = "127.0.0.1:10808" - verificationCodeTimeout = 10 - initScore = 2000 - logPostOnly = true - origin = "https://door.casbin.com" \ No newline at end of file + app.conf: {{ tpl .Values.config . | toYaml | nindent 4 }} diff --git a/manifests/casdoor/templates/deployment.yaml b/manifests/casdoor/templates/deployment.yaml index 21aaa2f8..ead07470 100644 --- a/manifests/casdoor/templates/deployment.yaml +++ b/manifests/casdoor/templates/deployment.yaml @@ -13,10 +13,11 @@ spec: {{- include "casdoor.selectorLabels" . | nindent 6 }} template: metadata: - {{- with .Values.podAnnotations }} annotations: + checksum/config: {{ tpl .Values.config . | toYaml | sha256sum }} + {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} labels: {{- include "casdoor.selectorLabels" . | nindent 8 }} spec: @@ -34,18 +35,25 @@ spec: image: "{{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} # command: ["sleep", "100000000"] + env: + - name: RUNNING_IN_DOCKER + value: "true" ports: - name: http - containerPort: 80 + containerPort: {{ .Values.service.port }} protocol: TCP - # livenessProbe: - # httpGet: - # path: / - # port: http - # readinessProbe: - # httpGet: - # path: / - # port: http + {{ if .Values.probe.liveness.enabled }} + livenessProbe: + httpGet: + path: / + port: http + {{ end }} + {{ if .Values.probe.readiness.enabled }} + readinessProbe: + httpGet: + path: / + port: http + {{ end }} resources: {{- toYaml .Values.resources | nindent 12 }} volumeMounts: @@ -60,7 +68,7 @@ spec: items: - key: app.conf path: app.conf - name: casdoor-config + name: {{ printf "%s-config" (include "casdoor.fullname" .) }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/manifests/casdoor/values.yaml b/manifests/casdoor/values.yaml index aeaff91d..f39ad685 100644 --- a/manifests/casdoor/values.yaml +++ b/manifests/casdoor/values.yaml @@ -6,11 +6,31 @@ replicaCount: 1 image: repository: casbin - name: casdoor-all-in-one + name: casdoor pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "" +# ref: https://casdoor.org/docs/basic/server-installation#via-ini-file +config: | + appname = casdoor + httpport = {{ .Values.service.port }} + runmode = dev + SessionOn = true + copyrequestbody = true + driverName = sqlite + dataSourceName = "file:ent?mode=memory&cache=shared&_fk=1" + dbName = casdoor + redisEndpoint = + defaultStorageProvider = + isCloudIntranet = false + authState = "casdoor" + socks5Proxy = "" + verificationCodeTimeout = 10 + initScore = 2000 + logPostOnly = true + origin = "https://door.casbin.com" + imagePullSecrets: [] nameOverride: "" fullnameOverride: "" @@ -37,9 +57,15 @@ securityContext: {} # runAsNonRoot: true # runAsUser: 1000 +probe: + readiness: + enabled: true + liveness: + enabled: true + service: type: ClusterIP - port: 80 + port: 8000 ingress: enabled: false