diff --git a/.github/workflows/aks.yaml b/.github/workflows/aks.yaml index 089cb1a0..cc45d4af 100644 --- a/.github/workflows/aks.yaml +++ b/.github/workflows/aks.yaml @@ -45,6 +45,9 @@ on: description: Runner template to use default: hosted-prov-e2e-ci-runner-spot-n2-highmem-16-gl-template-v1 type: string + provider_k8s_version: + description: Provider specific K8s version to test + default: 1.26.6 jobs: aks-e2e: @@ -61,3 +64,4 @@ jobs: run_support_matrix_importing_tests: ${{ inputs.run_support_matrix_importing_tests == true || (github.event_name == 'schedule' && false) }} destroy_runner: ${{ inputs.destroy_runner ==true || (github.event_name == 'schedule' && true) }} runner_template: ${{ inputs.runner_template || 'hosted-prov-e2e-ci-runner-spot-n2-highmem-16-gl-template-v1' }} + provider_k8s_version: ${{ inputs.provider_k8s_version || '1.26.6' }} diff --git a/.github/workflows/eks.yaml b/.github/workflows/eks.yaml index 57ac3404..f6c595bc 100644 --- a/.github/workflows/eks.yaml +++ b/.github/workflows/eks.yaml @@ -45,7 +45,9 @@ on: description: Runner template to use default: hosted-prov-e2e-ci-runner-spot-n2-highmem-16-gl-template-v1 type: string - + provider_k8s_version: + description: Provider specific K8s version to test + default: 1.26 jobs: eks-e2e: uses: ./.github/workflows/main.yaml @@ -61,3 +63,4 @@ jobs: run_support_matrix_importing_tests: ${{ inputs.run_support_matrix_importing_tests == true || (github.event_name == 'schedule' && false) }} destroy_runner: ${{ inputs.destroy_runner ==true || (github.event_name == 'schedule' && true) }} runner_template: ${{ inputs.runner_template || 'hosted-prov-e2e-ci-runner-spot-n2-highmem-16-gl-template-v1' }} + provider_k8s_version: ${{ inputs.provider_k8s_version || '1.26' }} diff --git a/.github/workflows/gke.yaml b/.github/workflows/gke.yaml index 492ab3e3..a8cdf0ae 100644 --- a/.github/workflows/gke.yaml +++ b/.github/workflows/gke.yaml @@ -45,7 +45,9 @@ on: description: Runner template to use default: hosted-prov-e2e-ci-runner-spot-n2-highmem-16-gl-template-v1 type: string - + provider_k8s_version: + description: Provider specific K8s version to test + default: 1.27.4-gke.900 jobs: gke-e2e: uses: ./.github/workflows/main.yaml @@ -61,3 +63,4 @@ jobs: run_support_matrix_importing_tests: ${{ inputs.run_support_matrix_importing_tests == true || (github.event_name == 'schedule' && false) }} destroy_runner: ${{ inputs.destroy_runner ==true || (github.event_name == 'schedule' && true) }} runner_template: ${{ inputs.runner_template || 'hosted-prov-e2e-ci-runner-spot-n2-highmem-16-gl-template-v1' }} + provider_k8s_version: ${{ inputs.provider_k8s_version || '1.27.4-gke.900' }} diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index ae523935..0d4a506c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -39,6 +39,9 @@ on: description: Runner template to use required: true type: string + provider_k8s_version: + description: Provider specific K8s version to test + type: string env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -54,6 +57,7 @@ env: RANCHER_PASSWORD: ${{ secrets.RANCHER_PASSWORD }} RANCHER_LOG_COLLECTOR: ${{ github.workspace }}/.github/scripts/collect-rancher-logs.sh GCP_RUNNER_ZONE: asia-south2-c + KUBERNETES_VERSION: ${{ inputs.provider_k8s_version }} jobs: create-runner: runs-on: ubuntu-latest diff --git a/README.md b/README.md index 93c62ce0..c62d3ca1 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Following are the common environment variables that need to be exported for runn 2. RANCHER_PASSWORD - Admin Password for login. We currently only test with 'admin' user. 3. CATTLE_TEST_CONFIG: Config file containing cluster and cloud credential information, for e.g. cattle-config-provisioning.yaml and cattle-config-import.yaml in the root directory. 4. PROVIDER: Type of the hosted provider you want to test. Acceptable values - gke, eks, aks +5. KUBERNETES_VERSION(Optional): Provider specific Kubernetes version to test. If the env var is not provided, the value is obtained from the config, if even that is not available, it uses a provider specific default value. To run GKE: 1. GCP_CREDENTIALS - a Service Account with a JSON private key and provide the JSON here. These IAM roles are required: diff --git a/hosted/aks/p0/p0_suite_test.go b/hosted/aks/p0/p0_suite_test.go index 2d986f87..c4148486 100644 --- a/hosted/aks/p0/p0_suite_test.go +++ b/hosted/aks/p0/p0_suite_test.go @@ -10,7 +10,6 @@ import ( ) const ( - k8sVersion = "1.26.6" increaseBy = 1 ) @@ -18,6 +17,7 @@ var ( ctx helpers.Context clusterName string location = helpers.GetAKSLocation() + k8sVersion = helpers.GetK8sVersion("aks") ) func TestP0(t *testing.T) { diff --git a/hosted/eks/p0/p0_suite_test.go b/hosted/eks/p0/p0_suite_test.go index 9aee5231..6a090aff 100644 --- a/hosted/eks/p0/p0_suite_test.go +++ b/hosted/eks/p0/p0_suite_test.go @@ -10,7 +10,6 @@ import ( ) const ( - k8sVersion = "1.26" increaseBy = 1 ) @@ -18,6 +17,7 @@ var ( ctx helpers.Context clusterName string region = helpers.GetEKSRegion() + k8sVersion = helpers.GetK8sVersion("eks") ) func TestP0(t *testing.T) { diff --git a/hosted/gke/p0/p0_suite_test.go b/hosted/gke/p0/p0_suite_test.go index 447b7082..c569a6a0 100644 --- a/hosted/gke/p0/p0_suite_test.go +++ b/hosted/gke/p0/p0_suite_test.go @@ -10,7 +10,6 @@ import ( ) const ( - k8sVersion = "1.27.4-gke.900" increaseBy = 1 ) @@ -19,6 +18,7 @@ var ( clusterName string zone = helpers.GetGKEZone() project = helpers.GetGKEProjectID() + k8sVersion = helpers.GetK8sVersion("gke") ) func TestP0(t *testing.T) { diff --git a/hosted/helpers/helper_common.go b/hosted/helpers/helper_common.go index 2d429e09..499a67c1 100644 --- a/hosted/helpers/helper_common.go +++ b/hosted/helpers/helper_common.go @@ -3,6 +3,9 @@ package helpers import ( "fmt" "github.com/onsi/ginkgo/v2" + "github.com/rancher/rancher/tests/framework/extensions/clusters/aks" + "github.com/rancher/rancher/tests/framework/extensions/clusters/eks" + "github.com/rancher/rancher/tests/framework/extensions/clusters/gke" "os" "os/user" "strings" @@ -202,3 +205,38 @@ func GetCommonMetadataLabels() map[string]string { "testfilenumber": filename, } } + +func GetK8sVersion(provider string) string { + k8sVersion := os.Getenv("KUBERNETES_VERSION") + if k8sVersion != "" { + return k8sVersion + } + switch provider { + case "gke": + gkeConfig := new(management.GKEClusterConfigSpec) + config.LoadConfig(gke.GKEClusterConfigConfigurationFileKey, gkeConfig) + if gkeConfig.KubernetesVersion != nil { + k8sVersion = *gkeConfig.KubernetesVersion + } else { + k8sVersion = "1.27.4-gke.900" + } + case "eks": + eksConfig := new(management.EKSClusterConfigSpec) + config.LoadConfig(eks.EKSClusterConfigConfigurationFileKey, eksConfig) + if eksConfig.KubernetesVersion != nil { + k8sVersion = *eksConfig.KubernetesVersion + } else { + k8sVersion = "1.26" + + } + case "aks": + aksConfig := new(management.AKSClusterConfigSpec) + config.LoadConfig(aks.AKSClusterConfigConfigurationFileKey, aksConfig) + if aksConfig.KubernetesVersion != nil { + k8sVersion = *aksConfig.KubernetesVersion + } else { + k8sVersion = "1.26.6" + } + } + return k8sVersion +}