2020-04-03 07:10:29 +00:00
|
|
|
# Stale Resource Cleanup
|
|
|
|
|
|
|
|
If the PVC is created with storage class which is having the `reclaimPolicy`
|
|
|
|
as `Retain` will not delete the PV object, backend omap metadata and backend image.
|
|
|
|
Manual deletion of PV will result in stale omap keys, values,
|
|
|
|
cephfs subvolume and rbd image.
|
|
|
|
It is required to cleanup metadata and image separately.
|
|
|
|
|
|
|
|
## Steps
|
|
|
|
|
|
|
|
### 1. Get PV name from PVC
|
|
|
|
|
|
|
|
a. get pv_name
|
|
|
|
|
2020-11-11 07:22:54 +00:00
|
|
|
```
|
|
|
|
kubectl get pvc pvc_name -n namespace -owide
|
|
|
|
```
|
2020-04-03 07:10:29 +00:00
|
|
|
|
|
|
|
```bash
|
|
|
|
$ kubectl get pvc mysql-pvc -owide -n prometheus
|
|
|
|
NAME STATUS VOLUME
|
|
|
|
mysql-pvc Bound pvc-bc537af8-67fc-4963-99c4-f40b3401686a
|
|
|
|
|
|
|
|
CAPACITY ACCESS MODES STORAGECLASS AGE VOLUMEMODE
|
|
|
|
20Gi RWO csi-rbd 14d Filesystem
|
|
|
|
```
|
|
|
|
|
|
|
|
### 2. Get omap key/value
|
|
|
|
|
|
|
|
a. get omapkey (suffix of csi.volumes.default is value used for the CLI option
|
|
|
|
[--instanceid](deploy-rbd.md#configuration) in the provisioner deployment.)
|
|
|
|
|
2020-11-11 07:22:54 +00:00
|
|
|
```
|
|
|
|
rados listomapkeys csi.volumes.default -p pool_name | grep pv_name
|
|
|
|
```
|
2020-04-03 07:10:29 +00:00
|
|
|
|
|
|
|
```bash
|
|
|
|
$ rados listomapkeys csi.volumes.default -p kube_csi | grep pvc-bc537af8-67fc-4963-99c4-f40b3401686a
|
|
|
|
csi.volume.pvc-bc537af8-67fc-4963-99c4-f40b3401686a
|
|
|
|
```
|
|
|
|
|
|
|
|
b. get omapval
|
|
|
|
|
2020-11-11 07:22:54 +00:00
|
|
|
```
|
|
|
|
rados getomapval csi.volumes.default omapkey -p pool_name
|
|
|
|
```
|
2020-04-03 07:10:29 +00:00
|
|
|
|
|
|
|
```bash
|
2020-11-11 07:22:54 +00:00
|
|
|
$ rados getomapval csi.volumes.default csi.volume.pvc-bc537af8-67fc-4963-99c4-f40b3401686a -p kube_csi
|
2020-04-03 07:10:29 +00:00
|
|
|
value (36 bytes) :
|
|
|
|
00000000 64 64 32 34 37 33 64 30 2d 36 61 38 63 2d 31 31 |dd2473d0-6a8c-11|
|
|
|
|
00000010 65 61 2d 39 31 31 33 2d 30 61 64 35 39 64 39 39 |ea-9113-0ad59d99|
|
|
|
|
00000020 35 63 65 37 |5ce7|
|
|
|
|
00000024
|
|
|
|
```
|
|
|
|
|
|
|
|
### 3. Delete the RBD image or CephFS subvolume
|
|
|
|
|
|
|
|
a. remove rbd image(csi-vol-omapval, the prefix csi-vol is value of [volumeNamePrefix](deploy-rbd.md#configuration))
|
|
|
|
|
2020-11-11 07:22:54 +00:00
|
|
|
```
|
|
|
|
rbd remove rbd_image_name -p pool_name
|
|
|
|
```
|
2020-04-03 07:10:29 +00:00
|
|
|
|
|
|
|
```bash
|
|
|
|
$ rbd remove csi-vol-dd2473d0-6a8c-11ea-9113-0ad59d995ce7 -p kube_csi
|
|
|
|
Removing image: 100% complete...done.
|
|
|
|
```
|
|
|
|
|
|
|
|
b. remove cephfs subvolume(csi-vol-omapval)
|
|
|
|
|
2020-11-11 07:22:54 +00:00
|
|
|
```
|
|
|
|
ceph fs subvolume rm volume_name subvolume_name group_name
|
|
|
|
```
|
2020-04-03 07:10:29 +00:00
|
|
|
|
|
|
|
```bash
|
2020-11-11 07:22:54 +00:00
|
|
|
ceph fs subvolume rm cephfs csi-vol-340daf84-5e8f-11ea-8560-6e87b41d7a6e csi
|
2020-04-03 07:10:29 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### 4. Delete omap object and omapkey
|
|
|
|
|
|
|
|
a. delete omap object
|
|
|
|
|
2020-11-11 07:22:54 +00:00
|
|
|
```
|
|
|
|
rados rm csi.volume.omapval -p pool_name
|
|
|
|
```
|
2020-04-03 07:10:29 +00:00
|
|
|
|
|
|
|
```bash
|
2020-11-11 07:22:54 +00:00
|
|
|
rados rm csi.volume.dd2473d0-6a8c-11ea-9113-0ad59d995ce7 -p kube_csi
|
2020-04-03 07:10:29 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
b. delete omapkey
|
|
|
|
|
|
|
|
```
|
2020-11-11 07:22:54 +00:00
|
|
|
rados rmomapkey csi.volumes.default csi.volume.omapkey -p pool_name
|
|
|
|
```
|
|
|
|
|
|
|
|
```bash
|
|
|
|
rados rmomapkey csi.volumes.default csi.volume.pvc-bc537af8-67fc-4963-99c4-f40b3401686a -p kube_csi
|
2020-04-03 07:10:29 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
### 5. Delete PV
|
|
|
|
|
|
|
|
a. delete pv
|
|
|
|
|
2020-11-11 07:22:54 +00:00
|
|
|
```
|
|
|
|
kubectl delete pv pv_name -n namespace
|
|
|
|
```
|
2020-04-03 07:10:29 +00:00
|
|
|
|
|
|
|
```bash
|
|
|
|
$ kubectl delete pv pvc-bc537af8-67fc-4963-99c4-f40b3401686a -n prometheus
|
|
|
|
persistentvolume "pvc-bc537af8-67fc-4963-99c4-f40b3401686a" deleted
|
|
|
|
```
|