Skip to content
This repository has been archived by the owner on Aug 14, 2021. It is now read-only.

Commit

Permalink
Add(feat): Block volume support for openebs volume
Browse files Browse the repository at this point in the history
This commit will add block volume support for openebs
volume.
As block volume support is in alpha state in k8s
have to enable feature-gate in kube-apiserver, cotroller-manger
and kubelet to use this feature using --featue-gate="BlockVolume=true".

Signed-off-by: prateekpandey14 <[email protected]>
  • Loading branch information
prateekpandey14 authored and kmova committed Oct 18, 2018
1 parent 208d435 commit f655b0e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion openebs/pkg/provisioner/cas_provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func NewOpenEBSCASProvisioner(client kubernetes.Interface) (controller.Provision
}

var _ controller.Provisioner = &openEBSCASProvisioner{}
var _ controller.BlockProvisioner = &openEBSCASProvisioner{}

// Provision creates a storage asset and returns a PV object representing it.
func (p *openEBSCASProvisioner) Provision(options controller.VolumeOptions) (*v1.PersistentVolume, error) {
Expand Down Expand Up @@ -136,6 +137,14 @@ func (p *openEBSCASProvisioner) Provision(options controller.VolumeOptions) (*v1
volAnnotations["openEBSProvisionerIdentity"] = p.identity
volAnnotations["openebs.io/cas-type"] = casVolume.Spec.CasType

fstype := casVolume.Spec.FSType
var volumeMode *v1.PersistentVolumeMode
volumeMode = options.PVC.Spec.VolumeMode
if volumeMode != nil && *volumeMode == v1.PersistentVolumeBlock {
// Block volumes should not have any FSType
glog.Infof("block volume provisioning for volume %s", options.PVC.ObjectMeta.Name)
fstype = ""
}
pv := &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: options.PVName,
Expand All @@ -148,12 +157,13 @@ func (p *openEBSCASProvisioner) Provision(options controller.VolumeOptions) (*v1
Capacity: v1.ResourceList{
v1.ResourceName(v1.ResourceStorage): options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)],
},
VolumeMode: volumeMode,
PersistentVolumeSource: v1.PersistentVolumeSource{
ISCSI: &v1.ISCSIPersistentVolumeSource{
TargetPortal: casVolume.Spec.TargetPortal,
IQN: casVolume.Spec.Iqn,
Lun: casVolume.Spec.Lun,
FSType: casVolume.Spec.FSType,
FSType: fstype,
ReadOnly: false,
},
},
Expand All @@ -168,6 +178,10 @@ func (p *openEBSCASProvisioner) GetAccessModes() []v1.PersistentVolumeAccessMode
}
}

func (p *openEBSCASProvisioner) SupportsBlock() bool {
return true
}

// Delete removes the storage asset that was created by Provision represented
// by the given PV.
func (p *openEBSCASProvisioner) Delete(volume *v1.PersistentVolume) error {
Expand Down

0 comments on commit f655b0e

Please sign in to comment.