Skip to content

Commit

Permalink
Merge pull request #2493 from NCEAS/feature-2492-k8s-nginx-cfg
Browse files Browse the repository at this point in the history
Feature 2492 k8s nginx cfg
  • Loading branch information
rushirajnenuji authored Jul 31, 2024
2 parents 0c598ee + 63e1ca7 commit d040c1d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
27 changes: 27 additions & 0 deletions helm/config/nginx-custom.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## This file contains custom configuration for nginx
## See https://nginx.org/en/docs/http/request_processing.html
## It will override any existing, matching config in /etc/nginx/nginx.conf
##
server {
listen 80 default_server;
listen [::]:80;
server_name _;

location {{ include "metacatui.clean.root" . }}/ {
root /usr/share/nginx/html;
index index.html index.htm;

# See https://nceas.github.io/metacatui/install/apache
#
#
# 1. Serve index.html instead of a 404 error in the MetacatUI directory.
# Equivalent to Apache directive: FallbackResource /metacatui/index.html
#
try_files $uri $uri/ {{ include "metacatui.clean.root" . }}/index.html;

# 2. Allow encoded slashes in URLs so encoded identifiers can be sent in MetacatUI URLs.
# Equivalent to Apache directive: AllowEncodedSlashes On
# (Apache allows encoded slashes to be used, and automatically decodes them)
# ** No config required; This is how NGINX behaves by default **
}
}
11 changes: 11 additions & 0 deletions helm/templates/config-js-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.appConfig.enabled }}
# Load only the "config/config.js" file into a ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-metacatui-config-js
labels:
{{- include "metacatui.labels" . | nindent 4 }}
data:
{{- (tpl (.Files.Glob "config/config.js").AsConfig . ) | nindent 2 }}
{{- end }}
6 changes: 2 additions & 4 deletions helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{{- if .Values.appConfig.enabled }}
# Load all files in the "config" directory into a ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-metacatui-config-js
name: {{ .Release.Name }}-metacatui-config-all
labels:
{{- include "metacatui.labels" . | nindent 4 }}
data:
{{- (tpl (.Files.Glob "config/config.js").AsConfig . ) | nindent 2 }}
{{- end }}
{{- (tpl (.Files.Glob "config/*").AsConfig . ) | nindent 2 }}
15 changes: 12 additions & 3 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ spec:
{{- include "metacatui.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- $configfiles := (.Files.Glob "config/*").AsConfig }}
checksum/config: {{ printf "%s" $configfiles | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "metacatui.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
Expand Down Expand Up @@ -136,11 +138,18 @@ spec:
- name: {{ .Release.Name }}-mcui-config-js
mountPath: {{ include "metacatui.root.mountpath" . }}/config/config.js
subPath: config.js
- name: {{ .Release.Name }}-mcui-config-all
mountPath: /etc/nginx/conf.d/default.conf
subPath: nginx-custom.conf
volumes:
- name: {{ .Release.Name }}-mcui-config-js
configMap:
name: {{ .Release.Name }}-metacatui-config-js
defaultMode: 0644
- name: {{ .Release.Name }}-mcui-config-all
configMap:
name: {{ .Release.Name }}-metacatui-config-all
defaultMode: 0644
- name: {{ .Release.Name }}-mcui-source-files
{{- if eq $source "pvc" }}
persistentVolumeClaim:
Expand Down

0 comments on commit d040c1d

Please sign in to comment.