Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom downstream k8s version for workflows #41

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
downstream_k8s_version:
description: Downstream cluster 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' }}
downstream_k8s_version: ${{ inputs.downstream_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

downstream_k8s_version:
description: Downstream cluster 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' }}
downstream_k8s_version: ${{ inputs.downstream_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

downstream_k8s_version:
description: Downstream cluster K8s version to test
default: 1.27.3-gke.100
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' }}
downstream_k8s_version: ${{ inputs.downstream_k8s_version || '1.27.3-gke.100' }}
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
downstream_k8s_version:
description: Downstream cluster 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
DOWNSTREAM_KUBERNETES_VERSION: ${{ inputs.downstream_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. DOWNSTREAM_KUBERNETES_VERSION (optional): Downstream cluster 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
3 changes: 1 addition & 2 deletions cattle-config-provisioning.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ gkeClusterConfig:
subnetworkName: ""
useIpAliases: true
kubernetesVersion: 1.27.3-gke.100
labels:
owner: hosted-provider-ci
labels: {}
locations: []
loggingService: logging.googleapis.com/kubernetes
maintenanceWindow: ""
Expand Down
1 change: 1 addition & 0 deletions hosted/aks/p0/p0_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var _ = Describe("P0Provisioning", func() {
aksConfig.DNSPrefix = &dnsPrefix
aksConfig.ResourceLocation = location
aksConfig.Tags = helper.GetTags()
aksConfig.KubernetesVersion = &k8sVersion
})
cluster, err = aks.CreateAKSHostedCluster(ctx.RancherClient, clusterName, ctx.CloudCred.ID, false, false, false, false, map[string]string{})
Expect(err).To(BeNil())
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
1 change: 1 addition & 0 deletions hosted/eks/p0/p0_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var _ = Describe("P0Provisioning", func() {
config.LoadAndUpdateConfig(eks.EKSClusterConfigConfigurationFileKey, eksConfig, func() {
eksConfig.Region = region
eksConfig.Tags = helper.GetTags()
eksConfig.KubernetesVersion = &k8sVersion
})
cluster, err = eks.CreateEKSHostedCluster(ctx.RancherClient, clusterName, ctx.CloudCred.ID, false, false, false, false, map[string]string{})
Expect(err).To(BeNil())
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
3 changes: 3 additions & 0 deletions hosted/gke/p0/p0_importing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ var _ = Describe("P0Importing", func() {
gkeConfig.Zone = zone
labels := helper.GetLabels()
gkeConfig.Labels = &labels
for _, np := range gkeConfig.NodePools {
np.Version = &k8sVersion
}
})
cluster, err = helper.ImportGKEHostedCluster(ctx.RancherClient, clusterName, ctx.CloudCred.ID, false, false, false, false, map[string]string{})
Expect(err).To(BeNil())
Expand Down
4 changes: 4 additions & 0 deletions hosted/gke/p0/p0_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ var _ = Describe("P0Provisioning", func() {
gkeConfig.Zone = zone
labels := helper.GetLabels()
gkeConfig.Labels = &labels
gkeConfig.KubernetesVersion = &k8sVersion
for _, np := range gkeConfig.NodePools {
np.Version = &k8sVersion
}
})

cluster, err = gke.CreateGKEHostedCluster(ctx.RancherClient, clusterName, ctx.CloudCred.ID, false, false, false, false, map[string]string{})
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.3-gke.100"
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
39 changes: 38 additions & 1 deletion 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 @@ -32,7 +35,6 @@ var (
rancherPassword = os.Getenv("RANCHER_PASSWORD")
rancherHostname = os.Getenv("RANCHER_HOSTNAME")
cloudCredential *cloudcredentials.CloudCredential
rancherConfig *rancher.Config
)

type Context struct {
Expand Down Expand Up @@ -202,3 +204,38 @@ func GetCommonMetadataLabels() map[string]string {
"testfilenumber": filename,
}
}

func GetK8sVersion(provider string) string {
k8sVersion := os.Getenv("DOWNSTREAM_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.3-gke.100"
}
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
}
Loading