mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-11 22:10:11 +01:00
feat(topology): adding support for custom topology keys (#94)
This commit adds the support for use to specify custom labels to the kubernetes nodes and use them in the allowedToplogoies section of the StorageClass. Few notes: - This PR depends on the CSI driver's capability to support custom topology keys. - label on the nodes should be added first and then deploy the driver to make it aware of all the labels that node has. If labels are added after ZFS-LocalPV driver has been deployed, a restart all the node csi driver agents is required so that the driver can pick the labels and add them as supported topology keys. - if storageclass is using Immediate binding mode and topology key is not mentioned then all the nodes should be labeled using same key, that means: - same key should be present on all nodes, nodes can have different values for those keys. - If nodes are labeled with different keys i.e. some nodes are having different keys, then ZFSPV's default scheduler can not effictively do the volume count based scheduling. In this case the CSI provisioner will pick keys from any random node and then prepare the preferred topology list using the nodes which has those keys defined. And ZFSPV scheduler will schedule the PV among those nodes only. Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
parent
f65575e447
commit
de9b302083
7 changed files with 184 additions and 13 deletions
|
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/container-storage-interface/spec/lib/go/csi"
|
||||
apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1alpha1"
|
||||
"github.com/openebs/zfs-localpv/pkg/builder/volbuilder"
|
||||
k8sapi "github.com/openebs/zfs-localpv/pkg/client/k8s/v1alpha1"
|
||||
"github.com/openebs/zfs-localpv/pkg/mgmt/snapshot"
|
||||
"github.com/openebs/zfs-localpv/pkg/mgmt/volume"
|
||||
"github.com/openebs/zfs-localpv/pkg/zfs"
|
||||
|
|
@ -171,7 +172,34 @@ func (ns *node) NodeGetInfo(
|
|||
req *csi.NodeGetInfoRequest,
|
||||
) (*csi.NodeGetInfoResponse, error) {
|
||||
|
||||
topology := map[string]string{zfs.ZFSTopologyKey: ns.driver.config.NodeID}
|
||||
node, err := k8sapi.GetNode(ns.driver.config.NodeID)
|
||||
if err != nil {
|
||||
logrus.Errorf("failed to get the node %s", ns.driver.config.NodeID)
|
||||
return nil, err
|
||||
}
|
||||
/*
|
||||
* The driver will support all the keys and values defined in the node's label.
|
||||
* if nodes are labeled with the below keys and values
|
||||
* map[beta.kubernetes.io/arch:amd64 beta.kubernetes.io/os:linux kubernetes.io/arch:amd64 kubernetes.io/hostname:pawan-node-1 kubernetes.io/os:linux node-role.kubernetes.io/worker:true openebs.io/zone:zone1 openebs.io/zpool:ssd]
|
||||
* The driver will support below key and values
|
||||
* {
|
||||
* beta.kubernetes.io/arch:amd64
|
||||
* beta.kubernetes.io/os:linux
|
||||
* kubernetes.io/arch:amd64
|
||||
* kubernetes.io/hostname:pawan-node-1
|
||||
* kubernetes.io/os:linux
|
||||
* node-role.kubernetes.io/worker:true
|
||||
* openebs.io/zone:zone1
|
||||
* openebs.io/zpool:ssd
|
||||
* }
|
||||
*/
|
||||
|
||||
// support all the keys that node has
|
||||
topology := node.Labels
|
||||
|
||||
// add driver's topology key
|
||||
topology[zfs.ZFSTopologyKey] = ns.driver.config.NodeID
|
||||
|
||||
return &csi.NodeGetInfoResponse{
|
||||
NodeId: ns.driver.config.NodeID,
|
||||
AccessibleTopology: &csi.Topology{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue