karmada-io / karmada

Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration
https://karmada.io
Apache License 2.0
4.14k stars 812 forks source link

fix: kubectl karmada deinit doesn't cascade deletion of pvc resources #4750

Open CharlesQQ opened 1 month ago

CharlesQQ commented 1 month ago

What happened:

  1. Create karmada control plane as as the following command: kubectl-karmada init --kube-image-registry=registry.cn-hangzhou.aliyuncs.com/google_containers --storage-classes-name=local-path --etcd-pvc-size='30Gi' --etcd-storage-mode='PVC' --wait-component-ready-timeout=360 --etcd-replicas 3 --karmada-apiserver-replicas 3
  2. pod and pvc created successfully image
  3. remove karmada control plane as the following command: kubectl karmada deinit
  4. pod deleted but pvc not image

What you expected to happen:

pvc should be cascade deleted when etcd pods deleted. Otherwise, etcd pods can't be ready when created again. pvc might be add ownerReferences field, field item is etcd sts.

How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

CharlesQQ commented 1 month ago

After k8s 1.27, support statefulset-pvc-auto-deletion, refer to (https://kubernetes.io/blog/2023/05/04/kubernetes-1-27-statefulset-pvc-auto-deletion-beta/); but earlier version use must delete pvc manually.

CharlesQQ commented 1 month ago

I have a idea, Introduced flag --etcd-sts-pvc-delete-policy=Delete to set field sts.spec.persistentVolumeClaimRetentionPolicy.whenDeleted value

image

XiShanYongYe-Chang commented 1 month ago

I have a idea, Introduced flag --etcd-sts-pvc-delete-policy=Delete to set field sts.spec.persistentVolumeClaimRetentionPolicy.whenDeleted value

I agree with this idea, would you like to submit a PR? The flag name can be discussed in the PR

CharlesQQ commented 1 month ago

I agree with this idea, would you like to submit a PR? The flag name can be discussed in the PR

sure!

XiShanYongYe-Chang commented 1 month ago

In favor of #4759 /assign @CharlesQQ