mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-11 22:10:11 +01:00
k8s is very slow in attaching the volumes when dealing with the large number of volume attachment object. (k8s issue https://github.com/kubernetes/kubernetes/issues/84169) The volumeattachment is not required for ZFSPV, so avoid creation of attachment object, also removed the csi-attacher container as this is also not needed as it acts on volumeattachment object. k8s is very slow in attaching the volumes when dealing with the large number of volume attachment object : k8s issue https://github.com/kubernetes/kubernetes/issues/84169). Volumeattachment is a CR created just to tell the watcher of it which is csi-attacher, that it has to call the Controller Publish/Unpublish grpc. Which does all the tasks to attach the volumes to a node for example call to the DigitalOcean Block Storage API service to attach a created volume to a specified node. Since for ZFSPV, volume is already present locally, nothing needs to done in Controller Publish/Unpublish, so it is good to remove them. so avoiding creation of attachment object in this change, also removed the csi-attacher container as this is also not needed as it acts on volumeattachment object. Removed csi-cluster-driver-registrar container also as it is deprecated and not needed anymore. We are using csidriver beta CRDs so minimum k8s version required is 1.14+. Signed-off-by: Pawan <pawan@mayadata.io>
54 lines
1.4 KiB
Bash
54 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
if [ -z $1 ]; then
|
|
# default namespace is openebs when all the custom resources are created
|
|
ZFSPV_NAMESPACE="openebs"
|
|
else
|
|
ZFSPV_NAMESPACE=$1
|
|
fi
|
|
|
|
echo "Fetching ZFS Volumes"
|
|
numVol=`kubectl get zfsvolumes.openebs.io --no-headers -n $ZFSPV_NAMESPACE | wc -l`
|
|
|
|
if [ $numVol -gt 0 ]; then
|
|
echo "Cleaning the ZFS Volumes($numVol)"
|
|
kubectl get zfsvolumes.openebs.io -n $ZFSPV_NAMESPACE -oyaml > volumes.yaml
|
|
|
|
# remove the finalizer from the old CR
|
|
sed -i "/zfs.openebs.io\/finalizer/d" volumes.yaml
|
|
kubectl apply -f volumes.yaml
|
|
|
|
# delete the old CR
|
|
kubectl delete -f volumes.yaml
|
|
fi
|
|
|
|
# delete the ZFSVolume CRD definition
|
|
kubectl delete crd zfsvolumes.openebs.io
|
|
|
|
numAttach=`kubectl get volumeattachment --no-headers | grep zfs.csi.openebs.io | wc -l`
|
|
|
|
if [ $numAttach -gt 0 ]; then
|
|
echo "Cleaning the volumeattachment($numAttach)"
|
|
# delete the volumeattachment object
|
|
kubectl delete volumeattachment --all
|
|
fi
|
|
|
|
echo "Fetching ZFS Snapshots"
|
|
numSnap=`kubectl get zfssnapshots.openebs.io --no-headers -n $ZFSPV_NAMESPACE | wc -l`
|
|
|
|
if [ $numSnap -gt 0 ]; then
|
|
echo "Cleaning the ZFS Snapshot($numSnap)"
|
|
kubectl get zfssnapshots.openebs.io -n $ZFSPV_NAMESPACE -oyaml > snapshots.yaml
|
|
|
|
# remove the finalizer from the old CR
|
|
sed -i "/zfs.openebs.io\/finalizer/d" snapshots.yaml
|
|
kubectl apply -f snapshots.yaml
|
|
|
|
# delete the old CR
|
|
kubectl delete -f snapshots.yaml
|
|
fi
|
|
|
|
# delete the ZFSSnapshot CRD definition
|
|
kubectl delete crd zfssnapshots.openebs.io
|