Provide more options for Helm chart (#1485)

Add more configuration options to the helm chart including:

* lifecycleHooks
* extraEnv
* extraEnvFrom
* extraVolumes
* extraVolumeMounts
* Node port option for the service

It is now possible to define plugin versions as YAML variables for better maintainability.
This change will also disable the default helm repository in order to fix the build.

Co-authored-by: Sebastian Sdorra <sebastian.sdorra@cloudogu.com>
This commit is contained in:
schnatterer
2021-01-07 15:34:11 +01:00
committed by GitHub
parent c579de108f
commit 3118d843d3
6 changed files with 71 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Added
- Provide more options for Helm chart ([#1485](https://github.com/scm-manager/scm-manager/pull/1485))
- Option to create a permanent link to a source file ([#1489](https://github.com/scm-manager/scm-manager/pull/1489))
- add markdown codeblock renderer extension point ([#1492](https://github.com/scm-manager/scm-manager/pull/1492))

View File

@@ -146,7 +146,7 @@
<plugin>
<groupId>com.kiwigrid</groupId>
<artifactId>helm-maven-plugin</artifactId>
<version>5.4</version>
<version>5.6</version>
<extensions>true</extensions>
<configuration>
<chartDirectory>${project.basedir}/target/chart</chartDirectory>
@@ -164,6 +164,8 @@
<url>${helm.repository}</url>
<type>ARTIFACTORY</type>
</uploadRepoSnapshot>
<!-- Work around https://github.com/kiwigrid/helm-maven-plugin/issues/102 -->
<addDefaultRepo>false</addDefaultRepo>
</configuration>
</plugin>

View File

@@ -68,6 +68,10 @@ spec:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.lifecycleHooks }}
lifecycle:
{{ tpl .Values.lifecycleHooks . | indent 12 }}
{{- end }}
ports:
- name: http
containerPort: 8080
@@ -89,6 +93,17 @@ spec:
mountPath: /var/lib/scm
- name: config
mountPath: /opt/scm-server/conf
{{- with .Values.extraVolumeMounts }}
{{- tpl . $ | nindent 12 }}
{{- end }}
env:
{{- with .Values.extraEnv }}
{{- tpl . $ | nindent 12 }}
{{- end }}
envFrom:
{{- with .Values.extraEnvFrom }}
{{- tpl . $ | nindent 12 }}
{{- end }}
volumes:
- name: data
{{- if .Values.persistence.enabled }}
@@ -105,6 +120,9 @@ spec:
configMap:
name: {{ include "scm-manager.fullname" . }}-scripts
{{- end }}
{{- with .Values.extraVolumes }}
{{- tpl . $ | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}

View File

@@ -38,8 +38,8 @@ data:
mkdir -p /data/plugins
chown 1000:1000 /data/plugins
{{ range $i, $plugin := .Values.plugins }}
# install plugin {{ $plugin.name }}
wget -O /data/plugins/{{ $plugin.name }}.smp {{ $plugin.url }}
chown 1000:1000 /data/plugins/{{ $plugin.name }}.smp
# install plugin {{ tpl $plugin.name $ }}
wget -O /data/plugins/{{ tpl $plugin.name $ }}.smp {{ tpl $plugin.url $ }}
chown 1000:1000 /data/plugins/{{ tpl $plugin.name $ }}.smp
{{ end }}
{{ end }}

View File

@@ -38,6 +38,9 @@ spec:
targetPort: 8080
protocol: TCP
name: http
{{- if (not (empty .Values.service.nodePort)) }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
selector:
app: {{ include "scm-manager.name" . }}
release: {{ .Release.Name }}

View File

@@ -44,6 +44,8 @@ service:
type: LoadBalancer
# service.port -- k8s service port
port: 80
# service.nodePort -- k8s service node port
#nodePort:
ingress:
# ingress.enabled -- Enables ingress
@@ -117,3 +119,44 @@ tolerations: []
# affinity -- Affinity settings
affinity: {}
# lifecycleHooks for the container to automate configuration before or after startup,
# i.e. to create users or repos through REST API calls
lifecycleHooks: |
# postStart:
# exec:
# command: ["/bin/bash", "-c", "echo lifecycleHook"]
# Other option: Insert scrip file via "helm install --set-file=postStartHookScript=${pwd()}/postStartHook.sh"
# lifecycleHooks: |-
# postStart:
# exec:
# command:
# - "/bin/bash"
# - "-c"
# - >
# {{ tpl (required ".Values.postStartHookScript required!" .Values.postStartHookScript) . | indent 8 }}
# extraEnv -- Additional environment variables, parsed through tpl function
extraEnv: |
# - name: TZ
# value: "{{.Values.timezone}}"
# extraEnvFrom -- Additional environment variables mapped from Secret or ConfigMap, parsed through tpl function
extraEnvFrom: |
# - secretRef:
# name: "{{.Values.mail.credentials}}"
# extraVolumes -- Add additional volumes, parsed through tpl function
extraVolumes: |
# - name: bucket-service-account
# secret:
# secretName: "{{.Values.bucket.secretName}}"
# items:
# - key: service_account.json
# path: service_account.json
# extraVolumeMounts -- Add additional volumes mounts, parsed through tpl function
extraVolumeMounts: |
# - name: bucket-service-account
# mountPath: "{{.Values.bucket.mountPath}}"
# readOnly: true