Kubernetes PersistentVolumes are not deleted
Describe the bug
I'm not entirely sure if this is considered a bug.
Once a PersistentVolume is created it seems to only be deleted from disk when OrbStack is closed. This leads to a situation where in order to start fresh one would have to quit Orbstack and start it again, or use the deprecated "Recycle" reclaim policy. It is not enough to run kubectl delete and then kubectl apply again, as the data on the persistent volume will still be there even if the reclaim policy for the volume is "Delete".
To Reproduce
- Create a manifest containing a PV, PVC and a container mounting that volume. Set
persistentVolumeReclaimPolicyto "Delete". kubectl apply -f manifest.yamlthe manifest.- Log in to the container, create a file:
touch SOMERANDOMFILE. kubectl delete -f manifest.yamlkubectl apply -f manifest.yamlagain.- Log in to the container again and
ls -al.
Here's an example manifest using Wordpress:
--- # WP persistent volume
apiVersion: v1
kind: PersistentVolume
metadata:
name: wp-pv
namespace: wordpress
labels:
app: wordpress
tier: app
spec:
storageClassName: local-path
persistentVolumeReclaimPolicy: Delete
accessModes:
- ReadWriteOnce
capacity:
storage: 1Gi
hostPath:
path: "/mnt/wp"
--- # WP persistent volume claim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wp-pvc
namespace: wordpress
labels:
app: wordpress
tier: app
spec:
storageClassName: local-path
resources:
requests:
storage: 1Gi
accessModes:
- ReadWriteOnce
volumeName: wp-pv
--- # WP service
apiVersion: v1
kind: Service
metadata:
name: wordpress
namespace: wordpress
labels:
app: wordpress
tier: app
spec:
ports:
- port: 80
targetPort: 80
selector:
app: wordpress
tier: app
type: LoadBalancer
--- # WP deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress
namespace: wordpress
labels:
app: wordpress
tier: app
spec:
replicas: 1
selector:
matchLabels:
app: wordpress
tier: app
template:
metadata:
labels:
app: wordpress
tier: app
spec:
containers:
- image: public.ecr.aws/docker/library/wordpress:latest
name: wordpress
env:
- name: WORDPRESS_DB_HOST
value: wp-db
- name: WORDPRESS_DB_NAME
value: wordpress
- name: WORDPRESS_DB_USER
value: wordpress
- name: WORDPRESS_DB_PASSWORD
value: DBPass
ports:
- containerPort: 80
name: wordpress
volumeMounts:
- name: wp-www
mountPath: /var/www/html
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
volumes:
- name: wp-www
persistentVolumeClaim:
claimName: wp-pvc
Expected behavior
I would expect the volume to be deleted so that a fresh apply would be completely fresh. In my case the WordPress DB once initialized means I have to quit Orbstack before re-applying while testing. Or use Recycle as reclaim policy, which is deprecated.
Diagnostic report (REQUIRED)
OrbStack info: Version: 1.10.3 Commit: 2b5dd5f580d80a3d2494b7b40dde2ef46813cfc5 (v1.10.3)
System info: macOS: 15.3.2 (24D81) CPU: arm64, 10 cores CPU model: Apple M1 Pro Model: MacBookPro18,1 Memory: 16 GiB
Full report: https://orbstack.dev/_admin/diag/orbstack-diagreport_2025-03-24T09-23-53.871650Z.zip
Screenshots and additional context (optional)
No response
This seems to be a bug with local-path-provisioner which does not honor Delete persistentVolumeReclaimPolicy. To work around the issue you can use PVC only without binding to a specific PV. Just remove PV manifest and volumeName attribute in the PVC manifest.