Sitelet https://github.com/kubernetes/kops/pull/18102/files
Skip to content
Merged
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
22 changes: 22 additions & 0 deletions tests/e2e/csi-manifests/manifests.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright 2026 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package csimanifests

import "embed"

//go:embed aws-ebs/* gcp-pd/*
var FS embed.FS
55 changes: 43 additions & 12 deletions tests/e2e/pkg/tester/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"

Expand All @@ -29,6 +30,7 @@ import (
"k8s.io/klog/v2"
unversioned "k8s.io/kops/pkg/apis/kops"
api "k8s.io/kops/pkg/apis/kops/v1alpha2"
csimanifests "k8s.io/kops/tests/e2e/csi-manifests"
"k8s.io/kops/tests/e2e/pkg/kops"
"k8s.io/kops/upup/pkg/fi/cloudup/gce"
"sigs.k8s.io/kubetest2/pkg/artifacts"
Expand Down Expand Up @@ -421,31 +423,60 @@ func (t *Tester) addCSIDriverFlags() error {
return err
}

var driverFlags string
var provider, migratedPlugin string
if cluster.Spec.CloudConfig != nil {
cwd, err := os.Getwd()
if err != nil {
return err
}

switch {
case cluster.Spec.CloudConfig.AWSEBSCSIDriver != nil &&
cluster.Spec.CloudConfig.AWSEBSCSIDriver.Enabled != nil &&
*cluster.Spec.CloudConfig.AWSEBSCSIDriver.Enabled:
driverFlags = fmt.Sprintf(" --storage.testdriver=%s/tests/e2e/csi-manifests/aws-ebs/driver.yaml --storage.migratedPlugins=kubernetes.io/aws-ebs", cwd)
provider = "aws-ebs"
migratedPlugin = "kubernetes.io/aws-ebs"
case cluster.Spec.CloudConfig.GCPPDCSIDriver != nil &&
cluster.Spec.CloudConfig.GCPPDCSIDriver.Enabled != nil &&
*cluster.Spec.CloudConfig.GCPPDCSIDriver.Enabled:
driverFlags = fmt.Sprintf(" --storage.testdriver=%s/tests/e2e/csi-manifests/gcp-pd/driver.yaml --storage.migratedPlugins=kubernetes.io/gce-pd", cwd)
provider = "gcp-pd"
migratedPlugin = "kubernetes.io/gce-pd"
}
}

if driverFlags != "" {
klog.Infof("Setting %v", driverFlags)
t.TestArgs += driverFlags
} else {
if provider == "" {
klog.Info("CSI driver not enabled. Skipping tests")
return nil
}

tmpDir, err := os.MkdirTemp("", "csi-manifests-*")
if err != nil {
return fmt.Errorf("creating temp dir for CSI manifests: %w", err)
}

scData, err := csimanifests.FS.ReadFile(provider + "/sc.yaml")
if err != nil {
return fmt.Errorf("reading embedded %s/sc.yaml: %w", provider, err)
}
scPath := filepath.Join(tmpDir, "sc.yaml")
if err := os.WriteFile(scPath, scData, 0644); err != nil {
return fmt.Errorf("writing sc.yaml: %w", err)
}

driverData, err := csimanifests.FS.ReadFile(provider + "/driver.yaml")
if err != nil {
return fmt.Errorf("reading embedded %s/driver.yaml: %w", provider, err)
}
// Rewrite the FromFile path to point to the temp dir copy of sc.yaml
driverContent := strings.Replace(
string(driverData),
"tests/e2e/csi-manifests/"+provider+"/sc.yaml",
scPath,
1,
)
driverPath := filepath.Join(tmpDir, "driver.yaml")
if err := os.WriteFile(driverPath, []byte(driverContent), 0644); err != nil {
return fmt.Errorf("writing driver.yaml: %w", err)
}

driverFlags := fmt.Sprintf(" --storage.testdriver=%s --storage.migratedPlugins=%s", driverPath, migratedPlugin)
klog.Infof("Setting %v", driverFlags)
t.TestArgs += driverFlags
return nil
}

Expand Down
Loading