Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SS-342 and SS-1167 allow custom commands for custom apps #58

Merged
merged 3 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading