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

Feature 2368 helm k8s #2427

Merged
merged 50 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
30e9e4c
Initial helm chart for debugging purposes only.
mbjones Apr 18, 2024
d2e833b
Disable Ingress by default to avoid accidental deploys.
mbjones Apr 18, 2024
edda894
add configmap for config.js; git checkout static content
artntek Jun 3, 2024
3756462
doc update
artntek Jun 3, 2024
ea093a1
move pv/pvc yaml and add notes
artntek Jun 5, 2024
11bc6b5
final config.js
artntek Jun 5, 2024
efa461d
get source from official release zip, git, or PVC
artntek Jun 5, 2024
8e99644
move pv/pvc yaml
artntek Jun 5, 2024
8a7fac5
bump chart version
artntek Jun 5, 2024
a09abb8
set mcui version
artntek Jun 5, 2024
23261c6
use mcui version from chart yaml
artntek Jun 5, 2024
d14d29e
Update helm/README.md
artntek Jun 5, 2024
6f30219
adding global values so metacat chart can do overrides
artntek Jun 7, 2024
e887e9c
Merge branch 'feature-2368-helm-k8s' of github.com:NCEAS/metacatui in…
artntek Jun 7, 2024
ccb643e
mount configmap containing install script
artntek Jun 8, 2024
1dade31
last checkin before implementing script installation
artntek Jun 17, 2024
0fc0c4c
Merge branch 'develop' into feature-2368-helm-k8s
artntek Jun 17, 2024
e7c1bd5
not used
artntek Jun 19, 2024
a1ba8be
require theme; make config.js optional
artntek Jun 19, 2024
2f97b4a
handle different roots; autoconfig probes or make optional
artntek Jun 19, 2024
0fdc3b7
fix initContainer
artntek Jun 19, 2024
93fc142
rename for clarity
artntek Jun 19, 2024
da20230
enable pvc for custom theme
artntek Jun 20, 2024
cb1f3e2
example pv/pvc files
artntek Jun 20, 2024
d46df59
update app version
artntek Jul 1, 2024
53fd8c6
Merge branch 'main' into feature-2368-helm-k8s
artntek Jul 1, 2024
4049866
move root to global
artntek Jul 1, 2024
b7f1b4f
Update helm/README.md
artntek Jul 2, 2024
3d7a4e0
Update helm/README.md
artntek Jul 2, 2024
e26dcef
Update helm/README.md
artntek Jul 2, 2024
9e9d3f7
Update helm/README.md
artntek Jul 2, 2024
65183d0
Update helm/README.md
artntek Jul 2, 2024
60c3478
Update helm/admin/metacatui-customtheme-pvc.yaml
artntek Jul 2, 2024
817a12e
Update helm/values.yaml
artntek Jul 2, 2024
5e66f5f
Update helm/admin/metacatui-customtheme-pvc.yaml
artntek Jul 2, 2024
c998b37
Update helm/README.md
artntek Jul 2, 2024
2b6f427
Update helm/README.md
artntek Jul 2, 2024
becc7df
Update helm/README.md
artntek Jul 2, 2024
bfaf760
Update helm/README.md
artntek Jul 2, 2024
9304885
Update helm/README.md
artntek Jul 2, 2024
588f9a3
Update helm/README.md
artntek Jul 2, 2024
991c999
Update helm/README.md
artntek Jul 2, 2024
1101da0
Update helm/values.yaml
artntek Jul 2, 2024
5ea7d76
Update helm/README.md
artntek Jul 2, 2024
2b95d25
Update helm/README.md
artntek Jul 2, 2024
44b7a93
Update helm/README.md
artntek Jul 2, 2024
0d6ea3b
linting errors
artntek Jul 2, 2024
53b6611
add metadata to enable helm push to ghcr
artntek Jul 2, 2024
4f4cdb0
Merge branch 'develop' into feature-2368-helm-k8s
artntek Jul 8, 2024
f75cc64
.prettierignore helm directory contents
artntek Jul 8, 2024
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
23 changes: 23 additions & 0 deletions helm/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: metacatui
description: MetacatUI, a web interface for DataONE repositories

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.6.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "2.30.0"
107 changes: 107 additions & 0 deletions helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# MetacatUI Helm chart

This is a helm chart for deploying MetacatUI.

---
## Deployment in a Kubernetes cluster:
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved

1. Modify values.yaml as appropriate
2. install the helm chart:
```shell
$ helm -n knb upgrade --install knbmcui ./helm
```
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved

