From ab8fa9c392a0c87e6a8dc1046d6fcf47b1e1dc4d Mon Sep 17 00:00:00 2001 From: Emilien Devos Date: Thu, 26 Oct 2023 17:06:50 +0200 Subject: [PATCH] version 0.2.0 for support mviewer and mviewerstudio --- mviewer/Chart.yaml | 4 +- mviewer/README.md | 3 + .../{mviewer-ingress.yaml => ingress.yaml} | 37 +++- mviewer/templates/mviewer-deployment.yaml | 46 +++-- mviewer/templates/mviewer-svc.yaml | 6 +- .../templates/mviewerstudio-deployment.yaml | 77 +++++++ mviewer/templates/mviewerstudio-svc.yaml | 17 ++ mviewer/values.yaml | 192 ++++++++++++------ 8 files changed, 294 insertions(+), 88 deletions(-) rename mviewer/templates/{mviewer-ingress.yaml => ingress.yaml} (55%) create mode 100644 mviewer/templates/mviewerstudio-deployment.yaml create mode 100644 mviewer/templates/mviewerstudio-svc.yaml diff --git a/mviewer/Chart.yaml b/mviewer/Chart.yaml index 98a2c02..b171830 100644 --- a/mviewer/Chart.yaml +++ b/mviewer/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 name: mviewer -description: A Helm chart to deploy the mviewer application +description: A Helm chart to deploy the mviewer stack type: application -version: 0.1.0 +version: 0.2.0 appVersion: "3.9" maintainers: - name: geOrchestra diff --git a/mviewer/README.md b/mviewer/README.md index 04aa343..f9cb01c 100644 --- a/mviewer/README.md +++ b/mviewer/README.md @@ -1,5 +1,7 @@ # Mviewer +TODO: UPDATE README + 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. @@ -9,6 +11,7 @@ De nombreuses collectivités mais également des entreprises, le secteur de la r ## Source Code * https://github.com/mviewer/mviewer +* https://github.com/mviewer/mviewerstudio ## Requirements diff --git a/mviewer/templates/mviewer-ingress.yaml b/mviewer/templates/ingress.yaml similarity index 55% rename from mviewer/templates/mviewer-ingress.yaml rename to mviewer/templates/ingress.yaml index b8a2257..6e7c61f 100644 --- a/mviewer/templates/mviewer-ingress.yaml +++ b/mviewer/templates/ingress.yaml @@ -1,6 +1,5 @@ {{- 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 -}} @@ -33,25 +32,45 @@ spec: {{- end }} {{- end }} rules: - {{- range .Values.ingress.hosts }} + {{- range .Values.ingress.hosts | default (list "") }} + {{- if $.Values.ingress.hosts }} - host: {{ .host | quote }} + {{- else }} + - host: {{ $.Values.fqdn | quote }} + {{- end }} http: paths: - {{- range .paths }} - - path: {{ . }} + {{- if $.Values.mviewer.enabled }} + - path: /mviewer + {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + pathType: Prefix + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ include "helm-mviewer.fullname" $ }}-mviewer-svc + port: + number: 80 + {{- else }} + serviceName: {{ include "helm-mviewer.fullname" $ }}-mviewer-svc + servicePort: 80 + {{- end }} + {{- end }} + {{- if $.Values.mviewerstudio.enabled }} + - path: /mviewer {{- 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 + name: {{ include "helm-mviewer.fullname" $ }}-mviewerstudio-svc port: - number: {{ $svcPort }} + number: 8000 {{- else }} - serviceName: {{ $fullName }} - servicePort: {{ $svcPort }} + serviceName: {{ include "helm-mviewer.fullname" $ }}-mviewerstudio-svc + servicePort: 8000 {{- end }} {{- end }} {{- end }} - {{- end }} \ No newline at end of file + {{- end }} diff --git a/mviewer/templates/mviewer-deployment.yaml b/mviewer/templates/mviewer-deployment.yaml index 157da32..fb564b6 100644 --- a/mviewer/templates/mviewer-deployment.yaml +++ b/mviewer/templates/mviewer-deployment.yaml @@ -1,3 +1,4 @@ +{{- if .Values.mviewer.enabled -}} apiVersion: apps/v1 kind: Deployment metadata: @@ -5,13 +6,13 @@ metadata: labels: {{- include "helm-mviewer.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount }} + replicas: {{ .Values.mviewer.replicaCount }} selector: matchLabels: {{- include "helm-mviewer.selectorLabels" . | nindent 6 }} template: metadata: - {{- with .Values.podAnnotations }} + {{- with .Values.mviewer.podAnnotations }} annotations: {{- toYaml . | nindent 8 }} {{- end }} @@ -19,22 +20,22 @@ spec: {{- include "helm-mviewer.selectorLabels" . | nindent 8 }} application/name: {{ include "helm-mviewer.fullname" . }}-mviewer-deployment spec: - {{- if .Values.configuration.git.url }} + {{- if .Values.mviewer.configuration.git.url }} initContainers: {{- include "mviewer.bootstrap_mviewer_configuration" $ | nindent 6 }} {{- end }} - {{- with .Values.imagePullSecrets }} + {{- with .Values.mviewer.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- toYaml .Values.mviewer.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 }} + {{- toYaml .Values.mviewer.securityContext | nindent 12 }} + image: "{{ .Values.mviewer.image.repository }}:{{ .Values.mviewer.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.mviewer.image.pullPolicy }} ports: - name: http containerPort: 80 @@ -47,37 +48,46 @@ spec: httpGet: path: / port: http - {{- with .Values.lifecycle }} + {{- with .Values.mviewer.lifecycle }} lifecycle: {{- toYaml . | nindent 12 }} {{- end }} resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.extra_environment }} + {{- toYaml .Values.mviewer.resources | nindent 12 }} + {{- with .Values.mviewer.extra_environment }} env: {{- toYaml . | nindent 12 }} {{- end }} + {{- if .Values.mviewer.configuration.git.url }} volumeMounts: - name: mviewer-configuration - mountPath: /etc/mviewer + mountPath: /usr/share/nginx/html/apps + {{- else if .Values.mviewer.extraVolumesMounts }} + volumeMounts: + {{- .Values.mviewer.extraVolumesMounts | toYaml | nindent 6 }} + {{- end }} + {{- if .Values.mviewer.configuration.git.url }} volumes: - name: mviewer-configuration emptyDir: {} - {{- if .Values.configuration.git.ssh_secret }} - name: ssh-secret secret: - secretName: {{ .Values.configuration.git.ssh_secret }} + secretName: {{ .Values.mviewer.configuration.git.ssh_secret }} defaultMode: 0400 - {{- end }} - {{- with .Values.nodeSelector }} + {{- else if .Values.mviewer.extraVolumes }} + volumes: + {{- .Values.mviewer.mviewer.extraVolumes | toYaml | nindent 6 }} + {{- end }} + {{- with .Values.mviewer.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.affinity }} + {{- with .Values.mviewer.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.tolerations }} + {{- with .Values.mviewer.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} +{{- end }} diff --git a/mviewer/templates/mviewer-svc.yaml b/mviewer/templates/mviewer-svc.yaml index 485b11b..e2b24a9 100644 --- a/mviewer/templates/mviewer-svc.yaml +++ b/mviewer/templates/mviewer-svc.yaml @@ -1,3 +1,4 @@ +{{- if .Values.mviewer.enabled -}} apiVersion: v1 kind: Service metadata: @@ -5,11 +6,12 @@ metadata: labels: {{- include "helm-mviewer.labels" . | nindent 4 }} spec: - type: {{ .Values.service.type }} + type: {{ .Values.mviewer.service.type }} ports: - - port: {{ .Values.service.port }} + - port: {{ .Values.mviewer.service.port }} targetPort: http protocol: TCP name: http selector: application/name: {{ include "helm-mviewer.fullname" . }}-mviewer-deployment +{{- end }} diff --git a/mviewer/templates/mviewerstudio-deployment.yaml b/mviewer/templates/mviewerstudio-deployment.yaml new file mode 100644 index 0000000..3b2b88c --- /dev/null +++ b/mviewer/templates/mviewerstudio-deployment.yaml @@ -0,0 +1,77 @@ +{{- if .Values.mviewerstudio.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "helm-mviewer.fullname" . }}-mviewerstudio-deployment + labels: + {{- include "helm-mviewer.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.mviewerstudio.replicaCount }} + selector: + matchLabels: + {{- include "helm-mviewer.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.mviewerstudio.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "helm-mviewer.selectorLabels" . | nindent 8 }} + application/name: {{ include "helm-mviewer.fullname" . }}-mviewerstudio-deployment + spec: + {{- with .Values.mviewerstudio.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.mviewerstudio.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.mviewerstudio.securityContext | nindent 12 }} + image: "{{ .Values.mviewerstudio.image.repository }}:{{ .Values.mviewerstudio.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.mviewerstudio.image.pullPolicy }} + ports: + - name: http + containerPort: 8000 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + {{- with .Values.mviewerstudio.lifecycle }} + lifecycle: + {{- toYaml . | nindent 12 }} + {{- end }} + resources: + {{- toYaml .Values.mviewerstudio.resources | nindent 12 }} + {{- with .Values.mviewerstudio.extra_environment }} + env: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- if .Values.mviewerstudio.extraVolumesMounts }} + volumeMounts: + {{- .Values.mviewerstudio.extraVolumesMounts | toYaml | nindent 6 }} + {{- end }} + {{- if .Values.mviewerstudio.extraVolumes }} + volumes: + {{- .Values.mviewerstudio.extraVolumes | toYaml | nindent 6 }} + {{- end }} + {{- with .Values.mviewerstudio.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.mviewerstudio.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.mviewerstudio.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} diff --git a/mviewer/templates/mviewerstudio-svc.yaml b/mviewer/templates/mviewerstudio-svc.yaml new file mode 100644 index 0000000..8d420de --- /dev/null +++ b/mviewer/templates/mviewerstudio-svc.yaml @@ -0,0 +1,17 @@ +{{- if .Values.mviewerstudio.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "helm-mviewer.fullname" . }}-mviewerstudio-svc + labels: + {{- include "helm-mviewer.labels" . | nindent 4 }} +spec: + type: {{ .Values.mviewerstudio.service.type }} + ports: + - port: {{ .Values.mviewerstudio.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + application/name: {{ include "helm-mviewer.fullname" . }}-mviewerstudio-deployment +{{- end }} diff --git a/mviewer/values.yaml b/mviewer/values.yaml index 6bb5c30..697a605 100644 --- a/mviewer/values.yaml +++ b/mviewer/values.yaml @@ -1,73 +1,151 @@ -replicaCount: 1 +mviewer: + enabled: true + replicaCount: 1 -image: - repository: mviewer/mviewer - tag: latest - pullPolicy: Always + image: + repository: mviewer/mviewer + tag: latest + pullPolicy: Always -configuration: - git: - url: {} - ref: {} - ssh_secret: {} + configuration: + git: + url: {} + ref: {} + ssh_secret: {} -ingress: - enabled: true - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - hosts: - - host: mymviewer.org - paths: - - "/mymviewer" - tls: [] - # - secretName: chart-example-tls - # hosts: - # - mymviewer.org - - # define a custom incressClassName, like "traefik" or "nginx" - className: "" + extra_environment: [] + # - name: MY_ENV + # value: myvalue + + podAnnotations: {} + + podSecurityContext: {} + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + service: + type: ClusterIP + port: 80 + annotations: {} + + #lifecycle: + # postStart: + # exec: + # command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"] + # preStop: + # exec: + # command: ["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"] + + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + + nodeSelector: {} + + tolerations: [] -extra_environment: [] + affinity: {} + + extraVolumes: [] + # - mountPath: /usr/share/nginx/html + # name: volume-pvc + + extraVolumeMounts: [] + # - name: volume-pvc + # persistentVolumeClaim: + # claimName: persitent-volume-claim + +mviewerstudio: + enabled: false + replicaCount: 1 + + image: + repository: mviewer/mviewerstudio + tag: python-latest + pullPolicy: Always + + configuration: + git: + url: {} + ref: {} + ssh_secret: {} + + extra_environment: [] # - name: MY_ENV # value: myvalue -podAnnotations: {} + podAnnotations: {} -podSecurityContext: {} + podSecurityContext: {} -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 -service: - type: ClusterIP - port: 80 - annotations: {} + service: + type: ClusterIP + port: 80 + annotations: {} + + #lifecycle: + # postStart: + # exec: + # command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"] + # preStop: + # exec: + # command: ["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"] + + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + + nodeSelector: {} -#lifecycle: -# postStart: -# exec: -# command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"] -# preStop: -# exec: -# command: ["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"] + tolerations: [] -resources: - limits: - cpu: 100m - memory: 128Mi - requests: - cpu: 100m - memory: 128Mi + affinity: {} + extraVolumes: [] + # - mountPath: /usr/share/nginx/html + # name: volume-pvc -nodeSelector: {} + extraVolumeMounts: [] + # - name: volume-pvc + # persistentVolumeClaim: + # claimName: persitent-volume-claim -tolerations: [] +ingress: + enabled: true + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: mviewer.mydomain.org + tls: [] + # You can import TLS secrets using + # kubectl create secret tls testsecret --key key.pem --cert cert.pem + # Then specify the TLS secret name below. + # - secretName: testsecret + # hosts: + # - mviewer.mydomain.org + # define a custom incressClassName, like "traefik" or "nginx" + className: "" -affinity: {} \ No newline at end of file