Skip to content
Open
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ test: $(SETUP_ENVTEST) ## Run unit and integration tests
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test ./... $(TEST_ARGS)

# Allow overriding the e2e configurations
GINKGO_FOCUS ?= Workload cluster creation
GINKGO_FOCUS ?= Workload cluster creation|GKE workload cluster creation
GINKGO_SKIP ?= API Version Upgrade
GINKGO_NODES ?= 1
GINKGO_NOCOLOR ?= false
Expand Down
3 changes: 3 additions & 0 deletions cloud/services/container/clusters/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
infrav1exp "sigs.k8s.io/cluster-api-provider-gcp/exp/api/v1beta1"
"sigs.k8s.io/cluster-api/util/kubeconfig"
"sigs.k8s.io/cluster-api/util/secret"
"sigs.k8s.io/controller-runtime/pkg/log"
)

const (
Expand Down Expand Up @@ -238,12 +239,14 @@
}

func (s *Service) generateToken(ctx context.Context) (string, error) {
log := log.FromContext(ctx)
req := &credentialspb.GenerateAccessTokenRequest{
Name: "projects/-/serviceAccounts/" + s.scope.GetCredential().ClientEmail,
Scope: []string{
GkeScope,
},
}
log.Info("DEBUG - Generating Token", "serviceAccount", req.Name, "scopes", req.Scope)

Check failure on line 249 in cloud/services/container/clusters/kubeconfig.go

View workflow job for this annotation

GitHub Actions / lint

avoid direct access to proto field req.Name, use req.GetName() instead (protogetter)
resp, err := s.scope.CredentialsClient().GenerateAccessToken(ctx, req)
if err != nil {
return "", errors.Errorf("error generating access token: %v", err)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/config/gcp-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ providers:
variables:
KUBERNETES_VERSION: "v1.32.5"
KUBERNETES_VERSION_MANAGEMENT: "v1.32.5"
KUBERNETES_VERSION_GKE: "v1.32.6"
ETCD_VERSION_UPGRADE_TO: "3.5.16-0"
COREDNS_VERSION_UPGRADE_TO: "v1.11.3"
KUBERNETES_IMAGE_UPGRADE_FROM: "projects/k8s-staging-cluster-api-gcp/global/images/cluster-api-ubuntu-2204-v1-32-5-nightly"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ metadata:
spec:
project: "${GCP_PROJECT}"
location: "${GCP_REGION}"
version: "${KUBERNETES_VERSION}"
version: "${KUBERNETES_VERSION_GKE}"
releaseChannel: "regular"
---
apiVersion: cluster.x-k8s.io/v1beta1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ spec:
extraArgs:
cloud-provider: external
allocate-node-cidrs: "false"
kubernetesVersion: "${KUBERNETES_VERSION}"
kubernetesVersion: "${KUBERNETES_VERSION_GKE}"
files:
- content: |
[Global]
Expand Down
20 changes: 12 additions & 8 deletions test/e2e/e2e_gke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ const (
var _ = Describe("GKE workload cluster creation", func() {
var (
ctx = context.TODO()
specName = "create-gke-workload-cluster"
specName = "gke"
namespace *corev1.Namespace
cancelWatches context.CancelFunc
result *ApplyManagedClusterTemplateAndWaitResult
clusterName string
clusterNamePrefix string
clusterctlLogFolder string
)

Expand All @@ -55,9 +55,9 @@ var _ = Describe("GKE workload cluster creation", func() {
Expect(bootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. bootstrapClusterProxy can't be nil when calling %s spec", specName)
Expect(os.MkdirAll(artifactFolder, 0o755)).To(Succeed(), "Invalid argument. artifactFolder can't be created for %s spec", specName)

Expect(e2eConfig.Variables).To(HaveKey(KubernetesVersion))
Expect(e2eConfig.Variables).To(HaveKey(KubernetesVersionGKE))

clusterName = fmt.Sprintf("capg-e2e-%s", util.RandomString(6))
clusterNamePrefix = fmt.Sprintf("%s-%s", specName, util.RandomString(6))

// Setup a Namespace where to host objects for this spec and create a watcher for the namespace events.
namespace, cancelWatches = setupSpecNamespace(ctx, specName, bootstrapClusterProxy, artifactFolder)
Expand Down Expand Up @@ -86,6 +86,7 @@ var _ = Describe("GKE workload cluster creation", func() {

Context("Creating a GKE cluster without autopilot", func() {
It("Should create a cluster with 1 machine pool and scale", func() {
clusterName := fmt.Sprintf("%s-single", clusterNamePrefix)
By("Initializes with 1 machine pool")

minPoolSize, ok := e2eConfig.Variables["GKE_MACHINE_POOL_MIN"]
Expand All @@ -107,7 +108,7 @@ var _ = Describe("GKE workload cluster creation", func() {
Flavor: "ci-gke",
Namespace: namespace.Name,
ClusterName: clusterName,
KubernetesVersion: e2eConfig.MustGetVariable(KubernetesVersion),
KubernetesVersion: e2eConfig.MustGetVariable(KubernetesVersionGKE),
ControlPlaneMachineCount: ptr.To[int64](1),
WorkerMachineCount: ptr.To[int64](3),
ClusterctlVariables: map[string]string{
Expand Down Expand Up @@ -144,6 +145,7 @@ var _ = Describe("GKE workload cluster creation", func() {

Context("Creating a GKE cluster with autopilot", func() {
It("Should create a cluster with 1 machine pool and scale", func() {
clusterName := fmt.Sprintf("%s-ap", clusterNamePrefix)
By("Initializes with 1 machine pool")

ApplyManagedClusterTemplateAndWait(ctx, ApplyManagedClusterTemplateAndWaitInput{
Expand All @@ -156,7 +158,7 @@ var _ = Describe("GKE workload cluster creation", func() {
Flavor: "ci-gke-autopilot",
Namespace: namespace.Name,
ClusterName: clusterName,
KubernetesVersion: e2eConfig.MustGetVariable(KubernetesVersion),
KubernetesVersion: e2eConfig.MustGetVariable(KubernetesVersionGKE),
ControlPlaneMachineCount: ptr.To[int64](1),
WorkerMachineCount: ptr.To[int64](0),
},
Expand All @@ -169,6 +171,7 @@ var _ = Describe("GKE workload cluster creation", func() {

Context("Creating a GKE cluster with custom subnet", func() {
It("Should create a cluster with 3 machine pool and custom subnet", func() {
clusterName := fmt.Sprintf("%s-cust-snet", clusterNamePrefix)
By("Initializes with 3 machine pool")

ApplyManagedClusterTemplateAndWait(ctx, ApplyManagedClusterTemplateAndWaitInput{
Expand All @@ -181,7 +184,7 @@ var _ = Describe("GKE workload cluster creation", func() {
Flavor: "ci-gke-custom-subnet",
Namespace: namespace.Name,
ClusterName: clusterName,
KubernetesVersion: e2eConfig.MustGetVariable(KubernetesVersion),
KubernetesVersion: e2eConfig.MustGetVariable(KubernetesVersionGKE),
ControlPlaneMachineCount: ptr.To[int64](1),
WorkerMachineCount: ptr.To[int64](3),
ClusterctlVariables: map[string]string{
Expand All @@ -198,6 +201,7 @@ var _ = Describe("GKE workload cluster creation", func() {

Context("Creating a GKE cluster with autopilot from a cluster class", func() {
It("Should create a cluster class and a cluster from it", func() {
clusterName := fmt.Sprintf("%s-cc", clusterNamePrefix)
By("Initializes a managed control plane and managed cluster")

ApplyManagedClusterTemplateAndWait(ctx, ApplyManagedClusterTemplateAndWaitInput{
Expand All @@ -210,7 +214,7 @@ var _ = Describe("GKE workload cluster creation", func() {
Flavor: "ci-gke-autopilot-topology",
Namespace: namespace.Name,
ClusterName: clusterName,
KubernetesVersion: e2eConfig.MustGetVariable(KubernetesVersion),
KubernetesVersion: e2eConfig.MustGetVariable(KubernetesVersionGKE),
ControlPlaneMachineCount: ptr.To[int64](1),
WorkerMachineCount: ptr.To[int64](0),
},
Expand Down
1 change: 1 addition & 0 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
const (
KubernetesVersion = "KUBERNETES_VERSION"
KubernetesVersionManagement = "KUBERNETES_VERSION_MANAGEMENT"
KubernetesVersionGKE = "KUBERNETES_VERSION_GKE"

CNIPath = "CNI"
CNIResources = "CNI_RESOURCES"
Expand Down
Loading