Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Support DeleteOptions when deleting resources in member clusters #1348

Closed
RolandMa1986 opened this issue Jan 22, 2021 · 2 comments · Fixed by #1355
Closed

Support DeleteOptions when deleting resources in member clusters #1348

RolandMa1986 opened this issue Jan 22, 2021 · 2 comments · Fixed by #1355
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@RolandMa1986
Copy link
Contributor

What would you like to be added:
Support DeleteOptions when deleting resources in member clusters.

Why is this needed:
DeleteOptions may be provided when deleting an object with kube-apiserver, such as GracePeriodSeconds and PropagationPolicy. This is extremely useful when the user wants to control the lifecycle of the federated resources as same as the Kubernetes's way.
ref: DeleteOptions

/kind feature

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 22, 2021
@RolandMa1986
Copy link
Contributor Author

User Story
KubeSphere is a tailored Kubernetes platform for hybrid multi-cloud. It providers an integrated multi-tenant and multi-cluster management solution. Kubefed is used to manage Multi-tenancy resources and workloads crossing clusters. Each workspace(a tenant) may contain one or more namespaces, which are owned by the workspace. When the workspace is being deleted, all the namespaces would be GC too. But sometimes the admin doesn't want the namespaces to be deleted with workspace together, just leave them as orphan namespaces.

In a single cluster, the propagationPolicy field on the deleteOptions is set to "Orphan", so we can stop the GC. However, In Multi-Clusters, the workspace's lifecycle is controlled by the federated workspace, currently, we can't apply the same deleteOptions as same a single cluster.

DeleteOptions Annotation

To apply the DeleteOptions while deleting the resources in the member cluster, a new annotation kubefed.io/deleteoptions is needed, which could be a JSON string of the DeleteOptions type.

apiVersion: types.kubefed.io/v1beta1
kind: Federated <type>
metadata:
  annotations:
    kubefed.io/deleteoptions: '{"kind":"DeleteOptions","apiVersion":"v1","propagationPolicy":"Orphan"}'
  name: <name>
spec:
  placement:
    clusters:
    - name: host
  template:
    ...

Or

kubectl patch <federated type> <name> \
    --type=merge -p '{"metadata": {"annotations": {"kubefed.io/deleteoptions": "{\"kind\":\"DeleteOptions\",\"apiVersion\":\"v1\",\"propagationPolicy\":\"Orphan\"}"}}}'

@RolandMa1986
Copy link
Contributor Author

/assign

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants