This content originally appeared on DEV Community and was authored by Maxime Guilbert
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):
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: {}
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! 🍺
This content originally appeared on DEV Community and was authored by Maxime Guilbert
Maxime Guilbert | Sciencx (2023-04-03T15:26:00+00:00) What does the error “cannot delete Pods with local storage” mean ?. Retrieved from https://www.scien.cx/2023/04/03/what-does-the-error-cannot-delete-pods-with-local-storage-mean/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.