Skip to content

Commit

Permalink
Update all the workflow input with GCP Zone and move to geolocalized …
Browse files Browse the repository at this point in the history
…instance template (#19)

* Update all the workflow input with GCP Zone

* Change to geolocalized instance template

* Move all the region to APAC

* Remove gcp runner zone from user input

* Use a single source of truth to obtain provider locations

Signed-off-by: Parthvi <parthvi.vala@gmail.com>
---------

Signed-off-by: Parthvi <parthvi.vala@gmail.com>
  • Loading branch information
valaparthvi authored Jan 9, 2024
1 parent 5871852 commit 6837488
Show file tree
Hide file tree
Showing 22 changed files with 143 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/aks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ on:
type: boolean
runner_template:
description: Runner template to use
default: hosted-prov-e2e-ci-runner-spot-x86-64-template-n2-highmem-32-v2
default: hosted-prov-e2e-ci-runner-spot-n2-highmem-16-gl-template-v1
type: string

jobs:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/eks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ on:
type: boolean
runner_template:
description: Runner template to use
default: hosted-prov-e2e-ci-runner-spot-x86-64-template-n2-highmem-32-v2
default: hosted-prov-e2e-ci-runner-spot-n2-highmem-16-gl-template-v1
type: string

jobs:
Expand All @@ -59,4 +59,3 @@ jobs:
run_support_matrix_importing_tests: ${{ inputs.run_support_matrix_importing_tests == true }}
destroy_runner: ${{ inputs.destroy_runner == true }}
runner_template: ${{ inputs.runner_template }}

2 changes: 1 addition & 1 deletion .github/workflows/gke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ on:
type: boolean
runner_template:
description: Runner template to use
default: hosted-prov-e2e-ci-runner-spot-x86-64-template-n2-highmem-32-v2
default: hosted-prov-e2e-ci-runner-spot-n2-highmem-16-gl-template-v1
type: string

jobs:
Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ on:
type: boolean
runner_template:
description: Runner template to use
default: hosted-prov-e2e-ci-runner-spot-x86-64-template-n2-highmem-32-v2
type: string
zone:
description: GCP zone to host the runner
default: us-west1-b
default: hosted-prov-e2e-ci-runner-spot-n2-highmem-16-gl-template-v1
type: string

env:
Expand All @@ -57,7 +53,7 @@ env:
PROVIDER: ${{ inputs.hosted_provider }}
RANCHER_PASSWORD: rancherpassword
RANCHER_LOG_COLLECTOR: ${{ github.workspace }}/.github/scripts/collect-rancher-logs.sh
GCP_RUNNER_ZONE: asia-south2-c
jobs:
create-runner:
runs-on: ubuntu-latest
Expand All @@ -84,13 +80,14 @@ jobs:
uses: google-github-actions/setup-gcloud@v1
- name: Create runner
run: |
REGION=$(echo ${{ env.GCP_RUNNER_ZONE }} | sed 's/-[abcdef]$//')
gcloud compute instances create ${{ steps.generator.outputs.runner }} \
--zone ${{ inputs.zone }} \
--source-instance-template ${{ inputs.runner_template }} &> /dev/null
--zone ${{ env.GCP_RUNNER_ZONE }} \
--source-instance-template projects/${{ env.GKE_PROJECT_ID }}/regions/${REGION}/instanceTemplates/${{ inputs.runner_template }}
- name: Allow traffic
run: |
gcloud compute instances add-tags ${{ steps.generator.outputs.runner }} \
--tags http-server,https-server --zone ${{ inputs.zone }}
--tags http-server,https-server --zone ${{ env.GCP_RUNNER_ZONE }}
- name: Create GCP secrets
run: |
echo -n ${{ secrets.PAT_TOKEN }} \
Expand Down Expand Up @@ -229,4 +226,4 @@ jobs:
run: |
gcloud --quiet compute instances delete ${{ needs.create-runner.outputs.runner }} \
--delete-disks all \
--zone ${{ inputs.zone }}
--zone ${{ env.GCP_RUNNER_ZONE }}
43 changes: 35 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,57 @@ To run GKE:
- Project: Viewer (roles/viewer)
- Kubernetes Engine: Kubernetes Engine Admin (roles/container.admin)
- Service Accounts: Service Account User (roles/iam.serviceAccountUser)

2. GKE_PROJECT_ID - Name of the Google Cloud Project
3. GKE_ZONE - Zone in which GKE must be provisioned (default: 'asia-south2-c'). This environment variable takes precedence over the config file variable.

To run EKS:
1. AWS_ACCESS_KEY_ID - AWS Access Key
2. AWS_SECRET_ACCESS_KEY - AWS Secret Key
3. EKS_REGION - Default Region (default: us-west-2)
3. EKS_REGION - Region in which EKS must be provisioned (default: 'ap-south-1'). This environment variable takes precedence over the config file variable.

To run AKS:
1. AKS_CLIENT_ID - Azure Client ID [Check Microsoft Entra ID to create or fetch value from an existing one](https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal)
2. AKS_CLIENT_SECRET - Azure Client Secret [Check Microsoft Entra ID to create or fetch value from an existing one](https://learn.microsoft.com/en-us/entra/identity-platform/howto-create-service-principal-portal)
3. AKS_SUBSCRIPTION_ID - Azure Subscription ID (In this case it is similar to a Google Cloud Project, but the value is an ID). [Check Azure Subscriptions](https://learn.microsoft.com/en-us/microsoft-365/enterprise/subscriptions-licenses-accounts-and-tenants-for-microsoft-cloud-offerings?view=o365-worldwide#subscriptions)
4. AKS_REGION - Region in which AKS must be provisioned (default: 'centralindia'). This environment variable takes precedence over the config file variable.


**Note:** It is advisable that all the Hosted Provider cluster be provisioned in APAC region, this is because we want to geolocalize all the resources created by hosted provider.

### Makefile targets to run tests
1. `make e2e-provisioning-tests` - Covers the _P0Provisioning_ test suite for a given ${PROVIDER}
2. `make e2e-import-tests` - Covers the _P0Importing_ test suite for a given ${PROVIDER}
3. `make e2e-support-matrix-importing-tests` - Covers the _SupportMatrixImporting_ test suite for a given ${PROVIDER}
4. `make e2e-support-matrix-provisioning-tests` - Covers the _SupportMatrixProvisioning_ test suite for a given ${PROVIDER}
1. `make e2e-provisioning-tests` - Covers the _P0Provisioning_ test suite for a given `${PROVIDER}`
2. `make e2e-import-tests` - Covers the _P0Importing_ test suite for a given `${PROVIDER}`
3. `make e2e-support-matrix-importing-tests` - Covers the _SupportMatrixImporting_ test suite for a given `${PROVIDER}`
4. `make e2e-support-matrix-provisioning-tests` - Covers the _SupportMatrixProvisioning_ test suite for a given `${PROVIDER}`

Run `make help` to know about other targets.

### Example
**GKE Provisioning Tests**
```shell
GKE_PROJECT_ID=some-project GCP_CREDENTIALS=<credentials-json> PROVIDER=gke RANCHER_HOSTNAME=ec2-1-2-3-4.ap-south-1.compute.amazonaws.com RANCHER_PASSWORD=admin123 CATTLE_TEST_CONFIG=/home/pvala/go/src/github.com/rancher/hosted-providers-e2e/hosted/gke/cattle-config-provisioning.yaml make e2e-provisioning-tests
```

**GKE Import Tests**
```shell
GKE_PROJECT_ID=some-project GCP_CREDENTIALS=<credentials-json> PROVIDER=gke RANCHER_HOSTNAME=ec2-1-2-3-4.ap-south-1.compute.amazonaws.com RANCHER_PASSWORD=admin123 CATTLE_TEST_CONFIG=/home/pvala/go/src/github.com/rancher/hosted-providers-e2e/hosted/gke/cattle-config-import.yaml make e2e-import-tests
```

**EKS Provisioning Tests**
```shell
EKS_REGION=ap-south-1 AWS_ACCESS_KEY_ID=<key-id> AWS_SECRET_ACCESS_KEY=<key> PROVIDER=eks RANCHER_HOSTNAME=ec2-1-2-3-4.ap-south-1.compute.amazonaws.com RANCHER_PASSWORD=admin123 CATTLE_TEST_CONFIG=/home/pvala/go/src/github.com/rancher/hosted-providers-e2e/hosted/gke/cattle-config-provisioning.yaml make e2e-provisioning-tests
```

**EKS Import Tests**
```shell
EKS_REGION=ap-south-1 AWS_ACCESS_KEY_ID=<key-id> AWS_SECRET_ACCESS_KEY=<key> PROVIDER=eks RANCHER_HOSTNAME=ec2-1-2-3-4.ap-south-1.compute.amazonaws.com RANCHER_PASSWORD=admin123 CATTLE_TEST_CONFIG=/home/pvala/go/src/github.com/rancher/hosted-providers-e2e/hosted/gke/cattle-config-import.yaml make e2e-import-tests
```

**AKS Provisioning Tests**
```shell
AKS_REGION=centralindia AKS_CLIENT_ID=<client-id> AKS_CLIENT_SECRET=<secret> AKS_SUBSCRIPTION_ID=<subscription-id> PROVIDER=aks RANCHER_HOSTNAME=ec2-1-2-3-4.ap-south-1.compute.amazonaws.com RANCHER_PASSWORD=admin123 CATTLE_TEST_CONFIG=/home/pvala/go/src/github.com/rancher/hosted-providers-e2e/hosted/gke/cattle-config-provisioning.yaml make e2e-provisioning-tests
```

**AKS Import Tests**
```shell
PROVIDER=gke RANCHER_HOSTNAME=ec2-1-2-3-4.ap-south-1.compute.amazonaws.com CATTLE_TEST_CONFIG=/home/pvala/go/src/github.com/rancher/hosted-providers-e2e/hosted/gke/config make e2e-provisioning-tests
AKS_REGION=centralindia AKS_CLIENT_ID=<client-id> AKS_CLIENT_SECRET=<secret> AKS_SUBSCRIPTION_ID=<subscription-id> PROVIDER=aks RANCHER_HOSTNAME=ec2-1-2-3-4.ap-south-1.compute.amazonaws.com RANCHER_PASSWORD=admin123 CATTLE_TEST_CONFIG=/home/pvala/go/src/github.com/rancher/hosted-providers-e2e/hosted/gke/cattle-config-import.yaml make e2e-import-tests
```
6 changes: 3 additions & 3 deletions cattle-config-import.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ aksClusterConfig:
osType: Linux
vmSize: Standard_DS2_v2
resourceGroup: ""
resourceLocation: eastus
resourceLocation: centralindia
awsCredentials:
azureCredentials:
environment: AzurePublicCloud
Expand All @@ -39,10 +39,10 @@ eksClusterConfig:
subnets: []
tags: {}
userData: ""
region: ca-central-1
region: ap-south-1
gkeClusterConfig:
projectID: <project>
zone: us-central1-c
zone: asia-south2-c
imported: true
nodePools:
- autoscaling: {}
Expand Down
8 changes: 4 additions & 4 deletions cattle-config-provisioning.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ aksClusterConfig:
vmSize: Standard_DS2_v2
privateCluster: false
resourceGroup: ""
resourceLocation: eastus
tags: {}
resourceLocation: centralindia
tags: {}
awsCredentials:
azureCredentials:
environment: AzurePublicCloud
Expand Down Expand Up @@ -51,7 +51,7 @@ eksClusterConfig:
privateAccess: false
publicAccess: true
publicAccessSources: []
region: us-east-2
region: ap-south-1
secretsEncryption: false
securityGroups: []
serviceRole: ""
Expand Down Expand Up @@ -120,7 +120,7 @@ gkeClusterConfig:
masterIpv4CidrBlock: ""
region: ""
subnetwork: default
zone: us-central1-c
zone: asia-south2-c
projectID: <project>
googleCredentials:
rancher:
Expand Down
4 changes: 3 additions & 1 deletion hosted/aks/p0/p0_importing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import (
)

var _ = Describe("P0Importing", func() {

var (
location = helpers.GetAKSLocation()
)
When("a cluster is imported", func() {
var cluster *management.Cluster

Expand Down
1 change: 0 additions & 1 deletion hosted/aks/p0/p0_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
var (
ctx helpers.Context
clusterName string
location = "eastus"
k8sVersion = "1.26.6"
increaseBy = 1
)
Expand Down
4 changes: 1 addition & 3 deletions hosted/aks/support_matrix/support_matrix_importing_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package support_matrix_test

import (
"fmt"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"fmt"

management "github.com/rancher/rancher/tests/framework/clients/rancher/generated/management/v3"
"github.com/rancher/rancher/tests/framework/extensions/clusters"
"github.com/rancher/rancher/tests/framework/extensions/clusters/aks"
Expand All @@ -26,7 +25,6 @@ var _ = Describe("SupportMatrixImporting", func() {
When(fmt.Sprintf("a cluster is created with kubernetes version %s", version), func() {
var (
clusterName string
location = "eastus"
cluster *management.Cluster
)
BeforeEach(func() {
Expand Down
3 changes: 2 additions & 1 deletion hosted/aks/support_matrix/support_matrix_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import (
var (
availableVersionList []string
ctx helpers.Context
location = helpers.GetAKSLocation()
)

func TestSupportMatrix(t *testing.T) {
RegisterFailHandler(Fail)
var err error
ctx, err = helpers.CommonBeforeSuite("aks")
Expect(err).To(BeNil())
availableVersionList, err = helper.ListSingleVariantAKSAvailableVersions(ctx.RancherClient, ctx.CloudCred.ID, "eastus")
availableVersionList, err = helper.ListSingleVariantAKSAvailableVersions(ctx.RancherClient, ctx.CloudCred.ID, location)
Expect(err).To(BeNil())
RunSpecs(t, "SupportMatrix Suite")
}
5 changes: 4 additions & 1 deletion hosted/eks/p0/p0_importing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import (
)

var _ = Describe("P0Importing", func() {
var cluster *management.Cluster
var (
cluster *management.Cluster
region = helpers.GetEKSRegion()
)

When("a cluster is imported", func() {

Expand Down
2 changes: 0 additions & 2 deletions hosted/eks/p0/p0_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package p0_test

import (
"os"
"testing"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -13,7 +12,6 @@ import (
var (
ctx helpers.Context
clusterName string
region = os.Getenv("EKS_REGION")
k8sVersion = "1.26"
increaseBy = 1
)
Expand Down
3 changes: 0 additions & 3 deletions hosted/eks/support_matrix/support_matrix_importing_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package support_matrix_test

import (
"os"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

Expand All @@ -26,7 +24,6 @@ var _ = Describe("SupportMatrixImporting", func() {
When(fmt.Sprintf("a cluster is created with kubernetes version %s", version), func() {
var (
clusterName string
region = os.Getenv("EKS_REGION")
cluster *management.Cluster
)
BeforeEach(func() {
Expand Down
1 change: 1 addition & 0 deletions hosted/eks/support_matrix/support_matrix_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
var (
availableVersionList []string
ctx helpers.Context
region = helpers.GetEKSRegion()
)

func TestSupportMatrix(t *testing.T) {
Expand Down
11 changes: 4 additions & 7 deletions hosted/gke/p0/p0_importing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,23 @@ import (
"github.com/rancher/hosted-providers-e2e/hosted/helpers"
management "github.com/rancher/rancher/tests/framework/clients/rancher/generated/management/v3"
"github.com/rancher/rancher/tests/framework/extensions/clusters"
"github.com/rancher/rancher/tests/framework/extensions/clusters/gke"
nodestat "github.com/rancher/rancher/tests/framework/extensions/nodes"
"github.com/rancher/rancher/tests/framework/extensions/workloads/pods"
"github.com/rancher/rancher/tests/framework/pkg/config"
)

var _ = Describe("P0Importing", func() {
var (
zone = helpers.GetGKEZone()
)

When("a cluster is created", func() {
var cluster *management.Cluster

BeforeEach(func() {
var err error
err = helper.CreateGKEClusterOnGCloud(zone, clusterName, project, k8sVersion)
err = helper.CreateGKEClusterOnGCloud(zone, clusterName, helpers.GetGKEProjectID(), k8sVersion)
Expect(err).To(BeNil())

gkeConfig := new(helper.ImportClusterConfig)
config.LoadAndUpdateConfig(gke.GKEClusterConfigConfigurationFileKey, gkeConfig, func() {
gkeConfig.ProjectID = project
})
cluster, err = helper.ImportGKEHostedCluster(ctx.RancherClient, clusterName, ctx.CloudCred.ID, false, false, false, false, map[string]string{})
Expect(err).To(BeNil())
cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherClient)
Expand Down
11 changes: 2 additions & 9 deletions hosted/gke/p0/p0_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/rancher/hosted-providers-e2e/hosted/gke/helper"
"github.com/rancher/hosted-providers-e2e/hosted/helpers"
management "github.com/rancher/rancher/tests/framework/clients/rancher/generated/management/v3"
"github.com/rancher/rancher/tests/framework/extensions/clusters"
"github.com/rancher/rancher/tests/framework/extensions/clusters/gke"
nodestat "github.com/rancher/rancher/tests/framework/extensions/nodes"
"github.com/rancher/rancher/tests/framework/extensions/workloads/pods"
"github.com/rancher/rancher/tests/framework/pkg/config"

"github.com/rancher/hosted-providers-e2e/hosted/gke/helper"
"github.com/rancher/hosted-providers-e2e/hosted/helpers"
)

var _ = Describe("P0Provisioning", func() {
Expand All @@ -22,11 +20,6 @@ var _ = Describe("P0Provisioning", func() {

BeforeEach(func() {
var err error
gkeConfig := new(management.GKEClusterConfigSpec)
config.LoadAndUpdateConfig(gke.GKEClusterConfigConfigurationFileKey, gkeConfig, func() {
gkeConfig.ProjectID = project
})

cluster, err = gke.CreateGKEHostedCluster(ctx.RancherClient, clusterName, ctx.CloudCred.ID, false, false, false, false, map[string]string{})
Expect(err).To(BeNil())
cluster, err = helpers.WaitUntilClusterIsReady(cluster, ctx.RancherClient)
Expand Down
3 changes: 0 additions & 3 deletions hosted/gke/p0/p0_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package p0_test

import (
"os"
"testing"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -13,8 +12,6 @@ import (
var (
ctx helpers.Context
clusterName string
zone = "us-central1-c"
project = os.Getenv("GKE_PROJECT_ID")
k8sVersion = "1.27.4-gke.900"
increaseBy = 1
)
Expand Down
Loading

0 comments on commit 6837488

Please sign in to comment.