feat(helm): support for extra volume mounts (#2584)

* feat(helm): support for extraVolumes and extraVolumeMounts

* ci(helm): run helm unittests
This commit is contained in:
Michael 2024-01-06 20:30:44 +01:00 committed by GitHub
parent fddd4a12b8
commit 9e536850fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 179 additions and 14 deletions

View File

@ -5,7 +5,7 @@ on:
branches:
- master
paths:
- 'manifests/casdoor/Chart.yaml'
- "manifests/casdoor/**"
jobs:
release-helm-chart:
@ -18,6 +18,12 @@ jobs:
- name: Set up Helm
uses: azure/setup-helm@v3
- name: Run helm unittest
id: unittest
run: |
helm plugin install https://github.com/helm-unittest/helm-unittest.git
helm unittest manifests/casdoor
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
@ -37,4 +43,4 @@ jobs:
- name: Commit updated helm index.yaml
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'ci: update helm index.yaml'
commit_message: "ci: update helm index.yaml"

3
.gitignore vendored
View File

@ -31,3 +31,6 @@ commentsRouter*.go
# ignore build result
casdoor
server
# include helm-chart
!manifests/casdoor

View File

@ -57,21 +57,27 @@ spec:
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config-volume
mountPath: /conf
- name: config-volume
mountPath: /conf
{{- if .Values.extraVolumeMounts }}
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
{{- end }}
{{ if .Values.extraContainersEnabled }}
{{- .Values.extraContainers | nindent 8 }}
{{- end }}
volumes:
- name: config-volume
projected:
defaultMode: 420
sources:
- configMap:
items:
- key: app.conf
path: app.conf
name: {{ printf "%s-config" (include "casdoor.fullname" .) }}
- name: config-volume
projected:
defaultMode: 420
sources:
- configMap:
name: {{ printf "%s-config" (include "casdoor.fullname" .) }}
items:
- key: app.conf
path: app.conf
{{- if .Values.extraVolumes }}
{{- toYaml .Values.extraVolumes | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}

View File

@ -0,0 +1,128 @@
has extraVolume and extraVolumeMounts:
1: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: casdoor-helm-charts
app.kubernetes.io/version: 1.2.3
helm.sh/chart: casdoor-helm-charts-1.0.0
name: RELEASE-NAME-casdoor-helm-charts
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: casdoor-helm-charts
template:
metadata:
annotations:
checksum/config: 529bc7ea51d30d00fefc46d24be7446d0637939827bccc1c3f03755f70059470
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: casdoor-helm-charts
spec:
containers:
- env:
- name: RUNNING_IN_DOCKER
value: "true"
image: casbin/casdoor:1.2.3
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /
port: http
name: casdoor-helm-charts
ports:
- containerPort: 8000
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /
port: http
resources: {}
securityContext: {}
volumeMounts:
- mountPath: /conf
name: config-volume
- mountPath: /extra-volume
name: extra-volume
securityContext: {}
serviceAccountName: RELEASE-NAME-casdoor-helm-charts
volumes:
- name: config-volume
projected:
defaultMode: 420
sources:
- configMap:
items:
- key: app.conf
path: app.conf
name: RELEASE-NAME-casdoor-helm-charts-config
- emptyDir: {}
name: extra-volume
manifest should match snapshot:
1: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: casdoor-helm-charts
app.kubernetes.io/version: 1.2.3
helm.sh/chart: casdoor-helm-charts-1.0.0
name: RELEASE-NAME-casdoor-helm-charts
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: casdoor-helm-charts
template:
metadata:
annotations:
checksum/config: 529bc7ea51d30d00fefc46d24be7446d0637939827bccc1c3f03755f70059470
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: casdoor-helm-charts
spec:
containers:
- env:
- name: RUNNING_IN_DOCKER
value: "true"
image: casbin/casdoor:1.2.3
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /
port: http
name: casdoor-helm-charts
ports:
- containerPort: 8000
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /
port: http
resources: {}
securityContext: {}
volumeMounts:
- mountPath: /conf
name: config-volume
securityContext: {}
serviceAccountName: RELEASE-NAME-casdoor-helm-charts
volumes:
- name: config-volume
projected:
defaultMode: 420
sources:
- configMap:
items:
- key: app.conf
path: app.conf
name: RELEASE-NAME-casdoor-helm-charts-config

View File

@ -0,0 +1,20 @@
suite: test deployment
templates:
- deployment.yaml
chart:
version: 1.0.0
appVersion: 1.2.3
tests:
- it: manifest should match snapshot
asserts:
- matchSnapshot: {}
- it: has extraVolume and extraVolumeMounts
set:
extraVolumes:
- name: extra-volume
emptyDir: {}
extraVolumeMounts:
- name: extra-volume
mountPath: /extra-volume
asserts:
- matchSnapshot: {}

View File

@ -114,4 +114,6 @@ extraContainersEnabled: false
extraContainers: ""
# extraContainers: |
# - name: ...
# image: ...
# image: ...
extraVolumeMounts: []
extraVolumes: []