Hello there joseacl! 👋

Thank you and congratulations 🎉 for opening your very first issue in this project! 💖

In case you want to claim this issue, please comment down below! We will try to get back to you as soon as we can. 👀 Hi @Haarolean @germanosin.

I've opened that issue because we're rolling out this tool in our clusters and due to the fact that we have clusters with different Kubernetes versions, we've realized the error described in the issue.

Currently, we're overriding the ingress template, so I've decided to create a PR https://github.com/provectus/kafka-ui/pull/2318 because it can happen to other users.
Looking forward to hearing from you, 

Thanks a lot! Hey @joseacl, thanks for raising the issue, we'll take a look at the PR :)
Make Ingress resource compatible with kubernetes versions lower than 1.19
**Describe the bug**
The helm template file for ingress is checking that **APIVersions** contains **networking.k8s.io/v1**, but this capability is available in Kubernetes since the version v1.8 **but for NetworkPolicy resource and not for Ingress**. https://kubernetes.io/docs/reference/using-api/deprecation-guide/#networkpolicy-v116

So if you applied helm template with **--kube-version 1.18** for example, the ingress is going to be rendered using **apiVersion: networking.k8s.io/v1** which is not supported by this version of Kubernetes https://kubernetes.io/docs/reference/using-api/deprecation-guide/#ingress-v122

**Set up**
Using helm version Version:"v3.8.0" with has --kube-version flags available.

Clone the repository and go to charts/kafka-ui

**Steps to Reproduce**

Steps to reproduce the behavior:

1. Execute the following command
`helm template --kube-version 1.18 --set ingress.enabled=true --output-dir ./manifests .`

**Expected behavior**
Ingress resource rendered should be compatible with kubernetes version specified, 1.18. Something like this

```
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: release-name-kafka-ui
  labels:
    helm.sh/chart: kafka-ui-0.0.4
    app.kubernetes.io/name: kafka-ui
    app.kubernetes.io/instance: release-name
    app.kubernetes.io/version: "latest"
    app.kubernetes.io/managed-by: Helm
spec:
  rules:
    - http:
        paths:
          - backend:
              serviceName: release-name-kafka-ui
              servicePort: 80
```

But with the current template, the ingress is incompatible with versions lower than 1.19

```
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: release-name-kafka-ui
  labels:
    helm.sh/chart: kafka-ui-0.0.4
    app.kubernetes.io/name: kafka-ui
    app.kubernetes.io/instance: release-name
    app.kubernetes.io/version: "latest"
    app.kubernetes.io/managed-by: Helm
spec:
  rules:
    - http:
        paths:
          - backend:
              service:
                name: release-name-kafka-ui
                port:
                  number: 80
            pathType: Prefix

```

.github/workflows/helm.yaml charts/kafka-ui/templates/ingress.yaml
.github/workflows/helm.yaml charts/kafka-ui/templates/ingress.yaml
diff --git a/.github/workflows/helm.yaml b/.github/workflows/helm.yaml
index 664a15e8a73..0da4bdc51e4 100644
--- a/.github/workflows/helm.yaml
+++ b/.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
diff --git a/charts/kafka-ui/templates/ingress.yaml b/charts/kafka-ui/templates/ingress.yaml
index 8631ea0130c..7659867b31a 100644
--- a/charts/kafka-ui/templates/ingress.yaml
+++ b/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
