From 100f1d02efd8d7887858d72f9965f6056360820e Mon Sep 17 00:00:00 2001 From: Benn Simon Date: Thu, 23 Sep 2021 11:46:16 +0300 Subject: [PATCH] update nginx manifest and configurations (#35) --- charts/opensrp-web/Chart.yaml | 2 +- charts/opensrp-web/README.md | 29 ++++++++++++++--------- charts/opensrp-web/templates/NOTES.txt | 2 +- charts/opensrp-web/templates/ingress.yaml | 28 ++++++++++++++++++---- charts/opensrp-web/values.yaml | 12 +++++++++- 5 files changed, 55 insertions(+), 18 deletions(-) diff --git a/charts/opensrp-web/Chart.yaml b/charts/opensrp-web/Chart.yaml index e3a48a9..e569ed5 100644 --- a/charts/opensrp-web/Chart.yaml +++ b/charts/opensrp-web/Chart.yaml @@ -19,7 +19,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.8 +version: 0.2.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/opensrp-web/README.md b/charts/opensrp-web/README.md index 46d010a..c7c06e0 100644 --- a/charts/opensrp-web/README.md +++ b/charts/opensrp-web/README.md @@ -37,16 +37,22 @@ ingress: annotations: kubernetes.io/ingress.class: nginx kubernetes.io/tls-acme: "true" - cert-manager.io/cluster-issuer: "" + cert-manager.io/cluster-issuer: cert-manager.io/acme-challenge-type: http01 nginx.ingress.kubernetes.io/force-ssl-redirect: "true" - hosts: - - host: - paths: ["/"] - tls: - - secretName: - hosts: - - + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: opensrp-web.local + paths: + - path: / + pathType: ImplementationSpecific + + tls: + - secretName: opensrp-web-tls + hosts: + - opensrp-web.local sharedVars: keycloakUrl: "keycloak-url" @@ -89,9 +95,10 @@ reactEnvironmentVariables: | `service.type` | | `"ClusterIP"` | | `service.port` | | `8080` | | `ingress.enabled` | | `false` | -| `ingress.annotations` | | `{}` | -| `ingress.hosts` | | `[{"host": "opensrp-web.local", "paths": []}]` | -| `ingress.tls` | | `[]` | +| `ingress.className` | | `""` | +| `ingress.annotations` | | `{}` | +| `ingress.hosts` | | `[{"host": "opensrp-web.local", "paths": [{"path": "/", "pathType": "ImplementationSpecific"}]}]` | +| `ingress.tls` | | `[]` | | `resources` | | `{}` | | `autoscaling.enabled` | | `false` | | `autoscaling.minReplicas` | | `1` | diff --git a/charts/opensrp-web/templates/NOTES.txt b/charts/opensrp-web/templates/NOTES.txt index 7388027..1a621b8 100644 --- a/charts/opensrp-web/templates/NOTES.txt +++ b/charts/opensrp-web/templates/NOTES.txt @@ -2,7 +2,7 @@ {{- if .Values.ingress.enabled }} {{- range $host := .Values.ingress.hosts }} {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} {{- end }} {{- end }} {{- else if contains "NodePort" .Values.service.type }} diff --git a/charts/opensrp-web/templates/ingress.yaml b/charts/opensrp-web/templates/ingress.yaml index 2f802fe..69fe38c 100644 --- a/charts/opensrp-web/templates/ingress.yaml +++ b/charts/opensrp-web/templates/ingress.yaml @@ -1,7 +1,14 @@ -{{- if .Values.ingress.enabled -}} +{{- if and .Values.ingress.enabled -}} {{- $fullName := include "opensrp-web.fullname" . -}} {{- $svcPort := .Values.service.port -}} -{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- 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 @@ -16,6 +23,9 @@ metadata: {{- 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 }} @@ -32,10 +42,20 @@ spec: http: paths: {{- range .paths }} - - path: {{ . }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} serviceName: {{ $fullName }} servicePort: {{ $svcPort }} + {{- end }} {{- end }} {{- end }} - {{- end }} +{{- end }} diff --git a/charts/opensrp-web/values.yaml b/charts/opensrp-web/values.yaml index 94f7b0c..6201ed0 100644 --- a/charts/opensrp-web/values.yaml +++ b/charts/opensrp-web/values.yaml @@ -37,11 +37,21 @@ service: ingress: enabled: false + className: "" annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" hosts: - host: opensrp-web.local - paths: [] + paths: + - path: / + pathType: ImplementationSpecific + tls: [] +# - secretName: opensrp-web-tls +# hosts: +# - opensrp-web.local + resources: {} autoscaling: