From 3364de494dcb6bc9e51aa7e64b5b29e1a90b9cc2 Mon Sep 17 00:00:00 2001 From: michalby24 Date: Sun, 7 Jun 2026 15:03:05 +0300 Subject: [PATCH 1/4] feat: enhance ingress configuration with dynamic service name and port --- helm/templates/ingress.yaml | 95 +++++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 26 deletions(-) diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml index 3355e5c..b9d1fad 100644 --- a/helm/templates/ingress.yaml +++ b/helm/templates/ingress.yaml @@ -1,34 +1,77 @@ -{{- $releaseName := .Release.Name -}} -{{- $chartName := include "ts-server-boilerplate.name" . -}} {{- if and (.Values.enabled) (.Values.ingress.enabled) -}} +{{- $fullName := include "ts-server-boilerplate.fullname" . -}} +{{- $serviceName := $fullName -}} +{{- $servicePort := .Values.env.port -}} +{{- $ingressPath := default "/" .Values.ingress.path -}} +{{- $ingressPathType := default "Prefix" .Values.ingress.pathType -}} +{{- $extraPaths := .Values.ingress.extraPaths -}} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: {{ include "ts-server-boilerplate.fullname" . }} + name: {{ $fullName }}-ingress + namespace: {{ .Release.Namespace }} + labels: + {{- include "ts-server-boilerplate.labels" . | nindent 4 }} + {{- with .Values.ingress.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.ingress.annotations }} annotations: - kubernetes.io/ingress.class: "nginx" - nginx.org/mergeable-ingress-type: "minion" - nginx.org/rewrites: 'serviceName={{ include "ts-server-boilerplate.fullname" . }} rewrite=/' - nginx.org/location-snippets: | - if ($request_method = OPTIONS) { - return 204; - } - {{- if .Values.ingress.cors.enabled }} - add_header 'Access-Control-Allow-Origin' '{{- .Values.ingress.cors.origin -}}'; - add_header 'Access-Control-Max-Age' 3600; - add_header 'Access-Control-Expose-Headers' 'Content-Length'; - add_header 'Access-Control-Allow-Headers' '*'; + {{- range $key, $value := . }} + {{ $key }}: {{ tpl ($value | toString) $ | quote }} {{- end }} + {{- end }} spec: + {{- if .Values.ingress.className }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- with .Values.ingress.tls }} + tls: + {{- tpl (toYaml .) $ | nindent 4 }} + {{- end }} rules: - - http: - paths: - - path: {{ .Values.ingress.path }} - pathType: Prefix - backend: - service: - name: {{ include "ts-server-boilerplate.fullname" . }} - port: - number: {{ .Values.env.port }} - host: {{ .Values.ingress.host | quote }} -{{- end -}} + {{- if .Values.ingress.hosts }} + {{- range .Values.ingress.hosts }} + - host: {{ tpl . $ | quote }} + http: + paths: + {{- with $extraPaths }} + {{- tpl (toYaml .) $ | nindent 10 }} + {{- end }} + - path: {{ $ingressPath }} + pathType: {{ $ingressPathType }} + backend: + service: + name: {{ $serviceName }} + port: + number: {{ $servicePort }} + {{- end }} + {{- else if .Values.ingress.host }} + - host: {{ tpl .Values.ingress.host $ | quote }} + http: + paths: + {{- with $extraPaths }} + {{- tpl (toYaml .) $ | nindent 10 }} + {{- end }} + - path: {{ $ingressPath }} + pathType: {{ $ingressPathType }} + backend: + service: + name: {{ $serviceName }} + port: + number: {{ $servicePort }} + {{- else }} + - http: + paths: + {{- with $extraPaths }} + {{- tpl (toYaml .) $ | nindent 10 }} + {{- end }} + - path: {{ $ingressPath }} + pathType: {{ $ingressPathType }} + backend: + service: + name: {{ $serviceName }} + port: + number: {{ $servicePort }} + {{- end -}} +{{- end }} From 099e2d5a2f3a19815047c0e72db0aceeef568bd7 Mon Sep 17 00:00:00 2001 From: michalby24 Date: Sun, 7 Jun 2026 17:53:49 +0300 Subject: [PATCH 2/4] feat: update ingress configuration with additional options and default values --- helm/templates/ingress.yaml | 2 +- helm/values.yaml | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml index b9d1fad..7a9c7ce 100644 --- a/helm/templates/ingress.yaml +++ b/helm/templates/ingress.yaml @@ -2,7 +2,7 @@ {{- $fullName := include "ts-server-boilerplate.fullname" . -}} {{- $serviceName := $fullName -}} {{- $servicePort := .Values.env.port -}} -{{- $ingressPath := default "/" .Values.ingress.path -}} +{{- $ingressPath := .Values.ingress.path -}} {{- $ingressPathType := default "Prefix" .Values.ingress.pathType -}} {{- $extraPaths := .Values.ingress.extraPaths -}} apiVersion: networking.k8s.io/v1 diff --git a/helm/values.yaml b/helm/values.yaml index 11b81f6..e7d34d9 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -113,8 +113,18 @@ route: ingress: enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + labels: {} path: / + pathType: Prefix + extraPaths: [] + hosts: [] + # - "chart-example.local" host: 'localhost' - cors: - enabled: true - origin: '*' + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local From d7696e7f2c23edbc8b587deee988637881960143 Mon Sep 17 00:00:00 2001 From: michalby24 Date: Sun, 28 Jun 2026 13:18:09 +0300 Subject: [PATCH 3/4] feat: create init helmfile --- helm/{ => chart}/.helmignore | 0 helm/{ => chart}/Chart.lock | 0 helm/{ => chart}/Chart.yaml | 0 helm/{ => chart}/templates/_helpers.tpl | 0 helm/{ => chart}/templates/configmap.yaml | 0 helm/{ => chart}/templates/deployment.yaml | 0 helm/{ => chart}/templates/ingress.yaml | 0 helm/{ => chart}/templates/route.yaml | 0 helm/{ => chart}/templates/service.yaml | 0 helm/{ => chart}/values.yaml | 0 helm/environments/base.yaml.gotmpl | 28 ++++++++++++++++++++++ helm/environments/dev.yaml | 0 helm/environments/prod.yaml | 0 helm/environments/stage.yaml | 0 helm/helmfile.yaml | 17 +++++++++++++ 15 files changed, 45 insertions(+) rename helm/{ => chart}/.helmignore (100%) rename helm/{ => chart}/Chart.lock (100%) rename helm/{ => chart}/Chart.yaml (100%) rename helm/{ => chart}/templates/_helpers.tpl (100%) rename helm/{ => chart}/templates/configmap.yaml (100%) rename helm/{ => chart}/templates/deployment.yaml (100%) rename helm/{ => chart}/templates/ingress.yaml (100%) rename helm/{ => chart}/templates/route.yaml (100%) rename helm/{ => chart}/templates/service.yaml (100%) rename helm/{ => chart}/values.yaml (100%) create mode 100644 helm/environments/base.yaml.gotmpl create mode 100644 helm/environments/dev.yaml create mode 100644 helm/environments/prod.yaml create mode 100644 helm/environments/stage.yaml create mode 100644 helm/helmfile.yaml diff --git a/helm/.helmignore b/helm/chart/.helmignore similarity index 100% rename from helm/.helmignore rename to helm/chart/.helmignore diff --git a/helm/Chart.lock b/helm/chart/Chart.lock similarity index 100% rename from helm/Chart.lock rename to helm/chart/Chart.lock diff --git a/helm/Chart.yaml b/helm/chart/Chart.yaml similarity index 100% rename from helm/Chart.yaml rename to helm/chart/Chart.yaml diff --git a/helm/templates/_helpers.tpl b/helm/chart/templates/_helpers.tpl similarity index 100% rename from helm/templates/_helpers.tpl rename to helm/chart/templates/_helpers.tpl diff --git a/helm/templates/configmap.yaml b/helm/chart/templates/configmap.yaml similarity index 100% rename from helm/templates/configmap.yaml rename to helm/chart/templates/configmap.yaml diff --git a/helm/templates/deployment.yaml b/helm/chart/templates/deployment.yaml similarity index 100% rename from helm/templates/deployment.yaml rename to helm/chart/templates/deployment.yaml diff --git a/helm/templates/ingress.yaml b/helm/chart/templates/ingress.yaml similarity index 100% rename from helm/templates/ingress.yaml rename to helm/chart/templates/ingress.yaml diff --git a/helm/templates/route.yaml b/helm/chart/templates/route.yaml similarity index 100% rename from helm/templates/route.yaml rename to helm/chart/templates/route.yaml diff --git a/helm/templates/service.yaml b/helm/chart/templates/service.yaml similarity index 100% rename from helm/templates/service.yaml rename to helm/chart/templates/service.yaml diff --git a/helm/values.yaml b/helm/chart/values.yaml similarity index 100% rename from helm/values.yaml rename to helm/chart/values.yaml diff --git a/helm/environments/base.yaml.gotmpl b/helm/environments/base.yaml.gotmpl new file mode 100644 index 0000000..04b8196 --- /dev/null +++ b/helm/environments/base.yaml.gotmpl @@ -0,0 +1,28 @@ +cloudProvider: + flavor: openshift + +# Dynamically pull the component name from the release labels defined in helmfile.yaml +mclabels: + component: {{ index .Release.Labels "component" | default "backend" }} + +env: + # Simple, readable conditions for environment-specific logging + {{- if eq .Environment.Name "dev" }} + logLevel: debug + logPrettyPrintEnabled: true + {{- else if eq .Environment.Name "prod" }} + logLevel: warn + logPrettyPrintEnabled: false + {{- else }} + logLevel: info + logPrettyPrintEnabled: false + {{- end }} + +route: + enabled: true + # Generates my-app-dev.apps... for dev/stage, and my-app.apps... for prod + {{- if eq .Environment.Name "prod" }} + host: {{ .Release.Name }}.apps.ocp-cluster.internal + {{- else }} + host: {{ .Release.Name }}-{{ .Environment.Name }}.apps.ocp-cluster.internal + {{- end }} diff --git a/helm/environments/dev.yaml b/helm/environments/dev.yaml new file mode 100644 index 0000000..e69de29 diff --git a/helm/environments/prod.yaml b/helm/environments/prod.yaml new file mode 100644 index 0000000..e69de29 diff --git a/helm/environments/stage.yaml b/helm/environments/stage.yaml new file mode 100644 index 0000000..e69de29 diff --git a/helm/helmfile.yaml b/helm/helmfile.yaml new file mode 100644 index 0000000..68299e4 --- /dev/null +++ b/helm/helmfile.yaml @@ -0,0 +1,17 @@ +# helmfile.yaml +environments: + dev: + stage: + prod: + +--- + +releases: + - name: ts-server-boilerplate + namespace: my-app-{{ .Environment.Name }} + chart: ./chart + labels: + component: backend + values: + - ./environments/base.yaml.gotmpl + - ./environments/{{ .Environment.Name }}.yaml From 07bcf2efd3c62e9cf9aac68a78115e8e1caffb66 Mon Sep 17 00:00:00 2001 From: michalby24 Date: Sun, 28 Jun 2026 17:14:39 +0300 Subject: [PATCH 4/4] feat: create init helmfile --- helm/chart/values.yaml | 25 +------------------------ helm/environments/base.yaml.gotmpl | 27 +++++++++++++++------------ helm/environments/dev.yaml | 9 +++++++++ helm/environments/prod.yaml | 9 +++++++++ helm/environments/stage.yaml | 9 +++++++++ 5 files changed, 43 insertions(+), 36 deletions(-) diff --git a/helm/chart/values.yaml b/helm/chart/values.yaml index e7d34d9..3afce19 100644 --- a/helm/chart/values.yaml +++ b/helm/chart/values.yaml @@ -3,13 +3,6 @@ global: tracing: {} metrics: {} -mclabels: - component: backend - partOf: boilerplates - owner: common - prometheus: - enabled: true - enabled: true replicaCount: 1 revisionHistoryLimit: 5 # Amount of revisions we keep @@ -54,12 +47,6 @@ args: [] sidecars: [] -cloudProvider: - dockerRegistryUrl: '' - imagePullSecretName: '' - flavor: openshift - -caSecretName: '' caPath: '/usr/local/share/ca-certificates' caKey: 'ca.crt' @@ -73,8 +60,7 @@ env: port: 8080 targetPort: 8080 protocol: TCP - logLevel: info - logPrettyPrintEnabled: false + responseCompressionEnabled: true requestPayloadLimit: 1mb tracing: @@ -84,15 +70,6 @@ env: enabled: false url: http://localhost:55681/v1/metrics -resources: - enabled: true - value: - limits: - cpu: 100m - memory: 128Mi - requests: - cpu: 100m - memory: 128Mi route: enabled: true diff --git a/helm/environments/base.yaml.gotmpl b/helm/environments/base.yaml.gotmpl index 04b8196..7289e9b 100644 --- a/helm/environments/base.yaml.gotmpl +++ b/helm/environments/base.yaml.gotmpl @@ -1,28 +1,31 @@ cloudProvider: + dockerRegistryUrl: '' + imagePullSecretName: '' flavor: openshift # Dynamically pull the component name from the release labels defined in helmfile.yaml mclabels: - component: {{ index .Release.Labels "component" | default "backend" }} + component: backend + partOf: boilerplates + owner: common + prometheus: + enabled: true + +caSecretName: '' env: - # Simple, readable conditions for environment-specific logging - {{- if eq .Environment.Name "dev" }} - logLevel: debug - logPrettyPrintEnabled: true - {{- else if eq .Environment.Name "prod" }} - logLevel: warn - logPrettyPrintEnabled: false - {{- else }} + {{- if eq .Environment.Name "prod" }} logLevel: info logPrettyPrintEnabled: false + {{- else }} + logLevel: debug + logPrettyPrintEnabled: true {{- end }} route: enabled: true - # Generates my-app-dev.apps... for dev/stage, and my-app.apps... for prod {{- if eq .Environment.Name "prod" }} - host: {{ .Release.Name }}.apps.ocp-cluster.internal + host: {{ .Release.Name }}.mapcolonies.net {{- else }} - host: {{ .Release.Name }}-{{ .Environment.Name }}.apps.ocp-cluster.internal + host: {{ .Release.Name }}-{{ .Environment.Name }}.mapcolonies.net {{- end }} diff --git a/helm/environments/dev.yaml b/helm/environments/dev.yaml index e69de29..7c136d0 100644 --- a/helm/environments/dev.yaml +++ b/helm/environments/dev.yaml @@ -0,0 +1,9 @@ +resources: + enabled: true + value: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi diff --git a/helm/environments/prod.yaml b/helm/environments/prod.yaml index e69de29..7c136d0 100644 --- a/helm/environments/prod.yaml +++ b/helm/environments/prod.yaml @@ -0,0 +1,9 @@ +resources: + enabled: true + value: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi diff --git a/helm/environments/stage.yaml b/helm/environments/stage.yaml index e69de29..7c136d0 100644 --- a/helm/environments/stage.yaml +++ b/helm/environments/stage.yaml @@ -0,0 +1,9 @@ +resources: + enabled: true + value: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi