Skip to content

Commit

Permalink
SS-342 and SS-1167 allow custom commands for custom apps (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
churnikov authored Oct 16, 2024
1 parent d3b07a5 commit bded0be
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/custom-app/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
appVersion: "0.1"
description: A Helm chart for a standard serve app
name: custom-app
version: 1.0.2
version: 1.1.0
maintainers:
- name: Team Whale
email: [email protected]
40 changes: 36 additions & 4 deletions apps/custom-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ spec:
type: RuntimeDefault
fsGroup: {{ .Values.appconfig.userid | default 1000 }}

{{- if .Values.apps.volumeK8s }}
{{- if or .Values.apps.volumeK8s .Values.appconfig.startupCommand }}
initContainers:
{{- end}}
{{- if .Values.apps.volumeK8s }}
- name: copy-to-pvc
image: {{ .Values.appconfig.image }}
imagePullPolicy: IfNotPresent
Expand All @@ -54,16 +56,34 @@ spec:
{{- range $key, $value := .Values.apps.volumeK8s }}
- name: {{ $key }}
mountPath: /tmp
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.appconfig.startupCommand}}
- name: create-startup-script
image: busybox
command:
- /bin/sh
- -c
- |
echo "{{ .Values.appconfig.startupCommand }}" > /scripts/custom-start-script.sh;
chmod +x /scripts/custom-start-script.sh;
volumeMounts:
- name: startup-script
mountPath: /scripts
{{- end}}
containers:
- name: {{ .Values.appname }}
image: {{ .Values.appconfig.image }}
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
{{- if .Values.appconfig.startupCommand }}
- /scripts/custom-start-script.sh;
{{- else }}
- ./start-script.sh;
{{- end }}

ports:
- containerPort: {{ .Values.appconfig.port }}
securityContext:
Expand All @@ -77,20 +97,32 @@ spec:
- all
resources:
{{- toYaml .Values.flavor | nindent 10 }}
{{- if .Values.apps.volumeK8s }}
{{- if or .Values.appconfig.startupCommand .Values.apps.volumeK8s }}
volumeMounts:
{{- end }}
{{- if .Values.apps.volumeK8s }}
{{- range $key, $value := .Values.apps.volumeK8s }}
- name: {{ $key }}
mountPath: {{ $.Values.appconfig.path }}
{{- end }}
{{- end }}
{{- if .Values.appconfig.startupCommand}}
- name: startup-script
mountPath: /scripts
{{- end}}
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
{{ if .Values.apps.volumeK8s }}
{{ if or .Values.apps.volumeK8s .Values.appconfig.startupCommand }}
volumes:
{{- end }}
{{ if .Values.apps.volumeK8s }}
{{- range $key, $value := .Values.apps.volumeK8s }}
- name: {{ $key }}
persistentVolumeClaim:
claimName: {{ $value.release }}
{{- end }}
{{ end }}
{{- if .Values.appconfig.startupCommand}}
- name: startup-script
emptyDir: { }
{{- end}}
1 change: 1 addition & 0 deletions apps/custom-app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ appconfig:
port: 8501
image: ghcr.io/scilifelabdatacentre/example-streamlit:240312-1531
path: /home
startupCommand: {}

service:
name: customapp-svc
Expand Down

0 comments on commit bded0be

Please sign in to comment.