DEV Community

Maxime Guilbert
Maxime Guilbert

Posted on • Updated on

What does the error "cannot delete Pods with local storage" mean ?

While we are doing Kubernetes cluster updates, or we simply want to clean a node before deleting it, we can have the error "**cannot delete Pods with local storage".



$ kubectl drain node-1 --ignore-daemonsets
...
error: cannot delete Pods with local storage (use --delete-emptydir-data to override):


Enter fullscreen mode Exit fullscreen mode

The solution is quite simple and is already noted in the error log. We just have to add the option --delete-emptydir-data to your command to make it work.

But what does it mean ?


Error explaination

This error want to show you that you have some pods (which are on the node you want to clean) have local storage as emptyDir.



apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  containers:
  - image: busybox
    name: busybox
    volumeMounts:
    - mountPath: /data
      name: my-volume
  volumes:
  - name: my-volume
    emptyDir: {}


Enter fullscreen mode Exit fullscreen mode

Using an emptyDir volume is something which must be understand to avoid this kind of issue.

An emptyDir volume only exists on the node where the related pod is. Contrary to the pods, it won't be moved to a new node, but it will be destroyed, before being recreated on the new node.
It means that all the data which are on the "old" node will be deleted.

It is for this reason that we must be conscious about what is an emptyDir volume. If you are using this for a database, you may be able to do something manually to extract the data and migrate it to the new node. But you won't be able to always do it. Some services using volumes doesn't have an "extract" feature.

So we can conclude that the error cannot delete Pod with local storage is more a "confirmation box" to let you know that you have local storage and it should be extracted, if you can, or it will be deleted for good.


I hope it will help you! 🍺


You want to support me?

Buy Me A Coffee

Top comments (0)