mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Do not delete PVs with --all, instead delete them selectively.
PV is a non-namespaced resource. Running `kubectl delete pv --all`, even with `--namespace` is going to delete all the PVs in the cluster. This is a dangerous operation and should not be deleted this way. Instead we now retrieve the PVs bound to the PVCs in the namespace we are deleteing and delete only those PVs. Fixes issue #46380.
This commit is contained in:
parent
3837d95191
commit
60d10e9e27
@ -414,8 +414,15 @@ function cleanup-federation-api-objects {
|
||||
echo "Cleaning Federation control plane objects"
|
||||
# Delete all resources with the federated-cluster label.
|
||||
$host_kubectl delete pods,svc,rc,deployment,secret -lapp=federated-cluster
|
||||
|
||||
# Delete all PVs bound to PVCs in FEDERATION_NAMESPACE
|
||||
pvs=$($host_kubectl get pvc --namespace=${FEDERATION_NAMESPACE} -o jsonpath='{.items[*].spec.volumeName}')
|
||||
while $host_kubectl delete pv ${pvs} >/dev/null 2>&1; do
|
||||
sleep 2
|
||||
done
|
||||
|
||||
# Delete all resources in FEDERATION_NAMESPACE.
|
||||
$host_kubectl delete pvc,pv,pods,svc,rc,deployment,secret --namespace=${FEDERATION_NAMESPACE} --all
|
||||
$host_kubectl delete pvc,pods,svc,rc,deployment,secret --namespace=${FEDERATION_NAMESPACE} --all
|
||||
$host_kubectl delete ns ${FEDERATION_NAMESPACE}
|
||||
|
||||
# Poll until the namespace is completely gone.
|
||||
|
Loading…
Reference in New Issue
Block a user