From 815d3a4df7ad89a5ba126ae58b9892302621a5b5 Mon Sep 17 00:00:00 2001 From: martinibach Date: Fri, 29 Sep 2023 15:27:53 +0200 Subject: [PATCH 1/5] add ingress, nginx and helper --- charts/tooljet/templates/_helpers.tpl | 42 +++++++ charts/tooljet/templates/configmap-nginx.yaml | 105 ++++++++++++++++++ charts/tooljet/templates/ingress.yml | 55 +++++++++ charts/tooljet/values.yaml | 10 +- 4 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 charts/tooljet/templates/_helpers.tpl create mode 100644 charts/tooljet/templates/configmap-nginx.yaml create mode 100644 charts/tooljet/templates/ingress.yml diff --git a/charts/tooljet/templates/_helpers.tpl b/charts/tooljet/templates/_helpers.tpl new file mode 100644 index 0000000..c0f8e1e --- /dev/null +++ b/charts/tooljet/templates/_helpers.tpl @@ -0,0 +1,42 @@ +{{/* +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 "tooljet.fullname" -}} +{{- $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 }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "tooljet.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "tooljet.labels" -}} +helm.sh/chart: {{ include "tooljet.chart" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Return the appropriate apiVersion for ingress. +*/}} +{{- define "tooljet.ingress.apiVersion" -}} +{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} +{{- print "extensions/v1" -}} +{{- else -}} +{{- print "networking.k8s.io/v1" -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/tooljet/templates/configmap-nginx.yaml b/charts/tooljet/templates/configmap-nginx.yaml new file mode 100644 index 0000000..036840e --- /dev/null +++ b/charts/tooljet/templates/configmap-nginx.yaml @@ -0,0 +1,105 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "tooljet.fullname" . }}-nginx-config-template + labels: + app: {{ template "tooljet.fullname" . }} + chart: {{ template "tooljet.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +data: + nginx.conf.template: " + events + { + worker_connections 1024; + } + http + { + server + { + + location / + { + root /var/www; + try_files $uri $uri/ /index.html @proxy; + error_page 405 @proxy; + } + + location /api/ + { + try_files /_bypass_to_proxy @proxy; + } + + location /ws + { + proxy_pass http://{{ template "tooljet.fullname" . }}:3000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $host; + } + + location /yjs + { + proxy_pass http://{{ template "tooljet.fullname" . }}:3000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $host; + } + + location @proxy { + proxy_pass http://{{ template "tooljet.fullname" . }}:3000; + proxy_redirect off; + proxy_set_header Host $host; + } + } + + server + { + listen 80; + + location / + { + root /var/www; + try_files $uri $uri/ /index.html @proxy; + error_page 405 @proxy; + } + + location /api/ + { + try_files /_bypass_to_proxy @proxy; + } + + location /ws + { + proxy_pass http://{{ template "tooljet.fullname" . }}:3000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $host; + } + + location /yjs + { + proxy_pass http://{{ template "tooljet.fullname" . }}:3000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $host; + } + + location @proxy { + proxy_pass http://{{ template "tooljet.fullname" . }}:3000; + proxy_redirect off; + proxy_set_header Host $host; + } + } + + server + { + listen 127.0.0.1:8999; + client_body_buffer_size 128k; + client_max_body_size 128k; + } +}" \ No newline at end of file diff --git a/charts/tooljet/templates/ingress.yml b/charts/tooljet/templates/ingress.yml new file mode 100644 index 0000000..27e4462 --- /dev/null +++ b/charts/tooljet/templates/ingress.yml @@ -0,0 +1,55 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "tooljet.fullname" . -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "tooljet.fullname" . }} + labels: + {{- include "tooljet.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.ingressClassName }} + ingressClassName: {{ .Values.ingress.ingressClassName }} + {{- end }} + tls: + - hosts: + - {{ .Values.ingress.hostname }} +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- if .Values.ingress.hostname }} + - host: {{ .Values.ingress.hostname }} + http: + paths: + - path: / + pathType: 'Prefix' + backend: + service: + name: {{ template "tooljet.fullname" . }} + port: + number: 3000 + {{- end }} + {{- range .Values.ingress.hosts }} + - host: {{ . | quote }} + http: + paths: + - path: / + pathType: 'Prefix' + backend: + service: + name: {{ $fullName }} + port: + number: 3000 + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/tooljet/values.yaml b/charts/tooljet/values.yaml index 073ebb8..75eda32 100644 --- a/charts/tooljet/values.yaml +++ b/charts/tooljet/values.yaml @@ -2,7 +2,7 @@ apps: tooljet: service: type: ClusterIP - host: "http://localhost" + host: "http://tooljet.localhost" deployment: image: repository: tooljet/tooljet-ce @@ -27,6 +27,14 @@ apps: lockbox_key: "0123456789ABCDEF" secret_key_base: "0123456789ABCDEF" +ingress: + enabled: true + hostname: tooljet.localhost + ingressClassName: 'nginx' + kubernetes.io/ingress.class: "nginx" + annotations: + {} + tls: [] # https://artifacthub.io/packages/helm/bitnami/postgresql#global-parameters postgresql: enabled: true From b73f8637f01373640304771160ca06710946f8ac Mon Sep 17 00:00:00 2001 From: martinibach Date: Fri, 29 Sep 2023 15:28:59 +0200 Subject: [PATCH 2/5] remove whitespaces end of file --- charts/tooljet/values.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/charts/tooljet/values.yaml b/charts/tooljet/values.yaml index 75eda32..23d4650 100644 --- a/charts/tooljet/values.yaml +++ b/charts/tooljet/values.yaml @@ -107,5 +107,3 @@ service: type: ClusterIP port: 3000 annotations: {} - - From e87e342c10df4805cc10ed782c2360dd0b9650e3 Mon Sep 17 00:00:00 2001 From: martinibach Date: Tue, 3 Oct 2023 20:49:49 +0200 Subject: [PATCH 3/5] fix values.yaml formatting --- charts/tooljet/values.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/tooljet/values.yaml b/charts/tooljet/values.yaml index 23d4650..d082433 100644 --- a/charts/tooljet/values.yaml +++ b/charts/tooljet/values.yaml @@ -36,6 +36,7 @@ ingress: {} tls: [] # https://artifacthub.io/packages/helm/bitnami/postgresql#global-parameters + postgresql: enabled: true postgresqlExtendedConf: From a6a2bf9084c0c6613fa5546e41e1f7346cef65b6 Mon Sep 17 00:00:00 2001 From: martinibach Date: Tue, 3 Oct 2023 20:56:15 +0200 Subject: [PATCH 4/5] increase chart version number --- charts/tooljet/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tooljet/Chart.yaml b/charts/tooljet/Chart.yaml index 0a0c501..6770547 100644 --- a/charts/tooljet/Chart.yaml +++ b/charts/tooljet/Chart.yaml @@ -16,5 +16,5 @@ dependencies: version: "16.13.2" repository: "https://charts.bitnami.com/bitnami" -version: 2.6.0 +version: 2.6.1 appVersion: "v1.21.5" From bbd86e520e6322bfac92ab631c0cfe3fe49ab435 Mon Sep 17 00:00:00 2001 From: martinibach Date: Tue, 3 Oct 2023 21:24:13 +0200 Subject: [PATCH 5/5] adapt service name to be based on helper --- charts/tooljet/templates/service.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/tooljet/templates/service.yaml b/charts/tooljet/templates/service.yaml index 182fd81..e86176e 100644 --- a/charts/tooljet/templates/service.yaml +++ b/charts/tooljet/templates/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: tooljet + name: {{ template "tooljet.fullname" . }} spec: type: {{ .Values.apps.tooljet.service.type }} ports: