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/chart/templates/ingress.yaml b/helm/chart/templates/ingress.yaml new file mode 100644 index 00000000..7a9c7ceb --- /dev/null +++ b/helm/chart/templates/ingress.yaml @@ -0,0 +1,77 @@ +{{- if and (.Values.enabled) (.Values.ingress.enabled) -}} +{{- $fullName := include "ts-server-boilerplate.fullname" . -}} +{{- $serviceName := $fullName -}} +{{- $servicePort := .Values.env.port -}} +{{- $ingressPath := .Values.ingress.path -}} +{{- $ingressPathType := default "Prefix" .Values.ingress.pathType -}} +{{- $extraPaths := .Values.ingress.extraPaths -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + 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: + {{- 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: + {{- 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 }} 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 79% rename from helm/values.yaml rename to helm/chart/values.yaml index 11b81f68..3afce19c 100644 --- a/helm/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 @@ -113,8 +90,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 diff --git a/helm/environments/base.yaml.gotmpl b/helm/environments/base.yaml.gotmpl new file mode 100644 index 00000000..7289e9b0 --- /dev/null +++ b/helm/environments/base.yaml.gotmpl @@ -0,0 +1,31 @@ +cloudProvider: + dockerRegistryUrl: '' + imagePullSecretName: '' + flavor: openshift + +# Dynamically pull the component name from the release labels defined in helmfile.yaml +mclabels: + component: backend + partOf: boilerplates + owner: common + prometheus: + enabled: true + +caSecretName: '' + +env: + {{- if eq .Environment.Name "prod" }} + logLevel: info + logPrettyPrintEnabled: false + {{- else }} + logLevel: debug + logPrettyPrintEnabled: true + {{- end }} + +route: + enabled: true + {{- if eq .Environment.Name "prod" }} + host: {{ .Release.Name }}.mapcolonies.net + {{- else }} + host: {{ .Release.Name }}-{{ .Environment.Name }}.mapcolonies.net + {{- end }} diff --git a/helm/environments/dev.yaml b/helm/environments/dev.yaml new file mode 100644 index 00000000..7c136d07 --- /dev/null +++ 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 new file mode 100644 index 00000000..7c136d07 --- /dev/null +++ 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 new file mode 100644 index 00000000..7c136d07 --- /dev/null +++ b/helm/environments/stage.yaml @@ -0,0 +1,9 @@ +resources: + enabled: true + value: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi diff --git a/helm/helmfile.yaml b/helm/helmfile.yaml new file mode 100644 index 00000000..68299e4d --- /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 diff --git a/helm/templates/ingress.yaml b/helm/templates/ingress.yaml deleted file mode 100644 index 3355e5c9..00000000 --- a/helm/templates/ingress.yaml +++ /dev/null @@ -1,34 +0,0 @@ -{{- $releaseName := .Release.Name -}} -{{- $chartName := include "ts-server-boilerplate.name" . -}} -{{- if and (.Values.enabled) (.Values.ingress.enabled) -}} -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: {{ include "ts-server-boilerplate.fullname" . }} - 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' '*'; - {{- end }} -spec: - 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 -}}