Skip to content

Commit 0df8f2e

Browse files
committed
"Doc for inclusive configuration of resources to propagate"
Addresses issue kubernetes-retired#221, documentation is added on the `AllowPropagate` sync mode and on the `all` selector. Signed-off-by: mzeevi <[email protected]>
1 parent ec50308 commit 0df8f2e

File tree

2 files changed

+52
-16
lines changed

2 files changed

+52
-16
lines changed

docs/user-guide/concepts.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,28 +322,46 @@ for policy purposes.*
322322

323323
### Exceptions and propagation control
324324

325-
By default, HNC propagates _all_ objects of a [specified type](how-to.md#admin-resources)
326-
from ancestor namespaces to descendant namespaces. However, sometimes this is
327-
too restrictive, and you need to create ***exceptions*** to certain policies. For example:
325+
You can choose whether HNC propagates _all_ objects of a [specified type](how-to.md#admin-resources)
326+
from ancestor namespaces to descendant namespaces by using the `Propagate`
327+
[synchronization mode](how-to.md#modify-the-resources-propagated-by-hnc), or if HNC only
328+
propagates objects of a specified type when selectors are used, using the `AllowPropagate`
329+
synchronization mode.
330+
331+
When `Propagate` [synchronization mode](how-to.md#modify-the-resources-propagated-by-hnc) is
332+
configured for a [specified type](how-to.md#admin-resources), HNC propagates _all_ objects of this type
333+
from ancestor namespaces to descendant namespaces. When `AllowPropagate` synchronization mode
334+
is configured for a specified type, HNC does not propagates _any_ objects of this type
335+
from ancestor namespaces to descendant namespaces. ***Exceptions*** are used to create
336+
certain policies to modify the behavior of the propagation. For example:
328337

329338
* A ResourceQuota was propagated to many children, but one child namespace now
330339
has higher requirements than the rest. Rather than getting rid of the quota in
331340
the parent namespace, or raising the limit for everyone, you can stop the
332341
quota in the parent from being propagated to that _one_ child namespace,
333-
allowing you to replace it with another, more suitable quota.
342+
allowing you to replace it with another, more suitable quota. This is true
343+
when `Propagate` synchronization is set for the type.
334344

335345
* A RoleBinding allows any user to create subnamespaces under one namespace, but
336346
we don’t want to allow those users to create additional levels of hierarchy
337347
underneath those subnamespaces. So you can stop the role binding from being
338-
propagated to _any_ child namespace.
348+
propagated to _any_ child namespace. This is true when `Propagate`
349+
synchronization is set for the type.
350+
351+
* A Secret exists on a namespace but we don't want this secret to get propagated
352+
to all subnamespaces by default but only to one. So you can choose to propagate
353+
to that _one_ child namespace. This is true when `AllowPropagate`
354+
synchronization is set for the type.
355+
339356

340357
Exceptions are defined using [annotations on the objects
341358
themselves](how-to.md#use-limit-propagation). As a result, anyone who can edit
342359
an object can also control how it is propagated to descendant namespaces.
343360

344361
If you modify an exception - for example, by removing it - this could cause
345362
the object to be propagated to descendants from which it had previously been
346-
excluded. This could cause you to accidentally overwrite objects that were
363+
excluded, or be deleted from descendants to which it had previously been
364+
propagated. This could cause you to accidentally overwrite objects that were
347365
intended to be exceptions from higher-level policies, like the ResourceQuota
348366
in the example above. To prevent this, if modifying an exception would cause
349367
HNC to overwrite another object, HNC’s admission controllers will prevent you

docs/user-guide/how-to.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,15 @@ can use any of the following annotations:
366366

367367
* **`propagate.hnc.x-k8s.io/none`**: Setting `none` to `true` (case insensitive)
368368
will result in the object not propagating to _any_ descendant namespace. Any
369-
other value will be rejected.
369+
other value will be rejected. The behavior would be the same as setting
370+
[synchronization mode](#modify-the-resources-propagated-by-hnc) to
371+
`AllowPropagate` with no selectors at all.
372+
373+
* **`propagate.hnc.x-k8s.io/all`**: Setting `all` to `true` (case insensitive)
374+
will result in the object propagating to _any_ descendant namespace. Any
375+
other value will be rejected. The behavior would be the same as setting
376+
[synchronization mode](#modify-the-resources-propagated-by-hnc) to
377+
`Propagate` with no selectors at all.
370378

371379
For example, consider a case with a parent namespace with three child
372380
namespaces, and the parent namespace has a secret called `my-secret`. To set
@@ -388,6 +396,12 @@ To set `my-secret` not to propagate to any namespace, you can use:
388396
kubectl annotate secret my-secret -n parent propagate.hnc.x-k8s.io/none=true
389397
```
390398

399+
To set `my-secret` to propagate to any namespace, you can use:
400+
401+
```bash
402+
kubectl annotate secret my-secret -n parent propagate.hnc.x-k8s.io/all=true
403+
```
404+
391405
All these are equivalent to creating the object with the selector annotations:
392406

393407
```bash
@@ -677,6 +691,10 @@ The most important type of configuration is the way each object type
677691

678692
* **Propagate:** propagates objects from ancestors to descendants and deletes
679693
obsolete descendants.
694+
* **AllowPropagate:** inclusive propagation - only propagates objects from ancestors
695+
to descendants and deletes obsolete descendants when
696+
[selectors](#limit-the-propagation-of-an-object-to-descendant-namespaces) are set
697+
on the object.
680698
* **Remove:** deletes all existing propagated copies, but does not touch source
681699
objects.
682700
* **Ignore:** stops modifying this resource. New or changed objects will not be
@@ -700,7 +718,7 @@ To configure an object resource using the kubectl plugin:
700718

701719
```
702720
# "--group" can be omitted if the resource is a core K8s resource
703-
kubectl hns config set-resource [resource] --group [group] --mode [Propagate|Remove|Ignore]
721+
kubectl-hns config set-resource RESOURCE [--group GROUP] [--force] --mode <Propagate|Remove|Ignore|AllowPropagate>
704722
```
705723

706724
For example:
@@ -737,20 +755,20 @@ spec:
737755
mode: Propagate <<<
738756
```
739757
740-
Adding a new resource in the `Propagate` mode is potentially dangerous, since
741-
there could be existing objects of that resource type that would be overwritten
742-
by objects of the same name from ancestor namespaces. As a result, the HNS
743-
plugin will not allow you to add a new resource directly in the `Propagate`
744-
mode. Instead, to do so safely:
758+
Adding a new resource in the `Propagate` mode or `AllowPropagate` mode is potentially
759+
dangerous, since there could be existing objects of that resource type that
760+
would be overwritten by objects of the same name from ancestor namespaces.
761+
As a result, the HNS plugin will not allow you to add a new resource directly
762+
in the `Propagate` mode or `AlowPropagate`. Instead, to do so safely:
745763

746764
* Add the new resource in the `Remove` mode. This will remove any propagated
747765
copies (of which there should be none) but will force HNC to start
748766
synchronizing all known source objects.
749767
* Wait until `kubectl hns config describe` looks like it's identified the
750768
correct number of objects of the newly added resource in its status.
751-
* Change the propagation mode from `Remove` to `Propagate`. HNC will then check
752-
to see if any objects will be overwritten, and will not allow you to change
753-
the propagation mode until all such conflicts are resolved.
769+
* Change the propagation mode from `Remove` to `Propagate` or `AllowPropagate`.
770+
HNC will then check to see if any objects will be overwritten, and will not
771+
allow you to change the propagation mode until all such conflicts are resolved.
754772

755773
Alternatively, if you're certain you want to start propagating objects
756774
immediately, you can use the `--force` flag with `kubectl hns config

0 commit comments

Comments
 (0)