Skip to content

Commit

Permalink
feat: implement metadata-editor in gn helm (#6)
Browse files Browse the repository at this point in the history
* feat: implement metadata-editor in gn helm

* feat: update versions and filename
  • Loading branch information
f-necas authored Nov 9, 2023
1 parent 9c47e74 commit 34b08fd
Show file tree
Hide file tree
Showing 10 changed files with 444 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

## Datahub

Readme: https://github.com/geonetwork/geonetwork-helm-charts/tree/main/datahub
Readme: https://github.com/geonetwork/geonetwork-helm-charts/tree/main/datahub

## Metadata-editor

Readme: https://github.com/geonetwork/geonetwork-helm-charts/tree/main/metadata-editor
23 changes: 23 additions & 0 deletions metadata-editor/.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/
9 changes: 9 additions & 0 deletions metadata-editor/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: metadata-editor
description: A Helm chart to deploy the metadata-editor application
type: application
version: 0.1.0
appVersion: "1.0.0"
maintainers:
- name: geOrchestra
url: https://www.georchestra.org
82 changes: 82 additions & 0 deletions metadata-editor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Metadata-editor

UI of the web application `metadata-editor`.

`metadata-editor` is an UI application containing a dashboard for seeing metadata records, and a powerful form-based editor.


## Source Code

* https://github.com/geonetwork/geonetwork-ui/tree/main/apps/metadata-editor

## Requirements

Kubernetes: `>=1.14.0-0`

## Dependencies

None

## Installing the Chart

To install the chart with the release name `metadata-editor`

```console
helm repo add geonetwork https://helm-charts.geonetwork-opensource.org
helm repo update
helm install metadata-editor geonetwork/metadata-editor
```

## Uninstalling the Chart

To uninstall the `metadata-editor` deployment

```console
helm uninstall metadata-editor
```

The command removes all the Kubernetes components associated with the chart **including persistent volumes** and deletes the release.

## Configuration

Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values.

Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.

```console
helm install metadata-editor \
--set replicaCount="2" \
geonetwork/metadata-editor
```

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart.

```console
helm install metadata-editor geonetwork/metadata-editor -f values.yaml
```

## Metadata-editor configuration

Through the parameter `configuration.git`, you can set a git repository that will be used for configuring metadata-editor.

Both `configuration.config_directory_override` and `configuration.assets_directory_override` are available to specify the directory where metadata-editor should find the configuration.

The default values are `/conf` for the configuration and `/assets` for the assets.

Please refer to the docker documentation for more explanations about this custom configuration: https://github.com/geonetwork/geonetwork-ui/tree/main/apps/metadata-editor#specifying-a-custom-configuration-file

## Values

**Important**: Some values here are not documented because those are obvious parameters that you can find the meaning and the usuability through the Kubernetes configuration: https://kubernetes.io/docs/home/

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| image | object | See values.yaml | Set the docker image to use. |
| configuration | object | See values.yaml | [See above](#metadata-editor-configuration) |
| ingress | object | See values.yaml | Configurations for configuring ingress |

## Changelog

### Version 0.1.0

Initial version
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- define "metadata-editor.bootstrap_metadata-editor_configuration" -}}
- name: bootstrap-metadata-editor-configuration
image: bitnami/git
command:
- /bin/sh
- -c
- {{- if .Values.configuration.git.ssh_secret }}
mkdir -p /root/.ssh ;
cp /ssh-secret/ssh-privatekey /root/.ssh/id_rsa ;
chmod 0600 /root/.ssh/id_rsa ;
{{- end }}
git clone --depth 1 --single-branch {{ .Values.configuration.git.url }} -b {{ .Values.configuration.git.ref }} /etc/metadata-editor ;
{{- if .Values.configuration.git.ssh_secret }}
env:
- name: GIT_SSH_COMMAND
value: ssh -o "IdentitiesOnly=yes" -o "StrictHostKeyChecking no"
{{- end }}
volumeMounts:
- mountPath: /etc/metadata-editor
name: metadata-editor-configuration
{{- if .Values.configuration.git.ssh_secret }}
- mountPath: /ssh-secret
name: ssh-secret
{{- end }}
{{- end -}}
62 changes: 62 additions & 0 deletions metadata-editor/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "helm-metadata-editor.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "helm-metadata-editor.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "helm-metadata-editor.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "helm-metadata-editor.labels" -}}
helm.sh/chart: {{ include "helm-metadata-editor.chart" . }}
{{ include "helm-metadata-editor.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "helm-metadata-editor.selectorLabels" -}}
app.kubernetes.io/name: {{ include "helm-metadata-editor.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "helm-metadata-editor.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "helm-metadata-editor.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
87 changes: 87 additions & 0 deletions metadata-editor/templates/metadata-editor-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "helm-metadata-editor.fullname" . }}-metadata-editor-deployment
labels:
{{- include "helm-metadata-editor.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "helm-metadata-editor.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "helm-metadata-editor.selectorLabels" . | nindent 8 }}
org.geonetwork.service/name: {{ include "helm-metadata-editor.fullname" . }}-metadata-editor-deployment
spec:
{{- if .Values.configuration.git.url }}
initContainers:
{{- include "metadata-editor.bootstrap_metadata-editor_configuration" $ | nindent 6 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
{{- with .Values.lifecycle }}
lifecycle:
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: CONFIG_DIRECTORY_OVERRIDE
value: "/etc/metadata-editor/{{ .Values.configuration.override_directories.config_directory_override }}"
- name: ASSETS_DIRECTORY_OVERRIDE
value: "/etc/metadata-editor/{{ .Values.configuration.override_directories.assets_directory_override }}"
{{- with .Values.extra_environment }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: metadata-editor-configuration
mountPath: /etc/metadata-editor
volumes:
- name: metadata-editor-configuration
emptyDir: {}
{{- if .Values.configuration.git.ssh_secret }}
- name: ssh-secret
secret:
secretName: {{ .Values.configuration.git.ssh_secret }}
defaultMode: 0400
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
57 changes: 57 additions & 0 deletions metadata-editor/templates/metadata-editor-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "helm-metadata-editor.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}

kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "helm-metadata-editor.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: Prefix
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}-metadata-editor-svc
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions metadata-editor/templates/metadata-editor-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "helm-metadata-editor.fullname" . }}-metadata-editor-svc
labels:
{{- include "helm-metadata-editor.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
org.geonetwork.service/name: {{ include "helm-metadata-editor.fullname" . }}-metadata-editor-deployment
Loading

0 comments on commit 34b08fd

Please sign in to comment.