You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/user-guide/quickstart.md
+69-5Lines changed: 69 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -623,7 +623,7 @@ subnamespaces by default.
623
623
624
624
HNC will only allow recursive deletion of subnamespaces if those subnamespaces,
625
625
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:
627
627
628
628
```bash
629
629
kubectl hns set service-1 --allowCascadingDeletion
@@ -632,12 +632,39 @@ kubectl hns set service-1 --allowCascadingDeletion
632
632
kubectl hns set service-1 -a
633
633
```
634
634
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
+
635
647
Now you can (unsafely!) delete `service-1`:
636
648
637
649
```bash
638
650
kubectl delete subns service-1 -n team-a
639
651
```
640
652
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
+
641
668
There's an important difference between subnamespaces and regular child
642
669
namespace, also known as a full namespace. A subnamespace is created by HNC due
643
670
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
651
678
in the `ActivitiesHalted (ParentMissing)` condition, as you can see by calling
652
679
`kubectl hns describe regular-child`.
653
680
681
+
_Caution: Any propagated objects inside descendant namespaces will be deleted by deleting a parent namespace._
682
+
654
683
Let's see this in action. Create another subnamespace `service-4`:
655
684
656
685
```bash
@@ -668,28 +697,63 @@ kubectl hns tree team-a
668
697
669
698
Expected output:
670
699
671
-
```
700
+
```bash
672
701
team-a
673
702
├── [s] service-2
674
703
└── [s] service-4
675
704
└── staging
676
705
```
677
706
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`.
680
735
681
736
```bash
682
737
kubectl delete subns service-4 -n team-a
683
738
kubectl hns tree team-a
684
739
```
740
+
685
741
Output:
686
742
```
687
743
team-a
688
744
└── [s] service-2
689
745
```
690
746
691
747
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
0 commit comments