Question

how to safely remove digitalocean csi plugin

hello guys,

i spun up a digitalocean kubernetes with 3 worker nodes. i would prefer to use nfs for persistent volume provisioning. so i created a nfs server and deployed my external provisioner connected to it. i check that everything works well

here is the question: when i get “kubectl get sc” there are 2 default storageClass in my cluster. one my external provisioner, and one digitalocean csi…is it enough to remove the csi daemonset (kubectl delete ds -n kube-system) or any other consideration is needed ?

thank you so much for taking the time to help me


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
March 17, 2024

Hey!

When removing the DigitalOcean CSI plugin, you want to ensure the process is handled methodically to avoid unintended consequences.

Before you prcoeed I would strongly recommend making sure that you actually have a working backup. You can for example use the DigitalOcean Kubernetes backups with SnapShooter:

https://www.digitalocean.com/blog/doks-backup-snapshooter

Here are some steps, along with command examples, to remove the CSI plugin safely:

  1. Drain Kubernetes nodes (Optional but recommended for maintenance): This is to ensure that no work is being done on the node and no new work will be scheduled on it.

    kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data
    
  2. Scale down Deployments/StatefulSets: If you have deployments or stateful sets using the CSI driver, scale them down.

    kubectl scale deployment <deployment-name> --replicas=0
    kubectl scale statefulset <statefulset-name> --replicas=0
    
  3. Delete PersistentVolumeClaims (PVCs): Remove PVCs that are provisioned by the DigitalOcean CSI driver.

    kubectl delete pvc <pvc-name>
    

    After deleting the PVCs, make sure that the associated PVs are also deleted. You can check using:

    kubectl get pv
    

    If the PVs still exist and you’re sure they’re not needed anymore (or you’ve backed up the data elsewhere), you can delete them:

    kubectl delete pv <pv-name>
    
  4. Delete the CSI driver components: This includes the controller deployments, CSI driver daemonset, and any associated secrets or other resources.

    kubectl delete -f <csi-driver-deployment-file.yaml>
    kubectl delete ds -n kube-system <csi-driver-daemonset-name>
    kubectl delete secret -n kube-system <csi-driver-secret-name>
    

    These commands require you to know the exact names of the resources deployed by the CSI plugin. You can find them with:

    kubectl get all -n kube-system | grep csi
    
  5. Delete CustomResourceDefinitions (CRDs): If the CSI plugin used CRDs, you’ll need to delete those as well.

    kubectl delete crd <crd-name>
    
  6. Clean up ClusterRoleBindings and ClusterRoles: If the CSI plugin created any cluster roles or bindings, they should also be removed.

    kubectl delete clusterrolebinding <clusterrolebinding-name>
    kubectl delete clusterrole <clusterrole-name>
    
  7. Review Storage Classes: Make sure that your NFS storage class is set as default if you no longer intend to use DigitalOcean’s block storage.

    kubectl patch storageclass <your-nfs-storageclass-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
    
  8. Uncordon the nodes (If you drained them): Once the maintenance is complete, make sure to uncordon the nodes to allow scheduling workloads on them again.

    kubectl uncordon <node-name>
    

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel