mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Make the Quota creation optional
This commit is contained in:
parent
7ce5478c0c
commit
e631550ef3
@ -256,6 +256,7 @@ parameters:
|
|||||||
* **group** maps all access to this group. Default is `nfsnobody`.
|
* **group** maps all access to this group. Default is `nfsnobody`.
|
||||||
* **quobyteConfig** use the specified configuration to create the volume. You can create a new configuration or modify an existing one with the Web console or the quobyte CLI. Default is `BASE`
|
* **quobyteConfig** use the specified configuration to create the volume. You can create a new configuration or modify an existing one with the Web console or the quobyte CLI. Default is `BASE`
|
||||||
* **quobyteTenant** use the specified tenant ID to create/delete the volume. This Quobyte tenant has to be already present in Quobyte. For Quobyte < 1.4 use an empty string `""` as `DEFAULT` tenant. Default is `DEFAULT`
|
* **quobyteTenant** use the specified tenant ID to create/delete the volume. This Quobyte tenant has to be already present in Quobyte. For Quobyte < 1.4 use an empty string `""` as `DEFAULT` tenant. Default is `DEFAULT`
|
||||||
|
* **createQuota** if set all volumes created by this storage class will get a Quota for the specified size. The quota is set for the logical disk size (which can differ from the physical size e.q. if replication is used). Default is ``False
|
||||||
|
|
||||||
First create Quobyte admin's Secret in the system namespace. Here the Secret is created in `kube-system`:
|
First create Quobyte admin's Secret in the system namespace. Here the Secret is created in `kube-system`:
|
||||||
|
|
||||||
|
@ -12,3 +12,4 @@ parameters:
|
|||||||
group: "root"
|
group: "root"
|
||||||
quobyteConfig: "BASE"
|
quobyteConfig: "BASE"
|
||||||
quobyteTenant: "DEFAULT"
|
quobyteTenant: "DEFAULT"
|
||||||
|
createQuota: "False"
|
||||||
|
@ -365,6 +365,7 @@ func (provisioner *quobyteVolumeProvisioner) Provision() (*v1.PersistentVolume,
|
|||||||
}
|
}
|
||||||
provisioner.config = "BASE"
|
provisioner.config = "BASE"
|
||||||
provisioner.tenant = "DEFAULT"
|
provisioner.tenant = "DEFAULT"
|
||||||
|
createQuota := false
|
||||||
|
|
||||||
cfg, err := parseAPIConfig(provisioner.plugin, provisioner.options.Parameters)
|
cfg, err := parseAPIConfig(provisioner.plugin, provisioner.options.Parameters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -382,6 +383,8 @@ func (provisioner *quobyteVolumeProvisioner) Provision() (*v1.PersistentVolume,
|
|||||||
provisioner.tenant = v
|
provisioner.tenant = v
|
||||||
case "quobyteconfig":
|
case "quobyteconfig":
|
||||||
provisioner.config = v
|
provisioner.config = v
|
||||||
|
case "createquota":
|
||||||
|
createQuota = gostrings.ToLower(v) == "true"
|
||||||
case "adminsecretname",
|
case "adminsecretname",
|
||||||
"adminsecretnamespace",
|
"adminsecretnamespace",
|
||||||
"quobyteapiserver":
|
"quobyteapiserver":
|
||||||
@ -402,7 +405,7 @@ func (provisioner *quobyteVolumeProvisioner) Provision() (*v1.PersistentVolume,
|
|||||||
config: cfg,
|
config: cfg,
|
||||||
}
|
}
|
||||||
|
|
||||||
vol, sizeGB, err := manager.createVolume(provisioner)
|
vol, sizeGB, err := manager.createVolume(provisioner, createQuota)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ type quobyteVolumeManager struct {
|
|||||||
config *quobyteAPIConfig
|
config *quobyteAPIConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *quobyteVolumeManager) createVolume(provisioner *quobyteVolumeProvisioner) (quobyte *v1.QuobyteVolumeSource, size int, err error) {
|
func (manager *quobyteVolumeManager) createVolume(provisioner *quobyteVolumeProvisioner, createQuota bool) (quobyte *v1.QuobyteVolumeSource, size int, err error) {
|
||||||
capacity := provisioner.options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
|
capacity := provisioner.options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
|
||||||
volumeSize := int(volume.RoundUpSize(capacity.Value(), 1024*1024*1024))
|
volumeSize := int(volume.RoundUpSize(capacity.Value(), 1024*1024*1024))
|
||||||
// Quobyte has the concept of Volumes which doen't have a specific size (they can grow unlimited)
|
// Quobyte has the concept of Volumes which doen't have a specific size (they can grow unlimited)
|
||||||
@ -51,11 +51,13 @@ func (manager *quobyteVolumeManager) createVolume(provisioner *quobyteVolumeProv
|
|||||||
return &v1.QuobyteVolumeSource{}, volumeSize, err
|
return &v1.QuobyteVolumeSource{}, volumeSize, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Quoate for Volume with specified byte size
|
// Set Quota for Volume with specified byte size
|
||||||
err = quobyteClient.SetVolumeQuota(volumeUUID, capacity.Value())
|
if createQuota {
|
||||||
|
err = quobyteClient.SetVolumeQuota(volumeUUID, uint64(capacity.Value()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &v1.QuobyteVolumeSource{}, volumeSize, err
|
return &v1.QuobyteVolumeSource{}, volumeSize, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glog.V(4).Infof("Created Quobyte volume %s", provisioner.volume)
|
glog.V(4).Infof("Created Quobyte volume %s", provisioner.volume)
|
||||||
return &v1.QuobyteVolumeSource{
|
return &v1.QuobyteVolumeSource{
|
||||||
|
Loading…
Reference in New Issue
Block a user