Skip to content

Commit f3c6706

Browse files
committed
set --allowCascadingDeletion to service-4
1 parent 564b4a9 commit f3c6706

File tree

1 file changed

+69
-5
lines changed

1 file changed

+69
-5
lines changed

docs/user-guide/quickstart.md

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ subnamespaces by default.
623623

624624
HNC will only allow recursive deletion of subnamespaces if those subnamespaces,
625625
or any of their ancestors, have cascading deletion explicitly set. For example,
626-
to delete `service-1`, we first enable cascading deletion and then remove it:
626+
to delete `service-1`, you first enable cascading deletion and then remove it:
627627

628628
```bash
629629
kubectl hns set service-1 --allowCascadingDeletion
@@ -632,12 +632,39 @@ kubectl hns set service-1 --allowCascadingDeletion
632632
kubectl hns set service-1 -a
633633
```
634634

635+
You can check if the `service-1` cascading deletion is enabled from its `.spec.allowCascadingDeletion` field of `HierarchyConfiguration`. If the value is `true`, it's enabled.
636+
637+
```bash
638+
kubectl get hierarchyconfiguration hierarchy -o jsonpath='{.spec}' -n service-1
639+
```
640+
641+
Expected output:
642+
643+
```bash
644+
{"allowCascadingDeletion":true,"parent":"team-a"}
645+
```
646+
635647
Now you can (unsafely!) delete `service-1`:
636648

637649
```bash
638650
kubectl delete subns service-1 -n team-a
639651
```
640652

653+
You can see `service-1` and `dev` subnamespace under `service-1` are deleted.
654+
655+
```bash
656+
kubectl hns tree team-a
657+
```
658+
659+
Expected output:
660+
661+
```bash
662+
team-a
663+
└── [s] service-2
664+
665+
[s] indicates subnamespaces
666+
```
667+
641668
There's an important difference between subnamespaces and regular child
642669
namespace, also known as a full namespace. A subnamespace is created by HNC due
643670
to an anchor being created in the parent; when that anchor is deleted, the
@@ -651,6 +678,8 @@ full namespace itself will _not_ be deleted. However, HNC will mark is as being
651678
in the `ActivitiesHalted (ParentMissing)` condition, as you can see by calling
652679
`kubectl hns describe regular-child`.
653680

681+
_Caution: Any propagated objects inside descendant namespaces will be deleted by deleting a parent namespace._
682+
654683
Let's see this in action. Create another subnamespace `service-4`:
655684

656685
```bash
@@ -668,28 +697,63 @@ kubectl hns tree team-a
668697

669698
Expected output:
670699

671-
```
700+
```bash
672701
team-a
673702
├── [s] service-2
674703
└── [s] service-4
675704
└── staging
676705
```
677706

678-
Now, even if you delete `service-4`, the new `staging` namespace will _not_ be
679-
deleted.
707+
708+
As the same of `service-1`, you can't delete `service-4` subnamespace which is
709+
a parent of `staging` full namespace.
710+
711+
This is both to be consistent with how subnamespaces are treated,
712+
and also because deleting `service-4` will delete any propagated objects
713+
inside `staging`.
714+
715+
```bash
716+
kubectl delete subns service-4 -n team-a
717+
# forbidden
718+
```
719+
720+
So you need to make `service-4` subnamespace `"allowCascadingDeletion":true` to
721+
delete it.
722+
723+
```bash
724+
kubectl hns set service-4 --allowCascadingDeletion
725+
kubectl get hierarchyconfiguration hierarchy -o jsonpath='{.spec}' -n service-4
726+
```
727+
728+
Expected output:
729+
730+
```bash
731+
{"allowCascadingDeletion":true,"parent":"team-a"}
732+
```
733+
734+
Now, you can delete `service-4`.
680735

681736
```bash
682737
kubectl delete subns service-4 -n team-a
683738
kubectl hns tree team-a
684739
```
740+
685741
Output:
686742
```
687743
team-a
688744
└── [s] service-2
689745
```
690746

691747
The `staging` namespace no longer shows up, because it's no longer a descendant
692-
of `team-a`. However, if you look at it directly, you'll see a warning that it's
748+
of `team-a`.
749+
However, unlike the previous example of `service-1` and `dev`, `staging` namespace will _not_ be deleted alogn with its parent `service-4`.
750+
751+
```bash
752+
$ kubectl get namespace staging
753+
# staging namespace will be listed
754+
```
755+
756+
If you look at it directly, you'll see a warning that it's
693757
in a bad state:
694758

695759
```bash

0 commit comments

Comments
 (0)