Add imageFeatures parameter for RBD volume plugin, which is used to

customize RBD image format 2 features.
Update RBD docs in examples/persistent-volume-provisioning/README.md.
This commit is contained in:
Yecheng Fu 2017-06-16 12:11:35 +00:00
parent 2632bdd5e0
commit 0c7cdf773b
3 changed files with 33 additions and 13 deletions

View File

@ -209,6 +209,7 @@ parameters:
pool: kube
userId: kube
userSecretName: ceph-secret-user
imageFormat: "1"
```
* `monitors`: Ceph monitors, comma delimited. It is required.
@ -218,6 +219,10 @@ parameters:
* `pool`: Ceph RBD pool. Default is "rbd".
* `userId`: Ceph client ID that is used to map the RBD image. Default is the same as `adminId`.
* `userSecretName`: The name of Ceph Secret for `userId` to map RBD image. It must exist in the same namespace as PVCs. It is required.
* `imageFormat`: Ceph RBD image format, "1" or "2". Default is "1".
* `imageFeatures`: Ceph RBD image format 2 features, comma delimited. This is optional, and only be used if you set `imageFormat` to "2". For a complete list of available image features, please refer to [RBD docs](http://docs.ceph.com/docs/master/man/8/rbd/). By default, all features (except for striping) will be enabled.
NOTE: If you want to use RBD image format 2, you may need to disable some image features, because some of them are not supported by [Ceph kernel module](https://github.com/ceph/ceph-client). For example, only "layering" feature is supported on Linux 4.9 LTS version, so you need to specify `imageFeatures` to "layering", if set `imageFormat` to "2".
#### Quobyte

View File

@ -269,7 +269,7 @@ func (r *rbdVolumeProvisioner) Provision() (*v1.PersistentVolume, error) {
adminSecretNamespace := "default"
secretName := ""
secret := ""
imageFormat := ""
imageFormat := rbdImageFormat1
for k, v := range r.options.Parameters {
switch dstrings.ToLower(k) {
@ -292,6 +292,11 @@ func (r *rbdVolumeProvisioner) Provision() (*v1.PersistentVolume, error) {
secretName = v
case "imageformat":
imageFormat = v
case "imagefeatures":
arr := dstrings.Split(v, ",")
for _, f := range arr {
r.imageFeatures = append(r.imageFeatures, f)
}
default:
return nil, fmt.Errorf("invalid option %q for volume plugin %s", k, r.plugin.GetPluginName())
}
@ -386,15 +391,16 @@ func (rbd *rbd) GetPath() string {
type rbdMounter struct {
*rbd
// capitalized so they can be exported in persistRBD()
Mon []string
Id string
Keyring string
Secret string
fsType string
adminSecret string
adminId string
mountOptions []string
imageFormat string
Mon []string
Id string
Keyring string
Secret string
fsType string
adminSecret string
adminId string
mountOptions []string
imageFormat string
imageFeatures []string
}
var _ volume.Mounter = &rbdMounter{}

View File

@ -355,9 +355,18 @@ func (util *RBDUtil) CreateImage(p *rbdVolumeProvisioner) (r *v1.RBDVolumeSource
// iterate all monitors until create succeeds.
for i := start; i < start+l; i++ {
mon := p.Mon[i%l]
glog.V(4).Infof("rbd: create %s size %s using mon %s, pool %s id %s key %s", p.rbdMounter.Image, volSz, mon, p.rbdMounter.Pool, p.rbdMounter.adminId, p.rbdMounter.adminSecret)
output, err = p.rbdMounter.plugin.execCommand("rbd",
[]string{"create", p.rbdMounter.Image, "--size", volSz, "--pool", p.rbdMounter.Pool, "--id", p.rbdMounter.adminId, "-m", mon, "--key=" + p.rbdMounter.adminSecret, "--image-format", p.rbdMounter.imageFormat})
if p.rbdMounter.imageFormat == rbdImageFormat2 {
glog.V(4).Infof("rbd: create %s size %s format %s (features: %s) using mon %s, pool %s id %s key %s", p.rbdMounter.Image, volSz, p.rbdMounter.imageFormat, p.rbdMounter.imageFeatures, mon, p.rbdMounter.Pool, p.rbdMounter.adminId, p.rbdMounter.adminSecret)
} else {
glog.V(4).Infof("rbd: create %s size %s format %s using mon %s, pool %s id %s key %s", p.rbdMounter.Image, volSz, p.rbdMounter.imageFormat, mon, p.rbdMounter.Pool, p.rbdMounter.adminId, p.rbdMounter.adminSecret)
}
args := []string{"create", p.rbdMounter.Image, "--size", volSz, "--pool", p.rbdMounter.Pool, "--id", p.rbdMounter.adminId, "-m", mon, "--key=" + p.rbdMounter.adminSecret, "--image-format", p.rbdMounter.imageFormat}
if p.rbdMounter.imageFormat == rbdImageFormat2 && len(p.rbdMounter.imageFeatures) > 0 {
for _, f := range p.rbdMounter.imageFeatures {
args = append(args, "--image-feature", f)
}
}
output, err = p.rbdMounter.plugin.execCommand("rbd", args)
if err == nil {
break
} else {