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
@@ -633,7 +633,7 @@ subnamespaces by default.
633
633
634
634
HNC will only allow recursive deletion of subnamespaces if those subnamespaces,
635
635
or any of their ancestors, have cascading deletion explicitly set. For example,
636
-
to delete `service-1`, we first enable cascading deletion and then remove it:
636
+
to delete `service-1`, you first enable cascading deletion and then remove it:
637
637
638
638
```bash
639
639
kubectl hns set service-1 --allowCascadingDeletion
@@ -642,12 +642,39 @@ kubectl hns set service-1 --allowCascadingDeletion
642
642
kubectl hns set service-1 -a
643
643
```
644
644
645
+
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.
646
+
647
+
```bash
648
+
kubectl get hierarchyconfiguration hierarchy -o jsonpath='{.spec}' -n service-1
649
+
```
650
+
651
+
Expected output:
652
+
653
+
```bash
654
+
{"allowCascadingDeletion":true,"parent":"team-a"}
655
+
```
656
+
645
657
Now you can (unsafely!) delete `service-1`:
646
658
647
659
```bash
648
660
kubectl delete subns service-1 -n team-a
649
661
```
650
662
663
+
You can see `service-1` and `dev` subnamespace under `service-1` are deleted.
664
+
665
+
```bash
666
+
kubectl hns tree team-a
667
+
```
668
+
669
+
Expected output:
670
+
671
+
```bash
672
+
team-a
673
+
└── [s] service-2
674
+
675
+
[s] indicates subnamespaces
676
+
```
677
+
651
678
There's an important difference between subnamespaces and regular child
652
679
namespace, also known as a full namespace. A subnamespace is created by HNC due
653
680
to an anchor being created in the parent; when that anchor is deleted, the
@@ -661,6 +688,8 @@ full namespace itself will _not_ be deleted. However, HNC will mark is as being
661
688
in the `ActivitiesHalted (ParentMissing)` condition, as you can see by calling
662
689
`kubectl hns describe regular-child`.
663
690
691
+
_Caution: Any propagated objects inside descendant namespaces will be deleted by deleting a parent namespace._
692
+
664
693
Let's see this in action. Create another subnamespace `service-4`:
665
694
666
695
```bash
@@ -678,28 +707,63 @@ kubectl hns tree team-a
678
707
679
708
Expected output:
680
709
681
-
```
710
+
```bash
682
711
team-a
683
712
├── [s] service-2
684
713
└── [s] service-4
685
714
└── staging
686
715
```
687
716
688
-
Now, even if you delete `service-4`, the new `staging` namespace will _not_ be
689
-
deleted.
717
+
718
+
As the same of `service-1`, you can't delete `service-4` subnamespace which is
719
+
a parent of `staging` full namespace.
720
+
721
+
This is both to be consistent with how subnamespaces are treated,
722
+
and also because deleting `service-4` will delete any propagated objects
723
+
inside `staging`.
724
+
725
+
```bash
726
+
kubectl delete subns service-4 -n team-a
727
+
# forbidden
728
+
```
729
+
730
+
So you need to make `service-4` subnamespace `"allowCascadingDeletion":true` to
731
+
delete it.
732
+
733
+
```bash
734
+
kubectl hns set service-4 --allowCascadingDeletion
735
+
kubectl get hierarchyconfiguration hierarchy -o jsonpath='{.spec}' -n service-4
736
+
```
737
+
738
+
Expected output:
739
+
740
+
```bash
741
+
{"allowCascadingDeletion":true,"parent":"team-a"}
742
+
```
743
+
744
+
Now, you can delete `service-4`.
690
745
691
746
```bash
692
747
kubectl delete subns service-4 -n team-a
693
748
kubectl hns tree team-a
694
749
```
750
+
695
751
Output:
696
752
```
697
753
team-a
698
754
└── [s] service-2
699
755
```
700
756
701
757
The `staging` namespace no longer shows up, because it's no longer a descendant
702
-
of `team-a`. However, if you look at it directly, you'll see a warning that it's
758
+
of `team-a`.
759
+
However, unlike the previous example of `service-1` and `dev`, `staging` namespace will _not_ be deleted alogn with its parent `service-4`.
760
+
761
+
```bash
762
+
$ kubectl get namespace staging
763
+
# staging namespace will be listed
764
+
```
765
+
766
+
If you look at it directly, you'll see a warning that it's
0 commit comments