modified: README.md
This commit is contained in:
@@ -18,6 +18,7 @@ Kubernetes is an open‑source platform that automates the deployment, scaling,
|
||||
- [find persistent volume used pvc](#find-persistent-volume-used-pvc)
|
||||
- [Patch pv - change to retain policy](#patch-pv---change-to-retain-policy)
|
||||
- [Patch pv - remove finalizers](#patch-pv---remove-finalizers)
|
||||
- [check orphans](#check-orphans)
|
||||
- [persistent volume claims](#persistent-volume-claims)
|
||||
- [Create an pod with PVC](#create-an-pod-with-pvc)
|
||||
- [kubectl](#kubectl)
|
||||
@@ -346,6 +347,39 @@ kubectl patch pv $PV_NAME \
|
||||
-p '{"metadata":{"finalizers": null}}'
|
||||
```
|
||||
|
||||
### check orphans
|
||||
|
||||
**Execute on host:**
|
||||
|
||||
``` bash
|
||||
#/bin/bash
|
||||
STORAGE_DIR="/var/lib/rancher/k3s/storage"
|
||||
# clean if already been used
|
||||
unset PV_PATHS
|
||||
declare -A PV_PATHS
|
||||
ORPHANS=()
|
||||
|
||||
for name in $(kubectl get pv -o jsonpath='{.items[*].metadata.name}'); do
|
||||
path=$(kubectl get pv ${name} -o jsonpath='{.spec.local.path}' 2>/dev/null)
|
||||
# check if path is no empty
|
||||
[[ -n "${path}" ]] && PV_PATHS["${path}"]="1"
|
||||
done
|
||||
|
||||
for dir in "$STORAGE_DIR"/*; do
|
||||
[ -d "$dir" ] || continue
|
||||
if [[ -z "${PV_PATHS[$dir]}" ]]; then
|
||||
ORPHANS+=("$dir")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#ORPHANS[@]} -eq 0 ]]; then
|
||||
echo "No orphans found."
|
||||
else
|
||||
echo "orphans:"
|
||||
printf "%s\n" "${ORPHANS[@]}"
|
||||
fi
|
||||
```
|
||||
|
||||
### persistent volume claims
|
||||
|
||||
``` yaml
|
||||
|
||||
Reference in New Issue
Block a user