From b6f15551764a78ce82e4ffc7f36dc3642dce991c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Wed, 2 Jun 2021 16:15:50 +0200 Subject: [PATCH] added ingressClassName MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Bauer --- .github/workflows/e2e.yml | 4 ++- .github/workflows/test.yml | 8 +++-- charts/podinfo/Chart.yaml | 3 +- charts/podinfo/README.md | 2 +- charts/podinfo/templates/ingress.yaml | 46 +++++++++++++-------------- charts/podinfo/values-prod.yaml | 9 ++++-- charts/podinfo/values.yaml | 9 ++++-- 7 files changed, 46 insertions(+), 35 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 9ec0fc5..09f9711 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -11,13 +11,15 @@ jobs: strategy: matrix: helm-version: - - 3.5.3 + - 3.6.0 runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Setup Kubernetes uses: engineerd/setup-kind@v0.5.0 + with: + image: kindest/node:v1.19.11 - name: Build container image run: | ./test/build.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d4864e1..35af138 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,11 +33,15 @@ jobs: - name: Validate Helm chart uses: stefanprodan/kube-tools@v1 with: + kubectl: 1.19.11 + helm: 2.17.0 + helmv3: 3.6.0 command: | - helmv3 template ./charts/podinfo | kubeval --strict + helmv3 template ./charts/podinfo | kubeval --strict --kubernetes-version 1.19.11 --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master - name: Validate kustomization uses: stefanprodan/kube-tools@v1 with: + kubectl: 1.19.11 command: | - kustomize build ./kustomize | kubeval --strict + kustomize build ./kustomize | kubeval --strict --kubernetes-version 1.19.11 --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master kustomize build ./kustomize | conftest test -p .github/policy - diff --git a/charts/podinfo/Chart.yaml b/charts/podinfo/Chart.yaml index 41c3d60..f69cd09 100644 --- a/charts/podinfo/Chart.yaml +++ b/charts/podinfo/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 -version: 5.2.1 +version: 6.0.0 appVersion: 5.2.1 name: podinfo engine: gotpl @@ -10,3 +10,4 @@ maintainers: name: stefanprodan sources: - https://github.com/stefanprodan/podinfo +kubeVersion: ">=1.19.0-0" diff --git a/charts/podinfo/README.md b/charts/podinfo/README.md index 94f608a..0533769 100644 --- a/charts/podinfo/README.md +++ b/charts/podinfo/README.md @@ -76,8 +76,8 @@ Parameter | Default | Description `serviceMonitor.interval` | `15s` | Prometheus scraping interval `serviceMonitor.additionalLabels` | `{}` | Add additional labels to the service monitor | `ingress.enabled` | `false` | Enables Ingress +`ingress.className ` | `""` | Use ingressClassName `ingress.annotations` | `{}` | Ingress annotations -`ingress.path` | `/*` | Ingress path `ingress.hosts` | `[]` | Ingress accepted hosts `ingress.tls` | `[]` | Ingress TLS configuration `resources.requests.cpu` | `1m` | Pod CPU request diff --git a/charts/podinfo/templates/ingress.yaml b/charts/podinfo/templates/ingress.yaml index fee355c..93f9ae4 100644 --- a/charts/podinfo/templates/ingress.yaml +++ b/charts/podinfo/templates/ingress.yaml @@ -1,43 +1,41 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "podinfo.fullname" . -}} -{{- $ingressPath := .Values.ingress.path -}} -apiVersion: networking.k8s.io/v1beta1 +{{- $svcPort := .Values.service.externalPort -}} +apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ $fullName }} labels: {{- include "podinfo.labels" . | nindent 4 }} -{{- with .Values.ingress.annotations }} + {{- with .Values.ingress.annotations }} annotations: -{{ toYaml . | indent 4 }} -{{- end }} + {{- toYaml . | nindent 4 }} + {{- end }} spec: -{{- if .Values.ingress.tls }} + ingressClassName: {{ .Values.ingress.className }} + {{- if .Values.ingress.tls }} tls: - {{- range .Values.ingress.tls }} + {{- range .Values.ingress.tls }} - hosts: - {{- range .hosts }} + {{- range .hosts }} - {{ . | quote }} - {{- end }} + {{- end }} secretName: {{ .secretName }} + {{- end }} {{- end }} -{{- end }} rules: - {{- range .Values.ingress.hosts }} - - host: {{ . | quote }} + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} http: paths: - - path: {{ $ingressPath }} + {{- range .paths }} + - path: {{ .path }} + pathType: {{ .pathType }} backend: - serviceName: {{ $fullName }} - servicePort: http - {{- end }} - {{- if not .Values.ingress.hosts }} - - http: - paths: - - path: {{ $ingressPath }} - backend: - serviceName: {{ $fullName }} - servicePort: http - {{- end }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} {{- end }} diff --git a/charts/podinfo/values-prod.yaml b/charts/podinfo/values-prod.yaml index faf618f..a6aebc9 100644 --- a/charts/podinfo/values-prod.yaml +++ b/charts/podinfo/values-prod.yaml @@ -97,12 +97,15 @@ securityContext: {} ingress: enabled: false + className: "" annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" - path: /* - hosts: [] - # - podinfo.local + hosts: + - host: podinfo.local + paths: + - path: / + pathType: ImplementationSpecific tls: [] # - secretName: chart-example-tls # hosts: diff --git a/charts/podinfo/values.yaml b/charts/podinfo/values.yaml index ce42fc7..8d1296e 100644 --- a/charts/podinfo/values.yaml +++ b/charts/podinfo/values.yaml @@ -101,12 +101,15 @@ securityContext: {} ingress: enabled: false + className: "" annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" - path: /* - hosts: [] - # - podinfo.local + hosts: + - host: podinfo.local + paths: + - path: / + pathType: ImplementationSpecific tls: [] # - secretName: chart-example-tls # hosts: