Skip to content

Commit

Permalink
Allow custom downstream k8s version in the workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Parthvi <parthvi.vala@gmail.com>
  • Loading branch information
valaparthvi committed Jan 22, 2024
1 parent 62fffc1 commit a8ae24f
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/aks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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' }}
5 changes: 4 additions & 1 deletion .github/workflows/eks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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' }}
5 changes: 4 additions & 1 deletion .github/workflows/gke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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' }}
4 changes: 4 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion hosted/aks/p0/p0_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
)

const (
k8sVersion = "1.26.6"
increaseBy = 1
)

var (
ctx helpers.Context
clusterName string
location = helpers.GetAKSLocation()
k8sVersion = helpers.GetK8sVersion("aks")
)

func TestP0(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion hosted/eks/p0/p0_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
)

const (
k8sVersion = "1.26"
increaseBy = 1
)

var (
ctx helpers.Context
clusterName string
region = helpers.GetEKSRegion()
k8sVersion = helpers.GetK8sVersion("eks")
)

func TestP0(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion hosted/gke/p0/p0_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
)

const (
k8sVersion = "1.27.4-gke.900"
increaseBy = 1
)

Expand All @@ -19,6 +18,7 @@ var (
clusterName string
zone = helpers.GetGKEZone()
project = helpers.GetGKEProjectID()
k8sVersion = helpers.GetK8sVersion("gke")
)

func TestP0(t *testing.T) {
Expand Down
38 changes: 38 additions & 0 deletions hosted/helpers/helper_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

0 comments on commit a8ae24f

Please sign in to comment.