There's no need to set up any persistent storage, unless you wish to add your own theme. The chart
ships with [a few pre-defined themes](https://github.com/NCEAS/metacatui/tree/main/src/js/themes),
which can be selected in values.yaml.

---
## MetacatUI Configuration Files ('config.js')
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved

artntek marked this conversation as resolved.
Show resolved Hide resolved
The k8s version of Metacatui requires two 'config.js' configuration files:
1. the "root config" at the path `{root}/config/config.js`, and
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
2. the "theme config" in the theme directory itself (for example, see the knb `config.js` at:
https://github.com/NCEAS/metacatui/blob/main/src/js/themes/knb/config.js)
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved

The "root config" file must, at an absolute minimum, contain the name of the theme to be used; e.g:

```javascript
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
MetacatUI.AppConfig = {
theme: "knb"
};
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
```
...and metacatui will then load that theme and the corresponding "theme config".
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved

If any additional settings are defined in the "root config", Metacatui will use them to override
corresponding settings in the "theme config".

By default, this chart creates a simple "root config", which will contain any values of the form:
`key: stringValue,` or `key: intValue,` that are provided in the `appConfig:` section of
[values.yaml](./values.yaml).

If you need to provide more-complex overrides, set `appConfig.enabled: false`, and manually
create your own configMap named `<YourReleaseName>-metacatui-config-js`, containing your custom
config.js:
```shell
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
kubectl create configmap <yourReleaseName>-metacatui-config-js \
--from-file=config.js=<yourCustomConfig.js>
```
---
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved

## Using a Custom Theme

See [the MetacatUI
documentation](https://nceas.github.io/metacatui/install/configuration/index.html) for help with
creating custom themes.

If you wish to deploy MetacatUI with your own custom theme, instead of using one of the themes that
are bundled with metacatui, you will need to provide the files for that theme (including its
"theme config" file) on shared filesystem, accessed via a manually-created Persistent Volume (PV)
mount and a Persistent Volume Claim (PVC). Example files for creating PVs and PVCs are provided
in the [admin](./admin) directory.

Once you've got the chart deployed (see above), next steps are:

1. Copy your theme files to a directory on a filesystem that is accessible from your Kubernetes
artntek marked this conversation as resolved.
Show resolved Hide resolved
cluster
2. Create a Persistent Volume (PV) pointing to the correct directory on the filesystem
3. Create a PVC for the PV, and edit the `customTheme:` section in values.yaml
4. upgrade the helm chart
```shell
$ helm -n knb upgrade --install knbmcui ./helm

artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
---

## Development on Localhost

(e.g. Rancher Desktop/Docker Desktop)
artntek marked this conversation as resolved.
Show resolved Hide resolved

1. Create a namespace for the deployment (e.g. `mcui`)
2. Create a PV that is mapped to a local `hostPath` directory containing the source code
3. Create a PVC for the PV
4. Modify values.yaml:
1. Add the name of the PVC, so MetacatUI can find the files
2. Set your hostname for the Ingress definition
5. install the helm chart:
```shell
$ helm -n mcui upgrade --install --debug mcui ./helm
Release "mcui" has been upgraded. Happy Helming!
NAME: mcui
LAST DEPLOYED: Wed Apr 17 19:45:58 2024
NAMESPACE: mcui
STATUS: deployed
REVISION: 11
...etc

artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
You can now edit the MetacatUI source files, and changes will be immediately visible in your k8s
deployment.

You will likely need to edit the `config.js` file to get a minimal setup working. Example contents
for `config/config.js`:

```javascript
MetacatUI.AppConfig = {
root: "/",
baseUrl: "https://dev.nceas.ucsb.edu/knb/d1/mn"
}
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
```
30 changes: 30 additions & 0 deletions helm/admin/metacatui-customtheme-pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## EXAMPLE file for manually creating a Persistent Volume to store a metacatui custom theme.
## Needed only if 'customTheme.enabled:' is set to 'true' in values.yaml.
## EDIT this file to replace "$RELEASENAME", "$YOUR-CLUSTER-ID" and the "rootPath"
apiVersion: v1
kind: PersistentVolume
metadata:
# See https://github.com/DataONEorg/k8s-cluster/blob/main/storage/storage.md#dataone-volume-naming-conventions
# cephs-{release}-{function}-{instance}, where {release} usually = {namespace}
name: &pv-name cephfs-$RELEASENAME-metacatui-customtheme
spec:
accessModes:
- ReadOnlyMany
capacity:
storage: 100Mi
csi:
driver: cephfs.csi.ceph.com
nodeStageSecretRef:
# node stage secret name
name: csi-cephfs-$RELEASENAME-secret
# node stage secret namespace where above secret is created
namespace: ceph-csi-cephfs
volumeAttributes:
clusterID: $YOUR-CLUSTER-ID
fsName: cephfs
rootPath: /volumes/YOUR-subvol-group/YOUR-subvol/YOUR-ID/repos/YOUR_REPO/metacatui
staticVolume: "true"
volumeHandle: *pv-name
persistentVolumeReclaimPolicy: Retain
storageClassName: csi-cephfs-sc
volumeMode: Filesystem
20 changes: 20 additions & 0 deletions helm/admin/metacatui-customtheme-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## EXAMPLE file for manually creating a Persistent Volume Claim to access the PV containing a
## metacatui custom theme.
## Needed only if 'customTheme.enabled:' is set to 'true' in values.yaml.
## EDIT this file to replace "$RELEASENAME" and "$NAMESPACE"
##
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: $RELEASENAME-metacatui-customtheme
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
## NOTE: namespace must match the deployment namespace
namespace: $NAMESPACE
spec:
accessModes:
- ReadWriteOnce
artntek marked this conversation as resolved.
Show resolved Hide resolved
artntek marked this conversation as resolved.
Show resolved Hide resolved
resources:
requests:
storage: 100Mi
storageClassName: csi-cephfs-sc
volumeMode: Filesystem
volumeName: cephfs-RELEASENAME-metacatui-customtheme
18 changes: 18 additions & 0 deletions helm/admin/metacatui-sourcecode-pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## EXAMPLE file for manually creating a Persistent Volume to store the metacatui source code,
## typically for development purposes (so edits can be seen in realtime).
## Needed only if 'source.from:' is set to 'pvc' in values.yaml.
##
apiVersion: v1
kind: PersistentVolume
metadata:
name: metacatui-pv
spec:
accessModes:
- ReadWriteOnce
artntek marked this conversation as resolved.
Show resolved Hide resolved
capacity:
storage: 10Gi
hostPath:
path: /your/host/path/here # e.g. /Users/jones/development/metacatui/src
artntek marked this conversation as resolved.
Show resolved Hide resolved
type: ""
persistentVolumeReclaimPolicy: Retain
volumeMode: Filesystem
18 changes: 18 additions & 0 deletions helm/admin/metacatui-sourcecode-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## EXAMPLE file for manually creating a Persistent Volume Claim to access the PV containing the
## metacatui source code (see metacatui-pv.yaml), typically for development purposes.
## Needed only if 'source.from:' is set to 'pvc' in values.yaml.
##
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: metacatui-pvc
namespace: mcui
spec:
accessModes:
- ReadWriteOnce
artntek marked this conversation as resolved.
Show resolved Hide resolved
resources:
requests:
storage: 10Gi
storageClassName: ""
volumeMode: Filesystem
volumeName: metacatui-pv
17 changes: 17 additions & 0 deletions helm/config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MetacatUI.AppConfig = {
{{- $ignoreList := list "enabled" "theme" "root" "baseUrl" "metacatContext" "d1CNBaseUrl" -}}
artntek marked this conversation as resolved.
Show resolved Hide resolved
{{- range $key, $value := .Values.appConfig }}
{{- if not (has $key $ignoreList) }}
{{- if eq (typeOf $value) "string" }}
{{- $key | nindent 4 }}: {{ $value | quote }},
{{- else }}
{{- $key | nindent 4 }}: {{ $value }},
{{- end }}
{{- end }}
{{- end -}}
{{- include "metacatui.cn.url" . | nindent 4 }}
theme: {{ required "metacatUiThemeName_is_REQUIRED" .Values.global.metacatUiThemeName | quote }},
root: {{ required "root_is_REQUIRED" .Values.global.metacatUiWebRoot | quote }},
metacatContext: {{ required "metacatAppContext_is_REQUIRED" .Values.global.metacatAppContext | quote }},
baseUrl: {{ required "metacatExternalBaseUrl_is_REQUIRED" .Values.global.metacatExternalBaseUrl | quote }}
}
Binary file added helm/templates/.ingress.yaml.swp
Binary file not shown.
22 changes: 22 additions & 0 deletions helm/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "metacatui.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "metacatui.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "metacatui.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "metacatui.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
Loading
Loading