Add cephcsi namespace and rook namespace flag

Added namespace flag to cephcsi to deploy cephcsi
resouces in different namespace.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2020-02-25 17:15:54 +05:30 committed by mergify[bot]
parent 59fe8c1f2f
commit c45c426215
7 changed files with 144 additions and 81 deletions

View File

@ -70,12 +70,16 @@ $./minikube.sh clean
In addition to standard go tests parameters, the following custom parameters In addition to standard go tests parameters, the following custom parameters
are available while running tests: are available while running tests:
| flag | description | | flag | description |
| -------------- | ----------------------------------------------------------------------------- | | ----------------- | ----------------------------------------------------------------------------- |
| deploy-timeout | Timeout to wait for created kubernetes resources (default: 10) | | deploy-timeout | Timeout to wait for created kubernetes resources (default: 10) |
| kubeconfig | Path to kubeconfig containing embedded authinfo (default: $HOME/.kube/config) | | deploy-cephfs | Deploy cephfs csi driver as part of E2E (default: true) |
| timeout | Panic test binary after duration d (default 0, timeout disabled) | | deploy-rbd | Deploy rbd csi driver as part of E2E (default: true) |
| v | Verbose: print additional output | | cephcsi-namespace | The namespace in which cephcsi driver will be created (default: "default") |
| rook-namespace | The namespace in which rook operator is installed (default: "rook-ceph") |
| kubeconfig | Path to kubeconfig containing embedded authinfo (default: $HOME/.kube/config) |
| timeout | Panic test binary after duration d (default 0, timeout disabled) |
| v | Verbose: print additional output |
## Running E2E ## Running E2E

View File

