From 6a4f5832cf1a20b7e5eb04fdce9b34ee5eba44ea Mon Sep 17 00:00:00 2001 From: Ritika Patil Date: Thu, 11 Jan 2024 16:27:54 -0600 Subject: [PATCH] feat: (IAC-1186) Updated logic based on latest supported ingress versions --- docs/CONFIG-VARS.md | 2 +- roles/baseline/defaults/main.yml | 6 +----- roles/baseline/tasks/ingress-nginx.yaml | 12 +++++++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/CONFIG-VARS.md b/docs/CONFIG-VARS.md index 280a039a..a16fe52d 100644 --- a/docs/CONFIG-VARS.md +++ b/docs/CONFIG-VARS.md @@ -408,7 +408,7 @@ The EBS CSI driver is currently only used for kubernetes v1.23 or later AWS EKS | INGRESS_NGINX_NAMESPACE | NGINX Ingress Helm installation namespace | string | ingress-nginx | false | | baseline | | INGRESS_NGINX_CHART_URL | NGINX Ingress Helm chart URL | string | See [this document](https://kubernetes.github.io/ingress-nginx) for more information. | false | | baseline | | INGRESS_NGINX_CHART_NAME | NGINX Ingress Helm chart name | string | ingress-nginx | false | | baseline | -| INGRESS_NGINX_CHART_VERSION | NGINX Ingress Helm chart version | string | "" | false | If left as "" (empty string), version 4.3.0 is used for Kubernetes clusters whose version is <= 1.24.X, and version 4.9.0 is used for Kubernetes clusters whose version is >= 1.25.X. | baseline | +| INGRESS_NGINX_CHART_VERSION | NGINX Ingress Helm chart version | string | "" | false | If left as "" (empty string), version `4.9.0` is used for Kubernetes clusters whose version is >= 1.25.X, and for Kubernetes clusters whose version is <= 1.24.X please set this variable to avoid errors. See [Supported Versions table](https://github.com/kubernetes/ingress-nginx/?tab=readme-ov-file#supported-versions-table) for the supported versions list. | baseline | | INGRESS_NGINX_CONFIG | NGINX Ingress Helm values | string | See [this file](../roles/baseline/defaults/main.yml) for more information. Altering this value will affect the cluster. | false | | baseline | ### Metrics Server diff --git a/roles/baseline/defaults/main.yml b/roles/baseline/defaults/main.yml index eccbee0d..2377eb6e 100644 --- a/roles/baseline/defaults/main.yml +++ b/roles/baseline/defaults/main.yml @@ -31,11 +31,7 @@ METRICS_SERVER_CONFIG: ## Ingress-nginx - Defaults ingressVersions: - k8sMinorVersionCeiling: - value: 24 - api: - chartVersion: 4.3.0 - k8sMinorVersionFloor: + k8sMinorVersion: value: 25 api: chartVersion: 4.9.0 diff --git a/roles/baseline/tasks/ingress-nginx.yaml b/roles/baseline/tasks/ingress-nginx.yaml index 85adb019..1d2937aa 100644 --- a/roles/baseline/tasks/ingress-nginx.yaml +++ b/roles/baseline/tasks/ingress-nginx.yaml @@ -25,11 +25,17 @@ register: cluster_info - name: Set the default INGRESS_NGINX_CHART_VERSION based on K8s server minor version set_fact: - INGRESS_NGINX_CHART_VERSION: "{{ ingressVersions.k8sMinorVersionFloor.api.chartVersion if cluster_info.version.server.kubernetes.minor is version(ingressVersions.k8sMinorVersionFloor.value, - 'ge') else ingressVersions.k8sMinorVersionCeiling.api.chartVersion }}" + INGRESS_NGINX_CHART_VERSION: "{{ ingressVersions.k8sMinorVersion.api.chartVersion if cluster_info.version.server.kubernetes.minor is version(ingressVersions.k8sMinorVersion.value, + 'ge') else '' }}" - name: Output INGRESS_NGINX_CHART_VERSION debug: msg: "{{ INGRESS_NGINX_CHART_VERSION }}" + - name: Fail when INGRESS_NGINX_CHART_VERSION not set + fail: + msg: "INGRESS_NGINX_CHART_VERSION isn't set when K8s version is < 1.{{ingressVersions.k8sMinorVersion.value}}." + when: + - cluster_info.version.server.kubernetes.minor is version(ingressVersions.k8sMinorVersion.value, 'lt') + - INGRESS_NGINX_CHART_VERSION == "" - name: Update INGRESS_NGINX_CONFIG to use NLB for AWS set_fact: @@ -62,7 +68,7 @@ set_fact: INGRESS_NGINX_CONFIG: "{{ INGRESS_NGINX_CONFIG | combine(INGRESS_NGINX_CVE_2021_25742_PATCH, recursive=True) }}" when: - - cluster_info.version.server.kubernetes.minor is version(ingressVersions.k8sMinorVersionFloor.value, 'ge') + - cluster_info.version.server.kubernetes.minor is version(ingressVersions.k8sMinorVersion.value, 'ge') - INGRESS_NGINX_CHART_VERSION is version('4.0.10', ">=") or (INGRESS_NGINX_CHART_VERSION is version('3.40.0', ">=") and INGRESS_NGINX_CHART_VERSION is version('4.0.0', "<"))