Jelajahi Sumber

Fixed ingress template for k8s version older than 1.19 (#2318)

* Fixed ingress template for k8s version older than 1.19

* Added manifest tests with version lower than 1.19, and ingress enabled
José Antonio Cortés López 2 tahun lalu
induk
melakukan
bff27f1b5b
2 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 2 2
      .github/workflows/helm.yaml
  2. 2 2
      charts/kafka-ui/templates/ingress.yaml

+ 2 - 2
.github/workflows/helm.yaml

@@ -22,11 +22,11 @@ jobs:
         shell: bash
         run: |
           sed -i "s@enabled: false@enabled: true@g" charts/kafka-ui/values.yaml
-          K8S_VERSIONS=$(git ls-remote --refs --tags https://github.com/kubernetes/kubernetes.git | cut -d/ -f3 | grep -e '^v1\.[0-9]\{2\}\.[0]\{1,2\}$' | grep -v -e  '^v1\.1[0-8]\{1\}' | cut -c2-)
+          K8S_VERSIONS=$(git ls-remote --refs --tags https://github.com/kubernetes/kubernetes.git | cut -d/ -f3 | grep -e '^v1\.[0-9]\{2\}\.[0]\{1,2\}$' | grep -v -e  '^v1\.1[0-7]\{1\}' | cut -c2-)
           echo "NEXT K8S VERSIONS ARE GOING TO BE TESTED: $K8S_VERSIONS"
           echo ""
           for version in $K8S_VERSIONS
             do
               echo $version;
-              helm template charts/kafka-ui -f charts/kafka-ui/values.yaml | kubeval --additional-schema-locations https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master --strict -v $version;
+              helm template --kube-version $version --set ingress.enabled=true charts/kafka-ui -f charts/kafka-ui/values.yaml | kubeval --additional-schema-locations https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master --strict -v $version;
             done

+ 2 - 2
charts/kafka-ui/templates/ingress.yaml

@@ -1,7 +1,7 @@
 {{- if .Values.ingress.enabled -}}
 {{- $fullName := include "kafka-ui.fullname" . -}}
 {{- $svcPort := .Values.service.port -}}
-{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
+{{- if and ($.Capabilities.APIVersions.Has "networking.k8s.io/v1") (trimPrefix "v" .Capabilities.KubeVersion.Version | semverCompare ">= 1.19" ) -}}
 apiVersion: networking.k8s.io/v1
 {{- else if $.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }}
 apiVersion: networking.k8s.io/v1beta1
@@ -30,7 +30,7 @@ spec:
   rules:
     - http:
         paths:
-{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1" -}}
+{{- if and ($.Capabilities.APIVersions.Has "networking.k8s.io/v1") (trimPrefix "v" .Capabilities.KubeVersion.Version | semverCompare ">= 1.19" ) -}}
           {{- range .Values.ingress.precedingPaths }}
           - path: {{ .path }}
             pathType: Prefix