@ -2,9 +2,13 @@ package e2e
import ( import (
"fmt" "fmt"
"time"
. "github.com/onsi/ginkgo" // nolint . "github.com/onsi/ginkgo" // nolint
v1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
e2elog "k8s.io/kubernetes/test/e2e/framework/log" e2elog "k8s.io/kubernetes/test/e2e/framework/log"
@ -25,40 +29,40 @@ var (
func deployCephfsPlugin() { func deployCephfsPlugin() {
// delete objects deployed by rook // delete objects deployed by rook
framework.RunKubectlOrDie("delete", "--ignore-not-found=true", "-f", cephfsDirPath+cephfsProvisionerRBAC) framework.RunKubectlOrDie("delete", "--ignore-not-found=true", "-f", cephfsDirPath+cephfsProvisionerRBAC, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("delete", "--ignore-not-found=true", "-f", cephfsDirPath+cephfsNodePluginRBAC) framework.RunKubectlOrDie("delete", "--ignore-not-found=true", "-f", cephfsDirPath+cephfsNodePluginRBAC, fmt.Sprintf("--namespace=%s", cephCSINamespace))
// deploy provisioner // deploy provisioner
framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsProvisioner) framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsProvisioner, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsProvisionerRBAC) framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsProvisionerRBAC, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsProvisionerPSP) framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsProvisionerPSP, fmt.Sprintf("--namespace=%s", cephCSINamespace))
// deploy nodeplugin // deploy nodeplugin
framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsNodePlugin) framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsNodePlugin, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsNodePluginRBAC) framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsNodePluginRBAC, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsNodePluginPSP) framework.RunKubectlOrDie("create", "-f", cephfsDirPath+cephfsNodePluginPSP, fmt.Sprintf("--namespace=%s", cephCSINamespace))
} }
func deleteCephfsPlugin() { func deleteCephfsPlugin() {
_, err := framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisioner) _, err := framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisioner, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete cephfs provisioner %v", err) e2elog.Logf("failed to delete cephfs provisioner %v", err)
} }
_, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisionerRBAC) _, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisionerRBAC, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete cephfs provisioner rbac %v", err) e2elog.Logf("failed to delete cephfs provisioner rbac %v", err)
} }
_, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisionerPSP) _, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsProvisionerPSP, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete cephfs provisioner psp %v", err) e2elog.Logf("failed to delete cephfs provisioner psp %v", err)
} }
_, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsNodePlugin) _, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsNodePlugin, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete cephfs nodeplugin %v", err) e2elog.Logf("failed to delete cephfs nodeplugin %v", err)
} }
_, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsNodePluginRBAC) _, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsNodePluginRBAC, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete cephfs nodeplugin rbac %v", err) e2elog.Logf("failed to delete cephfs nodeplugin rbac %v", err)
} }
_, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsNodePluginPSP) _, err = framework.RunKubectl("delete", "-f", cephfsDirPath+cephfsNodePluginPSP, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete cephfs nodeplugin psp %v", err) e2elog.Logf("failed to delete cephfs nodeplugin psp %v", err)
} }
@ -72,6 +76,19 @@ var _ = Describe("cephfs", func() {
c = f.ClientSet c = f.ClientSet
createConfigMap(cephfsDirPath, f.ClientSet, f) createConfigMap(cephfsDirPath, f.ClientSet, f)
if deployCephFS { if deployCephFS {
if cephCSINamespace != defaultNs {
// create namespace
ns := &v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: cephCSINamespace,
},
}
_, err := c.CoreV1().Namespaces().Create(ns)
if err != nil && !apierrs.IsAlreadyExists(err) {
Fail(err.Error())
}
}
deployCephfsPlugin() deployCephfsPlugin()
} }
createCephfsSecret(f.ClientSet, f) createCephfsSecret(f.ClientSet, f)
@ -84,12 +101,22 @@ var _ = Describe("cephfs", func() {
// log node plugin // log node plugin
logsCSIPods("app=csi-cephfsplugin", c) logsCSIPods("app=csi-cephfsplugin", c)
} }
if deployCephFS {
deleteCephfsPlugin()
}
deleteConfigMap(cephfsDirPath) deleteConfigMap(cephfsDirPath)
deleteResource(cephfsExamplePath + "secret.yaml") deleteResource(cephfsExamplePath + "secret.yaml")
deleteResource(cephfsExamplePath + "storageclass.yaml") deleteResource(cephfsExamplePath + "storageclass.yaml")
if deployCephFS {
deleteCephfsPlugin()
if cephCSINamespace != defaultNs {
err := c.CoreV1().Namespaces().Delete(cephCSINamespace, nil)
if err != nil && !apierrs.IsNotFound(err) {
Fail(err.Error())
}
err = framework.WaitForNamespacesDeleted(c, []string{cephCSINamespace}, time.Duration(deployTimeout)*time.Minute)
if err != nil {
Fail(err.Error())
}
}
}
}) })
Context("Test cephfs CSI", func() { Context("Test cephfs CSI", func() {
@ -99,13 +126,13 @@ var _ = Describe("cephfs", func() {
By("checking provisioner deployment is running") By("checking provisioner deployment is running")
var err error var err error
err = waitForDeploymentComplete(cephfsDeploymentName, namespace, f.ClientSet, deployTimeout) err = waitForDeploymentComplete(cephfsDeploymentName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil { if err != nil {
Fail(err.Error()) Fail(err.Error())
} }
By("checking nodeplugin deamonsets is running") By("checking nodeplugin deamonsets is running")
err = waitForDaemonSets(cephfsDeamonSetName, namespace, f.ClientSet, deployTimeout) err = waitForDaemonSets(cephfsDeamonSetName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil { if err != nil {
Fail(err.Error()) Fail(err.Error())
} }

View File

@ -1,6 +1,8 @@
package e2e package e2e
import ( import (
"fmt"
. "github.com/onsi/gomega" // nolint . "github.com/onsi/gomega" // nolint
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
@ -17,37 +19,37 @@ var (
) )
func deployVault(c kubernetes.Interface, deployTimeout int) { func deployVault(c kubernetes.Interface, deployTimeout int) {
framework.RunKubectlOrDie("create", "-f", vaultExamplePath+vaultServicePath) framework.RunKubectlOrDie("create", "-f", vaultExamplePath+vaultServicePath, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("create", "-f", vaultExamplePath+vaultPSPPath) framework.RunKubectlOrDie("create", "-f", vaultExamplePath+vaultPSPPath, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("create", "-f", vaultExamplePath+vaultRBACPath) framework.RunKubectlOrDie("create", "-f", vaultExamplePath+vaultRBACPath, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("create", "-f", vaultExamplePath+vaultConfigPath) framework.RunKubectlOrDie("create", "-f", vaultExamplePath+vaultConfigPath, fmt.Sprintf("--namespace=%s", cephCSINamespace))
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=vault", LabelSelector: "app=vault",
} }
pods, err := c.CoreV1().Pods("default").List(opt) pods, err := c.CoreV1().Pods(cephCSINamespace).List(opt)
Expect(err).Should(BeNil()) Expect(err).Should(BeNil())
Expect(len(pods.Items)).Should(Equal(1)) Expect(len(pods.Items)).Should(Equal(1))
name := pods.Items[0].Name name := pods.Items[0].Name
err = waitForPodInRunningState(name, "default", c, deployTimeout) err = waitForPodInRunningState(name, cephCSINamespace, c, deployTimeout)
Expect(err).Should(BeNil()) Expect(err).Should(BeNil())
} }
func deleteVault() { func deleteVault() {
_, err := framework.RunKubectl("delete", "-f", vaultExamplePath+vaultServicePath) _, err := framework.RunKubectl("delete", "-f", vaultExamplePath+vaultServicePath, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete vault statefull set %v", err) e2elog.Logf("failed to delete vault statefull set %v", err)
} }
_, err = framework.RunKubectl("delete", "-f", vaultExamplePath+vaultRBACPath) _, err = framework.RunKubectl("delete", "-f", vaultExamplePath+vaultRBACPath, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete vault statefull set %v", err) e2elog.Logf("failed to delete vault statefull set %v", err)
} }
_, err = framework.RunKubectl("delete", "-f", vaultExamplePath+vaultConfigPath) _, err = framework.RunKubectl("delete", "-f", vaultExamplePath+vaultConfigPath, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete vault config map %v", err) e2elog.Logf("failed to delete vault config map %v", err)
} }
_, err = framework.RunKubectl("delete", "-f", vaultExamplePath+vaultPSPPath) _, err = framework.RunKubectl("delete", "-f", vaultExamplePath+vaultPSPPath, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete vault psp %v", err) e2elog.Logf("failed to delete vault psp %v", err)
} }

View File

@ -15,9 +15,11 @@ import (
) )
var ( var (
deployTimeout int deployTimeout int
deployCephFS bool deployCephFS bool
deployRBD bool deployRBD bool
cephCSINamespace string
rookNamespace string
) )
func init() { func init() {
@ -26,7 +28,8 @@ func init() {
flag.IntVar(&deployTimeout, "deploy-timeout", 10, "timeout to wait for created kubernetes resources") flag.IntVar(&deployTimeout, "deploy-timeout", 10, "timeout to wait for created kubernetes resources")
flag.BoolVar(&deployCephFS, "deploy-cephfs", true, "deploy cephfs csi driver") flag.BoolVar(&deployCephFS, "deploy-cephfs", true, "deploy cephfs csi driver")
flag.BoolVar(&deployRBD, "deploy-rbd", true, "deploy rbd csi driver") flag.BoolVar(&deployRBD, "deploy-rbd", true, "deploy rbd csi driver")
flag.StringVar(&cephCSINamespace, "cephcsi-namespace", defaultNs, "namespace in which cephcsi deployed")
flag.StringVar(&rookNamespace, "rook-namespace", "rook-ceph", "namespace in which rook is deployed")
setDefaultKubeconfig() setDefaultKubeconfig()
// Register framework flags, then handle flags // Register framework flags, then handle flags

View File

@ -3,9 +3,13 @@ package e2e
import ( import (
"fmt" "fmt"
"strings" "strings"
"time"
. "github.com/onsi/ginkgo" // nolint . "github.com/onsi/ginkgo" // nolint
v1 "k8s.io/api/core/v1"
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes" clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/test/e2e/framework" "k8s.io/kubernetes/test/e2e/framework"
e2elog "k8s.io/kubernetes/test/e2e/framework/log" e2elog "k8s.io/kubernetes/test/e2e/framework/log"
@ -23,29 +27,28 @@ var (
rbdExamplePath = "../examples/rbd/" rbdExamplePath = "../examples/rbd/"
rbdDeploymentName = "csi-rbdplugin-provisioner" rbdDeploymentName = "csi-rbdplugin-provisioner"
rbdDaemonsetName = "csi-rbdplugin" rbdDaemonsetName = "csi-rbdplugin"
namespace = "default"
) )
func deployRBDPlugin() { func deployRBDPlugin() {
// delete objects deployed by rook // delete objects deployed by rook
framework.RunKubectlOrDie("delete", "--ignore-not-found=true", "-f", rbdDirPath+rbdProvisionerRBAC) framework.RunKubectlOrDie("delete", "--ignore-not-found=true", "-f", rbdDirPath+rbdProvisionerRBAC, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("delete", "--ignore-not-found=true", "-f", rbdDirPath+rbdNodePluginRBAC) framework.RunKubectlOrDie("delete", "--ignore-not-found=true", "-f", rbdDirPath+rbdNodePluginRBAC, fmt.Sprintf("--namespace=%s", cephCSINamespace))
// deploy provisioner // deploy provisioner
framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdProvisioner) framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdProvisioner, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdProvisionerRBAC) framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdProvisionerRBAC, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdProvisionerPSP) framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdProvisionerPSP, fmt.Sprintf("--namespace=%s", cephCSINamespace))
// deploy nodeplugin // deploy nodeplugin
framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdNodePlugin) framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdNodePlugin, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdNodePluginRBAC) framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdNodePluginRBAC, fmt.Sprintf("--namespace=%s", cephCSINamespace))
framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdNodePluginPSP) framework.RunKubectlOrDie("create", "-f", rbdDirPath+rbdNodePluginPSP, fmt.Sprintf("--namespace=%s", cephCSINamespace))
} }
func deleteRBDPlugin() { func deleteRBDPlugin() {
_, err := framework.RunKubectl("delete", "-f", rbdDirPath+rbdProvisioner) _, err := framework.RunKubectl("delete", "-f", rbdDirPath+rbdProvisioner, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete rbd provisioner %v", err) e2elog.Logf("failed to delete rbd provisioner %v", err)
} }
_, err = framework.RunKubectl("delete", "-f", rbdDirPath+rbdProvisionerRBAC) _, err = framework.RunKubectl("delete", "-f", rbdDirPath+rbdProvisionerRBAC, fmt.Sprintf("--namespace=%s", cephCSINamespace), fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete provisioner rbac %v", err) e2elog.Logf("failed to delete provisioner rbac %v", err)
} }
@ -53,15 +56,15 @@ func deleteRBDPlugin() {
if err != nil { if err != nil {
e2elog.Logf("failed to delete provisioner psp %v", err) e2elog.Logf("failed to delete provisioner psp %v", err)
} }
_, err = framework.RunKubectl("delete", "-f", rbdDirPath+rbdNodePlugin) _, err = framework.RunKubectl("delete", "-f", rbdDirPath+rbdNodePlugin, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete nodeplugin %v", err) e2elog.Logf("failed to delete nodeplugin %v", err)
} }
_, err = framework.RunKubectl("delete", "-f", rbdDirPath+rbdNodePluginRBAC) _, err = framework.RunKubectl("delete", "-f", rbdDirPath+rbdNodePluginRBAC, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete nodeplugin rbac %v", err) e2elog.Logf("failed to delete nodeplugin rbac %v", err)
} }
_, err = framework.RunKubectl("delete", "-f", rbdDirPath+rbdNodePluginPSP) _, err = framework.RunKubectl("delete", "-f", rbdDirPath+rbdNodePluginPSP, fmt.Sprintf("--namespace=%s", cephCSINamespace))
if err != nil { if err != nil {
e2elog.Logf("failed to delete nodeplugin psp %v", err) e2elog.Logf("failed to delete nodeplugin psp %v", err)
} }
@ -75,6 +78,17 @@ var _ = Describe("RBD", func() {
c = f.ClientSet c = f.ClientSet
createConfigMap(rbdDirPath, f.ClientSet, f) createConfigMap(rbdDirPath, f.ClientSet, f)
if deployRBD { if deployRBD {
if cephCSINamespace != defaultNs {
ns := &v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: cephCSINamespace,
},
}
_, err := c.CoreV1().Namespaces().Create(ns)
if err != nil && !apierrs.IsAlreadyExists(err) {
Fail(err.Error())
}
}
deployRBDPlugin() deployRBDPlugin()
} }
createRBDStorageClass(f.ClientSet, f, make(map[string]string)) createRBDStorageClass(f.ClientSet, f, make(map[string]string))
@ -89,14 +103,25 @@ var _ = Describe("RBD", func() {
// log node plugin // log node plugin
logsCSIPods("app=csi-rbdplugin", c) logsCSIPods("app=csi-rbdplugin", c)
} }
if deployRBD {
deleteRBDPlugin()
}
deleteConfigMap(rbdDirPath) deleteConfigMap(rbdDirPath)
deleteResource(rbdExamplePath + "secret.yaml") deleteResource(rbdExamplePath + "secret.yaml")
deleteResource(rbdExamplePath + "storageclass.yaml") deleteResource(rbdExamplePath + "storageclass.yaml")
// deleteResource(rbdExamplePath + "snapshotclass.yaml") // deleteResource(rbdExamplePath + "snapshotclass.yaml")
deleteVault() deleteVault()
if deployRBD {
deleteRBDPlugin()
if cephCSINamespace != defaultNs {
err := c.CoreV1().Namespaces().Delete(cephCSINamespace, nil)
if err != nil && !apierrs.IsNotFound(err) {
Fail(err.Error())
}
err = framework.WaitForNamespacesDeleted(c, []string{cephCSINamespace}, time.Duration(deployTimeout)*time.Minute)
if err != nil {
Fail(err.Error())
}
}
}
}) })
Context("Test RBD CSI", func() { Context("Test RBD CSI", func() {
@ -111,13 +136,13 @@ var _ = Describe("RBD", func() {
By("checking provisioner deployment is running") By("checking provisioner deployment is running")
var err error var err error
err = waitForDeploymentComplete(rbdDeploymentName, namespace, f.ClientSet, deployTimeout) err = waitForDeploymentComplete(rbdDeploymentName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil { if err != nil {
Fail(err.Error()) Fail(err.Error())
} }
By("checking nodeplugin deamonsets is running") By("checking nodeplugin deamonsets is running")
err = waitForDaemonSets(rbdDaemonsetName, namespace, f.ClientSet, deployTimeout) err = waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil { if err != nil {
Fail(err.Error()) Fail(err.Error())
} }
@ -333,7 +358,7 @@ var _ = Describe("RBD", func() {
Fail(err.Error()) Fail(err.Error())
} }
// wait for nodeplugin pods to come up // wait for nodeplugin pods to come up
err = waitForDaemonSets(rbdDaemonsetName, namespace, f.ClientSet, deployTimeout) err = waitForDaemonSets(rbdDaemonsetName, cephCSINamespace, f.ClientSet, deployTimeout)
if err != nil { if err != nil {
Fail(err.Error()) Fail(err.Error())
} }

View File

@ -94,7 +94,7 @@ func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock bool) e
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
fsID, e := execCommandInPod(f, "ceph fsid", rookNS, &listOpt) fsID, e := execCommandInPod(f, "ceph fsid", rookNamespace, &listOpt)
if e != "" { if e != "" {
return fmt.Errorf("failed to get fsid from ceph cluster %s", e) return fmt.Errorf("failed to get fsid from ceph cluster %s", e)
} }
@ -104,7 +104,7 @@ func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock bool) e
// create rbd image // create rbd image
cmd := fmt.Sprintf("rbd create %s --size=%d --pool=replicapool --image-feature=layering", rbdImageName, 4096) cmd := fmt.Sprintf("rbd create %s --size=%d --pool=replicapool --image-feature=layering", rbdImageName, 4096)
_, e = execCommandInPod(f, cmd, rookNS, &listOpt) _, e = execCommandInPod(f, cmd, rookNamespace, &listOpt)
if e != "" { if e != "" {
return fmt.Errorf("failed to create rbd image %s", e) return fmt.Errorf("failed to create rbd image %s", e)
} }
@ -113,7 +113,7 @@ func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock bool) e
opt["pool"] = "replicapool" opt["pool"] = "replicapool"
opt["staticVolume"] = "true" opt["staticVolume"] = "true"
pv := getStaticPV(pvName, rbdImageName, size, "csi-rbd-secret", "default", sc, "rbd.csi.ceph.com", isBlock, opt) pv := getStaticPV(pvName, rbdImageName, size, "csi-rbd-secret", cephCSINamespace, sc, "rbd.csi.ceph.com", isBlock, opt)
_, err := c.CoreV1().PersistentVolumes().Create(pv) _, err := c.CoreV1().PersistentVolumes().Create(pv)
if err != nil { if err != nil {
@ -155,6 +155,6 @@ func validateRBDStaticPV(f *framework.Framework, appPath string, isBlock bool) e
} }
cmd = fmt.Sprintf("rbd rm %s --pool=replicapool", rbdImageName) cmd = fmt.Sprintf("rbd rm %s --pool=replicapool", rbdImageName)
execCommandInPod(f, cmd, rookNS, &listOpt) execCommandInPod(f, cmd, rookNamespace, &listOpt)
return nil return nil
} }

View File

@ -31,12 +31,14 @@ import (
) )
const ( const (
rookNS = "rook-ceph" defaultNs = "default"
vaultAddr = "http://vault.default.svc.cluster.local:8200"
vaultSecretNs = "/secret/ceph-csi/" // nolint: gosec, #nosec vaultSecretNs = "/secret/ceph-csi/" // nolint: gosec, #nosec
) )
var poll = 2 * time.Second var (
vaultAddr = fmt.Sprintf("http://vault.%s.svc.cluster.local:8200", cephCSINamespace)
poll = 2 * time.Second
)
// type snapInfo struct { // type snapInfo struct {
// ID int64 `json:"id"` // ID int64 `json:"id"`
@ -195,7 +197,7 @@ func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, en
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
fsID, stdErr := execCommandInPod(f, "ceph fsid", rookNS, &opt) fsID, stdErr := execCommandInPod(f, "ceph fsid", rookNamespace, &opt)
Expect(stdErr).Should(BeEmpty()) Expect(stdErr).Should(BeEmpty())
// remove new line present in fsID // remove new line present in fsID
fsID = strings.Trim(fsID, "\n") fsID = strings.Trim(fsID, "\n")
@ -212,7 +214,7 @@ func createRBDStorageClass(c kubernetes.Interface, f *framework.Framework, param
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
fsID, stdErr := execCommandInPod(f, "ceph fsid", rookNS, &opt) fsID, stdErr := execCommandInPod(f, "ceph fsid", rookNamespace, &opt)
Expect(stdErr).Should(BeEmpty()) Expect(stdErr).Should(BeEmpty())
// remove new line present in fsID // remove new line present in fsID
fsID = strings.Trim(fsID, "\n") fsID = strings.Trim(fsID, "\n")
@ -269,12 +271,12 @@ func createConfigMap(pluginPath string, c kubernetes.Interface, f *framework.Fra
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
fsID, stdErr := execCommandInPod(f, "ceph fsid", rookNS, &opt) fsID, stdErr := execCommandInPod(f, "ceph fsid", rookNamespace, &opt)
Expect(stdErr).Should(BeEmpty()) Expect(stdErr).Should(BeEmpty())
// remove new line present in fsID // remove new line present in fsID
fsID = strings.Trim(fsID, "\n") fsID = strings.Trim(fsID, "\n")
// get mon list // get mon list
mons := getMons(rookNS, c) mons := getMons(rookNamespace, c)
conmap := []struct { conmap := []struct {
Clusterid string `json:"clusterID"` Clusterid string `json:"clusterID"`
Monitors []string `json:"monitors"` Monitors []string `json:"monitors"`
@ -287,7 +289,7 @@ func createConfigMap(pluginPath string, c kubernetes.Interface, f *framework.Fra
data, err := json.Marshal(conmap) data, err := json.Marshal(conmap)
Expect(err).Should(BeNil()) Expect(err).Should(BeNil())
cm.Data["config.json"] = string(data) cm.Data["config.json"] = string(data)
_, err = c.CoreV1().ConfigMaps("default").Create(&cm) _, err = c.CoreV1().ConfigMaps(cephCSINamespace).Create(&cm)
Expect(err).Should(BeNil()) Expect(err).Should(BeNil())
} }
@ -309,13 +311,13 @@ func createCephfsSecret(c kubernetes.Interface, f *framework.Framework) {
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
adminKey, stdErr := execCommandInPod(f, "ceph auth get-key client.admin", rookNS, &opt) adminKey, stdErr := execCommandInPod(f, "ceph auth get-key client.admin", rookNamespace, &opt)
Expect(stdErr).Should(BeEmpty()) Expect(stdErr).Should(BeEmpty())
sc.StringData["adminID"] = "admin" sc.StringData["adminID"] = "admin"
sc.StringData["adminKey"] = adminKey sc.StringData["adminKey"] = adminKey
delete(sc.StringData, "userID") delete(sc.StringData, "userID")
delete(sc.StringData, "userKey") delete(sc.StringData, "userKey")
_, err := c.CoreV1().Secrets("default").Create(&sc) _, err := c.CoreV1().Secrets(cephCSINamespace).Create(&sc)
Expect(err).Should(BeNil()) Expect(err).Should(BeNil())
} }
@ -325,11 +327,11 @@ func createRBDSecret(c kubernetes.Interface, f *framework.Framework) {
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
adminKey, stdErr := execCommandInPod(f, "ceph auth get-key client.admin", rookNS, &opt) adminKey, stdErr := execCommandInPod(f, "ceph auth get-key client.admin", rookNamespace, &opt)
Expect(stdErr).Should(BeEmpty()) Expect(stdErr).Should(BeEmpty())
sc.StringData["userID"] = "admin" sc.StringData["userID"] = "admin"
sc.StringData["userKey"] = adminKey sc.StringData["userKey"] = adminKey
_, err := c.CoreV1().Secrets("default").Create(&sc) _, err := c.CoreV1().Secrets(cephCSINamespace).Create(&sc)
Expect(err).Should(BeNil()) Expect(err).Should(BeNil())
} }
@ -595,7 +597,7 @@ func getImageMeta(rbdImageSpec, metaKey string, f *framework.Framework) (string,
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
stdOut, stdErr := execCommandInPod(f, cmd, rookNS, &opt) stdOut, stdErr := execCommandInPod(f, cmd, rookNamespace, &opt)
if stdErr != "" { if stdErr != "" {
return strings.TrimSpace(stdOut), fmt.Errorf(stdErr) return strings.TrimSpace(stdOut), fmt.Errorf(stdErr)
} }
@ -627,7 +629,7 @@ func readVaultSecret(key string, f *framework.Framework) (string, string) {
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=vault", LabelSelector: "app=vault",
} }
stdOut, stdErr := execCommandInPodAndAllowFail(f, cmd, "default", &opt) stdOut, stdErr := execCommandInPodAndAllowFail(f, cmd, cephCSINamespace, &opt)
return strings.TrimSpace(stdOut), strings.TrimSpace(stdErr) return strings.TrimSpace(stdOut), strings.TrimSpace(stdErr)
} }
@ -834,7 +836,7 @@ func deleteBackingCephFSVolume(f *framework.Framework, pvc *v1.PersistentVolumeC
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
_, stdErr := execCommandInPod(f, "ceph fs subvolume rm myfs "+volname+" csi", rookNS, &opt) _, stdErr := execCommandInPod(f, "ceph fs subvolume rm myfs "+volname+" csi", rookNamespace, &opt)
Expect(stdErr).Should(BeEmpty()) Expect(stdErr).Should(BeEmpty())
if stdErr != "" { if stdErr != "" {
@ -847,7 +849,7 @@ func listRBDImages(f *framework.Framework) []string {
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
stdout, stdErr := execCommandInPod(f, "rbd ls --pool=replicapool --format=json", rookNS, &opt) stdout, stdErr := execCommandInPod(f, "rbd ls --pool=replicapool --format=json", rookNamespace, &opt)
Expect(stdErr).Should(BeEmpty()) Expect(stdErr).Should(BeEmpty())
var imgInfos []string var imgInfos []string
@ -931,7 +933,7 @@ func deleteBackingRBDImage(f *framework.Framework, pvc *v1.PersistentVolumeClaim
} }
cmd := fmt.Sprintf("rbd rm %s --pool=replicapool", rbdImage) cmd := fmt.Sprintf("rbd rm %s --pool=replicapool", rbdImage)
execCommandInPod(f, cmd, rookNS, &opt) execCommandInPod(f, cmd, rookNamespace, &opt)
return nil return nil
} }
@ -959,7 +961,7 @@ func deletePool(name string, cephfs bool, f *framework.Framework) {
for _, cmd := range cmds { for _, cmd := range cmds {
// discard stdErr as some commands prints warning in strErr // discard stdErr as some commands prints warning in strErr
execCommandInPod(f, cmd, rookNS, &opt) execCommandInPod(f, cmd, rookNamespace, &opt)
} }
} }