From 04d3ece41c42f9f14946e6d9d0f5585c33f2f7ab Mon Sep 17 00:00:00 2001 From: David Porter Date: Wed, 3 Nov 2021 17:08:30 -0700 Subject: [PATCH 1/2] gke: Avoid hardcoding COS as default image type The default image type in GKE as of 1.19 is COS_CONTAINERD. kubetest2 gke deployer should avoid hardcoding the image and instead rely on the default unless image is specified. Signed-off-by: David Porter --- kubetest2-gke/deployer/deployer.go | 2 -- kubetest2-gke/deployer/up.go | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kubetest2-gke/deployer/deployer.go b/kubetest2-gke/deployer/deployer.go index 698d8f5c..3f9b5984 100644 --- a/kubetest2-gke/deployer/deployer.go +++ b/kubetest2-gke/deployer/deployer.go @@ -42,7 +42,6 @@ var GitTag string const ( defaultFirewallRuleAllow = "tcp:22,tcp:80,tcp:8080,tcp:30000-32767,udp:30000-32767" - defaultImage = "cos" defaultWindowsImage = WindowsImageTypeLTSC ) @@ -197,7 +196,6 @@ func NewDeployer(opts types.Options) *Deployer { NumClusters: 1, NumNodes: defaultNodePool.Nodes, MachineType: defaultNodePool.MachineType, - ImageType: defaultImage, // Leave ClusterVersion as empty to use the default cluster version. ClusterVersion: "", FirewallRuleAllow: defaultFirewallRuleAllow, diff --git a/kubetest2-gke/deployer/up.go b/kubetest2-gke/deployer/up.go index 5e81a1f0..6c571539 100644 --- a/kubetest2-gke/deployer/up.go +++ b/kubetest2-gke/deployer/up.go @@ -158,7 +158,9 @@ func (d *Deployer) CreateCluster(project string, cluster cluster, subNetworkArgs if !d.Autopilot { args = append(args, "--machine-type="+d.MachineType) args = append(args, "--num-nodes="+strconv.Itoa(d.NumNodes)) - args = append(args, "--image-type="+d.ImageType) + if d.ImageType != "" { + args = append(args, "--image-type="+d.ImageType) + } if d.WorkloadIdentityEnabled { args = append(args, fmt.Sprintf("--workload-pool=%s.svc.id.goog", project)) } From b93d2a7c0c645b7ef97306bbd83768da362e34f8 Mon Sep 17 00:00:00 2001 From: David Porter Date: Wed, 3 Nov 2021 17:22:02 -0700 Subject: [PATCH 2/2] gke: Remove windows image defaulting Avoid hardcoding the default windows image, only provide the image if it's specified. Signed-off-by: David Porter --- kubetest2-gke/deployer/deployer.go | 2 -- kubetest2-gke/deployer/up.go | 12 +++--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/kubetest2-gke/deployer/deployer.go b/kubetest2-gke/deployer/deployer.go index 3f9b5984..afefeb96 100644 --- a/kubetest2-gke/deployer/deployer.go +++ b/kubetest2-gke/deployer/deployer.go @@ -42,7 +42,6 @@ var GitTag string const ( defaultFirewallRuleAllow = "tcp:22,tcp:80,tcp:8080,tcp:30000-32767,udp:30000-32767" - defaultWindowsImage = WindowsImageTypeLTSC ) const ( @@ -202,7 +201,6 @@ func NewDeployer(opts types.Options) *Deployer { WindowsNumNodes: defaultWindowsNodePool.Nodes, WindowsMachineType: defaultWindowsNodePool.MachineType, - WindowsImageType: defaultWindowsImage, RetryableErrorPatterns: []string{gceStockoutErrorPattern}, }, diff --git a/kubetest2-gke/deployer/up.go b/kubetest2-gke/deployer/up.go index 6c571539..07907122 100644 --- a/kubetest2-gke/deployer/up.go +++ b/kubetest2-gke/deployer/up.go @@ -33,14 +33,6 @@ import ( "sigs.k8s.io/kubetest2/pkg/metadata" ) -const ( - // WindowsImageTypeLTSC is a gcloud --image-type option for Windows LTSC image - WindowsImageTypeLTSC = "WINDOWS_LTSC" - - // WindowsImageTypeSAC is a gcloud --image-type opotion for Windows SAC image - WindowsImageTypeSAC = "WINDOWS_SAC" -) - // Deployer implementation methods below func (d *Deployer) Up() error { if err := d.Init(); err != nil { @@ -236,7 +228,9 @@ func (d *Deployer) createWindowsNodePoolCommand(project string, cluster cluster, fs = append(fs, "--cluster="+cluster.name) fs = append(fs, "--project="+project) fs = append(fs, locationArg) - fs = append(fs, "--image-type="+imageType) + if imageType != "" { + fs = append(fs, "--image-type="+imageType) + } fs = append(fs, "--machine-type="+d.WindowsMachineType) fs = append(fs, "--num-nodes="+strconv.Itoa(d.WindowsNumNodes))