Skip to content

Commit

Permalink
add mviewer helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
edevosc2c committed Oct 26, 2023
1 parent 2c8b16d commit d17ecf5
Show file tree
Hide file tree
Showing 9 changed files with 426 additions and 0 deletions.
23 changes: 23 additions & 0 deletions mviewer/.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 mviewer/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: mviewer
description: A Helm chart to deploy the mviewer application
type: application
version: 0.1.0
appVersion: "3.9"
maintainers:
- name: geOrchestra
url: https://www.georchestra.org
79 changes: 79 additions & 0 deletions mviewer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Mviewer

mviewer est une application cartographique initiée et développée par la Région Bretagne, sous le nom de Kartenn (carte en breton).

Le code source de cette application est librement réutilisable depuis 2014.

De nombreuses collectivités mais également des entreprises, le secteur de la recherche et de l’enseignement utilisent librement cette application et participent à son évolution.

## Source Code

* https://github.com/mviewer/mviewer

## Requirements

Kubernetes: `>=1.14.0-0`

## Dependencies

None

## Installing the Chart

To install the chart with the release name `mviewer`

```console
helm repo add charts-gs https://camptocamp.github.io/charts-gs/
helm repo update
helm install mviewer charts-gs/mviewer
```

## Uninstalling the Chart

To uninstall the `mviewer` deployment

```console
helm uninstall mviewer
```

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 mviewer \
--set replicaCount="2" \
charts-gs/mviewer
```

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

```console
helm install mviewer charts-gs/mviewer -f values.yaml
```

## mviewer configuration

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

Please refer to the docker documentation for more explanations about this custom configuration: https://mviewerdoc.readthedocs.io/fr/latest/doc_tech/deploy.html#avec-docker

## 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](#mviewer-configuration) |
| ingress | object | See values.yaml | Configurations for configuring ingress |

## Changelog

### Version 0.1.0

Initial version
25 changes: 25 additions & 0 deletions mviewer/templates/_bootstrap-mviewer-configuration.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- define "mviewer.bootstrap_mviewer_configuration" -}}
- name: bootstrap-mviewer-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 }} /usr/share/nginx/html/apps ;
{{- if .Values.configuration.git.ssh_secret }}
env:
- name: GIT_SSH_COMMAND
value: ssh -o "IdentitiesOnly=yes" -o "StrictHostKeyChecking no"
{{- end }}
volumeMounts:
- mountPath: /usr/share/nginx/html/apps
name: mviewer-configuration
{{- if .Values.configuration.git.ssh_secret }}
- mountPath: /ssh-secret
name: ssh-secret
{{- end }}
{{- end -}}
62 changes: 62 additions & 0 deletions mviewer/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-mviewer.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-mviewer.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-mviewer.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "helm-mviewer.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "helm-mviewer.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
83 changes: 83 additions & 0 deletions mviewer/templates/mviewer-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "helm-mviewer.fullname" . }}-mviewer-deployment
labels:
{{- include "helm-mviewer.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "helm-mviewer.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "helm-mviewer.selectorLabels" . | nindent 8 }}
application/name: {{ include "helm-mviewer.fullname" . }}-mviewer-deployment
spec:
{{- if .Values.configuration.git.url }}
initContainers:
{{- include "mviewer.bootstrap_mviewer_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 }}
{{- with .Values.extra_environment }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: mviewer-configuration
mountPath: /etc/mviewer
volumes:
- name: mviewer-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 mviewer/templates/mviewer-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "helm-mviewer.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-mviewer.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 }}-mviewer-svc
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions mviewer/templates/mviewer-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "helm-mviewer.fullname" . }}-mviewer-svc
labels:
{{- include "helm-mviewer.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
application/name: {{ include "helm-mviewer.fullname" . }}-mviewer-deployment
Loading

0 comments on commit d17ecf5

Please sign in to comment.