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

Add applyToNginx for extraFileMappings #337

Merged
merged 4 commits into from
Oct 8, 2021
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
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,25 @@ jobHandlers:

## Extra File Mappings

The `extraFileMappings` field can be used to inject files to arbitrary paths in the `job`, `web`, or `workflow` handlers. The contents of the file can be specified directly in the `values.yml` file with the `content` attribute, or by specifying the path to the file to be injected with the `path` attribute.
The `extraFileMappings` field can be used to inject files to arbitrary paths in the `nginx` deployment, as well as any of the `job`, `web`, or `workflow` handlers.

The contents of the file can be specified directly in the `values.yml` file with the `content` attribute.

The `tpl` flag will determine whether these contents are run through the helm templating engine.

Note: when running with `tpl: true`, brackets (`{{ }}`) not meant for Helm should be escaped. One way of escaping is: `{{ '{{ mynon-helm-content}}' }}`

```yaml
extraFileMappings:
/galaxy/server/static/welcome.html:
applyToWeb: true
applyToJob: false
applyToWorkflow: false
applyToNginx: true
tpl: false
content: |
<!DOCTYPE html>
<html>...</html>
/galaxy/server/config/object_store_conf.xml:
applyToWeb: true
path: files/config/object_store_conf.xml
```

**NOTE** for security reasons Helm will not load files from outside the chart so the `path` must be a relative path to location inside the chart directory. This will change when [helm#3276](https://github.com/helm/helm/issues/3276) is resolved. In the interim files can be loaded from external locations by:
Expand Down
26 changes: 26 additions & 0 deletions galaxy/templates/deployment-nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
{{- range $key, $entry := .Values.extraFileMappings -}}
{{- if $entry.applyToNginx }}
- name: {{ include "galaxy.getExtraFilesUniqueName" $key }}
mountPath: {{ $key }}
subPath: {{ include "galaxy.getFilenameFromPath" $key }}
{{- end }}
{{- end }}
- name: static-dir
mountPath: /tmp/galaxy
command: ['/bin/sh', '-c', 'cp -r /galaxy/server/static /tmp/galaxy/static;']
Expand All @@ -49,6 +56,13 @@ spec:
containerPort: 80
protocol: TCP
volumeMounts:
{{- range $key, $entry := .Values.extraFileMappings -}}
{{- if $entry.applyToNginx }}
- name: {{ include "galaxy.getExtraFilesUniqueName" $key }}
mountPath: {{ $key }}
subPath: {{ include "galaxy.getFilenameFromPath" $key }}
{{- end }}
{{- end }}
- name: nginx-conf
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
Expand Down Expand Up @@ -81,6 +95,18 @@ spec:
exec:
command: ["/usr/sbin/nginx","-s","quit"]
volumes:
{{- range $key, $entry := .Values.extraFileMappings -}}
{{- if $entry.applyToNginx }}
- name: {{ include "galaxy.getExtraFilesUniqueName" $key }}
{{- if $entry.useSecret }}
secret:
secretName: {{ printf "%s-%s" (include "galaxy.fullname" $) (include "galaxy.getExtraFilesUniqueName" $key) }}
{{- else }}
configMap:
name: {{ printf "%s-%s" (include "galaxy.fullname" $) (include "galaxy.getExtraFilesUniqueName" $key) }}
{{- end }}
{{- end }}
{{- end }}
- name: nginx-conf
configMap:
name: {{ template "galaxy.fullname" $ }}-nginx-conf
Expand Down
1 change: 1 addition & 0 deletions galaxy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ extraFileMappings:
applyToJob: false
applyToWeb: true
applyToWorkflow: false
applyToNginx: true
tpl: true
content: |
<!DOCTYPE html>
Expand Down