Skip to content

Commit 5e43d71

Browse files
authored
Merge pull request #17819 from upodroid/use-stable-with-tests
enable deploying a released version of kops
2 parents dc2c9ef + d29da84 commit 5e43d71

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

tests/e2e/kubetest2-kops/deployer/common.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,14 @@ func (d *deployer) verifyKopsFlags() error {
178178
klog.Infof("Using cluster name: %v", d.ClusterName)
179179
}
180180

181-
if d.KopsBinaryPath == "" && d.KopsVersionMarker == "" {
182-
return errors.New("missing required --kops-binary-path when --kops-version-marker is not used")
181+
if d.KopsBinaryPath == "" && d.KopsVersionMarker == "" && d.KopsVersion == "" {
182+
return errors.New("atleast one of --kops-binary-path, --kops-version-marker, --kops-version must be set")
183+
}
184+
if d.KopsVersionMarker != "" && d.KopsVersion != "" {
185+
return errors.New("you can't set kops-version-marker and kops-version at the same time")
186+
}
187+
if d.KopsBinaryPath != "" && (d.KopsVersion != "" || d.KopsVersionMarker != "") {
188+
return errors.New("you can't set kops-binary-path with kops-version-marker or kops-version at the same time")
183189
}
184190

185191
if d.ControlPlaneCount == 0 {
@@ -220,7 +226,8 @@ func (d *deployer) env() []string {
220226
}
221227
}
222228

223-
if d.CloudProvider == "aws" {
229+
switch d.CloudProvider {
230+
case "aws":
224231
// Pass through some env vars if set
225232
for _, k := range []string{"AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE", "AWS_CONTAINER_CREDENTIALS_FULL_URI", "AWS_PROFILE", "AWS_SHARED_CREDENTIALS_FILE"} {
226233
v := os.Getenv(k)
@@ -231,7 +238,7 @@ func (d *deployer) env() []string {
231238
// Recognized by the e2e framework
232239
// https://github.com/kubernetes/kubernetes/blob/a750d8054a6cb3167f495829ce3e77ab0ccca48e/test/e2e/framework/ssh/ssh.go#L59-L62
233240
vars = append(vars, fmt.Sprintf("KUBE_SSH_KEY_PATH=%v", d.SSHPrivateKeyPath))
234-
} else if d.CloudProvider == "azure" {
241+
case "azure":
235242
// Pass through some env vars if set
236243
for _, k := range []string{"AZURE_TENANT_ID", "AZURE_SUBSCRIPTION_ID", "AZURE_CLIENT_ID", "AZURE_FEDERATED_TOKEN_FILE", "AZURE_STORAGE_ACCOUNT"} {
237244
v := os.Getenv(k)
@@ -241,7 +248,7 @@ func (d *deployer) env() []string {
241248
klog.Warningf("Azure env var %q not found or empty", k)
242249
}
243250
}
244-
} else if d.CloudProvider == "digitalocean" {
251+
case "digitalocean":
245252
// Pass through some env vars if set
246253
for _, k := range []string{"DIGITALOCEAN_ACCESS_TOKEN", "S3_ACCESS_KEY_ID", "S3_SECRET_ACCESS_KEY"} {
247254
v := os.Getenv(k)
@@ -251,7 +258,7 @@ func (d *deployer) env() []string {
251258
klog.Warningf("DO env var %q not found or empty", k)
252259
}
253260
}
254-
} else if d.CloudProvider == "gce" {
261+
case "gce":
255262
if d.GCPProject != "" {
256263
vars = append(vars, fmt.Sprintf("GCP_PROJECT=%v", d.GCPProject))
257264
}

tests/e2e/kubetest2-kops/deployer/deployer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ type deployer struct {
5757
Env []string `flag:"env" desc:"Additional env vars to set for kops commands in NAME=VALUE format"`
5858
CreateArgs string `flag:"create-args" desc:"Extra space-separated arguments passed to 'kops create cluster'"`
5959
KopsBinaryPath string `flag:"kops-binary-path" desc:"The path to kops executable used for testing"`
60+
KopsVersion string `flag:"kops-version" desc:"The kops version to use in the cluster, must be a released version of kops"`
6061
KubernetesFeatureGates string `flag:"kubernetes-feature-gates" desc:"Feature Gates to enable on Kubernetes components"`
6162

6263
// ControlPlaneCount specifies the number of VMs in the control-plane.

tests/e2e/kubetest2-kops/deployer/up.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ func (d *deployer) Up() error {
5050

5151
// kops is fetched when --up is called instead of init to support a scenario where k/k is being built
5252
// and a kops build is not ready yet
53-
if d.KopsVersionMarker != "" {
53+
if d.KopsVersionMarker != "" || d.KopsVersion != "" {
5454
d.KopsBinaryPath = path.Join(d.commonOptions.RunDir(), "kops")
55-
baseURL, err := kops.DownloadKops(d.KopsVersionMarker, d.KopsBinaryPath)
55+
baseURL, err := kops.DownloadKops(d.KopsVersionMarker, d.KopsBinaryPath, d.KopsVersion)
5656
if err != nil {
5757
return fmt.Errorf("init failed to download kops from url: %v", err)
5858
}

tests/e2e/pkg/kops/download.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@ import (
2929
// DownloadKops will download the kops binary from the version marker URL
3030
// Returning the URL to use for KOPS_BASE_URL
3131
// Example markerURL: https://storage.googleapis.com/k8s-staging-kops/kops/releases/markers/master/latest-ci-updown-green.txt
32-
func DownloadKops(markerURL, downloadPath string) (string, error) {
32+
func DownloadKops(markerURL, downloadPath, kopsVersion string) (string, error) {
3333
var b bytes.Buffer
34-
if err := util.HTTPGETWithHeaders(markerURL, nil, &b); err != nil {
35-
return "", err
34+
var kopsBaseURL string
35+
if markerURL == "" && kopsVersion != "" {
36+
kopsBaseURL = fmt.Sprintf("https://artifacts.k8s.io/binaries/kops/%s", kopsVersion)
37+
}
38+
if markerURL != "" && kopsVersion == "" {
39+
if err := util.HTTPGETWithHeaders(markerURL, nil, &b); err != nil {
40+
return "", err
41+
}
42+
kopsBaseURL = strings.TrimSpace(b.String())
3643
}
37-
kopsBaseURL := strings.TrimSpace(b.String())
3844

3945
kopsFile, err := os.Create(downloadPath)
4046
if err != nil {

0 commit comments

Comments
 (0)