From 39537d71904479832c96fb6dfe15526b8a6eea41 Mon Sep 17 00:00:00 2001 From: Peter Rifel Date: Mon, 25 Jan 2021 17:48:54 -0600 Subject: [PATCH 1/2] Add --create-args kubetest2 flag This allows us to customize the images, instance types, etc. kubetest (1) named this --kops-args, I think --create-args is more appropriate because its only passed to `create cluster` --- tests/e2e/kubetest2-kops/deployer/deployer.go | 1 + tests/e2e/kubetest2-kops/deployer/up.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/tests/e2e/kubetest2-kops/deployer/deployer.go b/tests/e2e/kubetest2-kops/deployer/deployer.go index a5e3f68a33..92ab1a1009 100644 --- a/tests/e2e/kubetest2-kops/deployer/deployer.go +++ b/tests/e2e/kubetest2-kops/deployer/deployer.go @@ -47,6 +47,7 @@ type deployer struct { ClusterName string `flag:"cluster-name" desc:"The FQDN to use for the cluster name"` CloudProvider string `flag:"cloud-provider" desc:"Which cloud provider to use"` Env []string `flag:"env" desc:"Additional env vars to set for kops commands in NAME=VALUE format"` + CreateArgs string `flag:"create-args" desc:"Extra space-separated arguments passed to 'kops create cluster'"` KopsBinaryPath string `flag:"kops-binary-path" desc:"The path to kops executable used for testing"` Networking string `flag:"networking" desc:"The networking mode to use"` StateStore string `flag:"-"` diff --git a/tests/e2e/kubetest2-kops/deployer/up.go b/tests/e2e/kubetest2-kops/deployer/up.go index 3c7aa1ad9b..a34ffcf9f2 100644 --- a/tests/e2e/kubetest2-kops/deployer/up.go +++ b/tests/e2e/kubetest2-kops/deployer/up.go @@ -129,6 +129,12 @@ func (d *deployer) createCluster(zones []string, adminAccess string) error { args = append(args, "--networking", d.Networking) } + if d.CreateArgs != "" { + // TODO: we should only set the above flags if they're not in CreateArgs + // allowing any flag to be overridden + args = append(args, strings.Split(d.CreateArgs, " ")...) + } + klog.Info(strings.Join(args, " ")) cmd := exec.Command(args[0], args[1:]...) cmd.SetEnv(d.env()...) From cf12fe4efdba73616d1c45bee11d9bd7eaeb3393 Mon Sep 17 00:00:00 2001 From: Peter Rifel Date: Mon, 25 Jan 2021 21:50:30 -0600 Subject: [PATCH 2/2] Support additional feature flags specified via --env=KOPS_FEATURE_FLAGS=foo --- tests/e2e/kubetest2-kops/deployer/common.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/e2e/kubetest2-kops/deployer/common.go b/tests/e2e/kubetest2-kops/deployer/common.go index 9659403ec4..32ba262b17 100644 --- a/tests/e2e/kubetest2-kops/deployer/common.go +++ b/tests/e2e/kubetest2-kops/deployer/common.go @@ -138,7 +138,14 @@ func (d *deployer) featureFlags() string { "+SpecOverrideFlag", "+AlphaAllowGCE", } - return strings.Join(ff, ",") + val := strings.Join(ff, ",") + for _, env := range d.Env { + e := strings.Split(env, "=") + if e[0] == "KOPS_FEATURE_FLAGS" && len(e) > 1 { + val = fmt.Sprintf("%v,", e[1]) + } + } + return val } // defaultClusterName returns a kops cluster name to use when ClusterName is not set