mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-29 21:29:24 +00:00
implement Ceph FS volume plugin and add to e2e volume test
Signed-off-by: Huamin Chen <hchen@redhat.com>
This commit is contained in:
@@ -478,5 +478,73 @@ var _ = Describe("Volumes", func() {
|
||||
|
||||
})
|
||||
})
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Ceph
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Marked with [Skipped] to skip the test by default (see driver.go),
|
||||
// the test needs privileged containers, which are disabled by default.
|
||||
// Run the test with "go run hack/e2e.go ... --ginkgo.focus=Volume"
|
||||
Describe("[Skipped] CephFS", func() {
|
||||
It("should be mountable", func() {
|
||||
config := VolumeTestConfig{
|
||||
namespace: namespace.Name,
|
||||
prefix: "cephfs",
|
||||
serverImage: "gcr.io/google_containers/volume-ceph",
|
||||
serverPorts: []int{6789},
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if clean {
|
||||
volumeTestCleanup(c, config)
|
||||
}
|
||||
}()
|
||||
pod := startVolumeServer(c, config)
|
||||
serverIP := pod.Status.PodIP
|
||||
Logf("Ceph server IP address: %v", serverIP)
|
||||
By("sleeping a bit to give ceph server time to initialize")
|
||||
time.Sleep(20 * time.Second)
|
||||
|
||||
// create ceph secret
|
||||
secret := &api.Secret{
|
||||
TypeMeta: api.TypeMeta{
|
||||
Kind: "Secret",
|
||||
APIVersion: "v1beta3",
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: config.prefix + "-secret",
|
||||
},
|
||||
// Must use the ceph keyring at contrib/for-tests/volumes-ceph/ceph/init.sh
|
||||
// and encode in base64
|
||||
Data: map[string][]byte{
|
||||
"key": []byte("AQAMgXhVwBCeDhAA9nlPaFyfUSatGD4drFWDvQ=="),
|
||||
},
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if clean {
|
||||
if err := c.Secrets(namespace.Name).Delete(secret.Name); err != nil {
|
||||
Failf("unable to delete secret %v: %v", secret.Name, err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
var err error
|
||||
if secret, err = c.Secrets(namespace.Name).Create(secret); err != nil {
|
||||
Failf("unable to create test secret %s: %v", secret.Name, err)
|
||||
}
|
||||
|
||||
volume := api.VolumeSource{
|
||||
CephFS: &api.CephFSVolumeSource{
|
||||
Monitors: []string{serverIP + ":6789"},
|
||||
User: "kube",
|
||||
SecretRef: &api.LocalObjectReference{Name: config.prefix + "-secret"},
|
||||
ReadOnly: true,
|
||||
},
|
||||
}
|
||||
// Must match content of contrib/for-tests/volumes-ceph/ceph/index.html
|
||||
testVolumeClient(c, config, volume, "Hello Ceph!")
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user