Skip to content

Commit

Permalink
add configmap for config.js; git checkout static content
Browse files Browse the repository at this point in the history
  • Loading branch information
artntek committed Jun 3, 2024
1 parent d2e833b commit edda894
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 22 deletions.
28 changes: 28 additions & 0 deletions helm/config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
MetacatUI.AppConfig = {
root: {{ .Values.appConfig.root | quote }},
theme: {{ .Values.appConfig.theme | quote }},
baseUrl: {{ .Values.appConfig.baseUrl | quote }}
{{- $optionalStringValues := list
"d1CNBaseUrl"
"mapKey"
"mdqBaseUrl"
"dataoneSearchUrl"
"googleAnalyticsKey"
"bioportalAPIKey"
"cesiumToken"
-}}
{{- $optionalIntValues := list
"portalLimit"
-}}
{{- range $key, $value := .Values.appConfig }}
{{- if has $key $optionalStringValues }}
{{- (printf ",") }}
{{- (printf "%s: \"%s\"" $key (toString $value)) | nindent 6 }}
{{- else }}
{{- if has $key $optionalIntValues }}
{{- (printf ",") }}
{{- (printf "%s: %s" $key (toString $value)) | nindent 6 }}
{{- end }}
{{- end }}
{{- end }}
}
9 changes: 9 additions & 0 deletions helm/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Load all files in the "config" directory into a ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-metacatui-configjs
labels:
{{- include "metacatui.labels" . | nindent 4 }}
data:
{{ (tpl (.Files.Glob "config/*").AsConfig . ) | nindent 4 }}
52 changes: 42 additions & 10 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ spec:
serviceAccountName: {{ include "metacatui.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if .Values.git.enabled }}
initContainers:
- name: git-clone
image: alpine/git
command:
- sh
- -c
- >
git clone -b {{ .Values.git.revision }} --depth 1 {{ .Values.git.repoUrl }} /metacatui
volumeMounts:
- name: {{ .Release.Name }}-mcui-static-files
mountPath: /metacatui
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
Expand All @@ -40,24 +53,43 @@ spec:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{- with .Values.livenessProbe }}
livenessProbe:
httpGet:
path: /
port: http
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.readinessProbe }}
readinessProbe:
httpGet:
path: /
port: http
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- if .Values.appConfig.enabled }}
- name: {{ .Release.Name }}-mcui-config-vol
mountPath: /usr/share/nginx/html/config/config.js
subPath: config.js
{{- end }}
- name: {{ .Release.Name }}-mcui-static-files
mountPath: "/usr/share/nginx/html"
subPath: "src"
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.appConfig.enabled }}
- name: {{ .Release.Name }}-mcui-config-vol
configMap:
name: {{ .Release.Name }}-metacatui-configjs
defaultMode: 0644
{{- end }}
{{- if .Values.git.enabled }}
- name: {{ .Release.Name }}-mcui-static-files
emptyDir: {}
{{- else }}
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
80 changes: 68 additions & 12 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,65 @@

replicaCount: 1

## appConfig contains the MetacatUI.AppConfig settings that can be overridden. Uses a configMap to
## define MetacatUI.AppConfig, replacing the version of config/config.js found on the mounted drive.
## Note that changes to the configMap will not be read unless the pod is restarted, and changes to
## these values will not be reflected in the configMap unless you do a 'helm upgrade'.
##
appConfig:
## appConfig.enabled Use a configMap to define MetacatUI.AppConfig, replacing the on-disk version
## Typical use is "false" for development purposes, and "true" for more-permanent deployments
##
enabled: true

## appConfig.root (required) The url root to be appended after the appConfig.baseUrl, below
##
root: "/"

## appConfig.theme (required) Corresponds to the name of one of the directories in src/js/themes/
##
theme: "default"

## appConfig.baseUrl (required) the base url (typically defined by the ingress)
##
baseUrl: "http://localhost:8080/"

## Optional configuration -- leave commented to use metacatui default values
##
# d1CNBaseUrl: "https://cn-sandbox.test.dataone.org/cn"
# mapKey: "your-map-key-here"
# mdqBaseUrl: "https://localhost:8080:30443/quality"
# dataoneSearchUrl: "https://search-stage.test.dataone.org"
# portalLimit: 100
# googleAnalyticsKey: "your-google-analytics-key-here"
# bioportalAPIKey: "your-bio-portal-api-key-here"
# cesiumToken: "your-cesium-token-here"


git:
## git.enabled set 'true' to create an initContainer and do a git checkout of the metacatui files
## NOTE: If you set git.enabled: 'false', then you will need to provide values for 'volumes'
## that
enabled: true

## git.repoUrl the https url of the repo to be cloned
repoUrl: "https://github.com/NCEAS/metacatui.git"

## git.revision can be any string that makes sense after the command `git checkout`... - for
## example:
## git checkout tags/2.29.0 => revision: "tags/2.29.0"
## git checkout develop => revision: "develop"
##
revision: "main"

## volumes Uncomment and provide values if you want to use a pre-configured PVC instead of doing a
## git checkout
#volumes:
# ## volumes.name substitute your own release name, but do NOT change the '-mcui-static-files' part
# - name: <Your-Release-Name>-mcui-static-files
# persistentVolumeClaim:
# claimName: <Your-Pre-Configured-pvc>

image:
repository: nginx
pullPolicy: IfNotPresent
Expand All @@ -14,6 +73,15 @@ imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

#livenessProbe:
# httpGet:
# path: /
# port: http
#readinessProbe:
# httpGet:
# path: /
# port: http

serviceAccount:
# Specifies whether a service account should be created
create: false
Expand Down Expand Up @@ -85,18 +153,6 @@ autoscaling:
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

# Additional volumes on the output Deployment definition.
volumes:
- name: metacatui-pvc
persistentVolumeClaim:
claimName: metacatui-pvc

# Additional volumeMounts on the output Deployment definition.
volumeMounts:
- name: metacatui-pvc
mountPath: "/usr/share/nginx/html"
readOnly: true

nodeSelector: {}

tolerations: []
Expand Down

0 comments on commit edda894

Please sign in to comment.