Skip to content

Commit

Permalink
Add applyToNginx for extraFileMappings (#337)
Browse files Browse the repository at this point in the history
* Add applyToNginx for extraFileMappings

* Add applyToNginx to welcome page

* Update README for extraFileMappings

* Add spaces to extraFileMappings
  • Loading branch information
almahmoud authored Oct 8, 2021
1 parent 5812c74 commit ba1f2fc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
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

0 comments on commit ba1f2fc

Please sign in to comment.