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
{{ message }}
This repository was archived by the owner on Apr 17, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: docs/user-guide/concepts.md
+67-2
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ namespaces are, and _why_ they behave the way they do.
13
13
*[Basic concepts](#basic)
14
14
*[Parents, children, trees and forests](#basic-trees)
15
15
*[Full namespaces and subnamespaces](#basic-subns)
16
+
*[Hierarchical resource quotas (HRQs)](#hrq)
16
17
*[Policy inheritance and object propagation](#basic-propagation)
17
18
*[Tree labels and non-propagated policies](#basic-labels)
18
19
*[Exceptions and propagation control](#basic-exceptions)
@@ -87,6 +88,8 @@ namespaces:
87
88
as isolation units for their own services. However, namespace creation is a
88
89
privileged cluster-level operation, and you typically want to control this
89
90
privilege very closely.
91
+
* You might want to give some amount of resources to a team (similar to `ResourceQuota`), and they can
92
+
distribute those resources between their subnamespaces.
90
93
* Finally, you might want to avoid having to find unique names for every
91
94
namespace in the cluster.
92
95
@@ -218,6 +221,68 @@ probably not a great idea.
218
221
You can create a subnamespace from the command line via `kubectl hns create child
219
222
-n parent`.
220
223
224
+
<aname="hrq">
225
+
226
+
### Hierarchical resource quotas (HRQs)
227
+
228
+
***Hierarchical resource quotas are beta in HNC v1.1***
229
+
230
+
When you want to give some amount of resources to `team-a`, and want them to be able to
231
+
flexibly use resources in any of their subnamespaces, you create a `HierarchicalResourceQuota`
232
+
in namespace `team-a`. The sum of all resources from all the subnamespaces of the
233
+
members wont be over the amount of resources that is configured in
234
+
`HierarchicalResourceQuota` of namespace `team-a`. All of the reasources of `team-a` are
235
+
equally shared between the applications in their subnamespaces, which is very efficient.
236
+
237
+
In addition, you can let an org or team's admin create their own hierarchical
238
+
quotas without violating the overall HRQ for their org or team. For example,
239
+
if you start with the following structure:
240
+
```
241
+
company-a
242
+
├── organization-a
243
+
│ ├── org-a-team-1
244
+
│ ├── org-a-team-2
245
+
│ ...
246
+
├── organization-b
247
+
│ ├── org-b-team-1
248
+
│ ├── org-b-team-2
249
+
│ ...
250
+
...
251
+
```
252
+
Instead of each team asking from the `cluster-admin` to modify their `ResourceQuota`,
253
+
you can insert an additional "policy" namespace above each level to hold
254
+
the policy objects (like hierarchical quota) that the sub-admin _cannot_
255
+
change, while giving them permission to create their own quotas in the
256
+
lower level namespaces, like this:
257
+
```
258
+
company-a-policy
259
+
└── company-a
260
+
```
261
+
And put the resources HRQ in the `company-a-policy` namespace. This will restrict
262
+
whole `company-a` to the amount of resources that they are paying for. Then `company-a`
263
+
can do similar HRQ with their organizations:
264
+
```
265
+
company-a-policy (has HRQ)
266
+
└── company-a
267
+
├── org-a-policy (has HRQ)
268
+
│ └── organization-a
269
+
├── org-b-policy (has HRQ)
270
+
│ └── organization-b
271
+
...
272
+
```
273
+
Lower-level quotas cannot override more restrictive quotas from ancestor namespaces;
274
+
the most restrictive quota always wins.
275
+
This way each individual can fairly and securely distribute their resources across
276
+
their members.
277
+
278
+
To implement hierarchical quotas, HNC automatically creates `ResourceQuota` objects in each
279
+
affected namespace. This is a part of the internal implementation and shouldn't be modified or
280
+
inspected. Use the `kubectl hns hrq` command to inspect hierarchical quotas,
281
+
or look at the `HierarchicalResourceQuota` object in the ancestor
282
+
namespaces.
283
+
284
+
Note: Decimal point values cannot be specified in HRQ (you can't do `cpu: 1.5` but you can do `cpu: "1.5"` or `cpu: 1500m`). See [#292](https://github.com/kubernetes-sigs/hierarchical-namespaces/issues/292)
285
+
221
286
<aname="basic-propagation">
222
287
223
288
### Policy inheritance and object propagation
@@ -327,7 +392,7 @@ HNC typically propagates _all_ objects of a [specified type](how-to.md#admin-res
327
392
from ancestor namespaces to descendant namespaces. However, sometimes this is
328
393
too restrictive, and you need to create ***exceptions*** to certain policies. For example:
329
394
330
-
* A ResourceQuota was propagated to many children, but one child namespace now
395
+
* A `ResourceQuota` was propagated to many children, but one child namespace now
331
396
has higher requirements than the rest. Rather than getting rid of the quota in
332
397
the parent namespace, or raising the limit for everyone, you can stop the
333
398
quota in the parent from being propagated to that _one_ child namespace,
@@ -345,7 +410,7 @@ an object can also control how it is propagated to descendant namespaces.
345
410
If you modify an exception - for example, by removing it - this could cause
346
411
the object to be propagated to descendants from which it had previously been
347
412
excluded. This could cause you to accidentally overwrite objects that were
348
-
intended to be exceptions from higher-level policies, like the ResourceQuota
413
+
intended to be exceptions from higher-level policies, like the `ResourceQuota`
349
414
in the example above. To prevent this, if modifying an exception would cause
350
415
HNC to overwrite another object, HNC’s admission controllers will prevent you
351
416
from modifying the object, and will identify the objects that would have been
*[Select namespaces based on their hierarchies](#use-select)
14
15
*[Delete a subnamespace](#use-subns-delete)
15
16
*[Organize full namespaces into a hierarchy](#use-full)
@@ -186,6 +187,19 @@ permissions. To understand why an object is not being propagated to a namespace,
186
187
use `kubectl hns describe <ns>`, where `<ns>` is either the source (ancestor) or
187
188
destination (descendant) namespace.
188
189
190
+
<aname="use-hrq"/>
191
+
192
+
### Limit Resources over parent namespaces
193
+
194
+
***Hierarchical resource quotas are beta in HNC v1.1***
195
+
196
+
HNC has an object called `HierarchicalResourceQuota` which is a drop-in replacement for `ResourceQuota`
197
+
but across all the namespaces in a hierarchy. It allows you to distribute your resources between
198
+
teams, and those teams can distribute their resources between their subteams.
199
+
[Learn how it works](concepts.md#hierarchical-resource-quota) or see an [quickstart example](quickstart.md#hrq)
200
+
201
+
Note: Decimal point values cannot be specified in HRQ (you can't do `cpu: 1.5` but you can do `cpu: "1.5"` or `cpu: 1500m`). See [#292](https://github.com/kubernetes-sigs/hierarchical-namespaces/issues/292)
and you can delete the hrq via simply deleting the CR:
548
+
```bash
549
+
kubectl delete hrq acme-org-hrq -n acme-org
550
+
```
551
+
552
+
Note: Decimal point values cannot be specified (you can't do `cpu: 1.5` but you can do `cpu: "1.5"` or `cpu: 1500m`). See [#292](https://github.com/kubernetes-sigs/hierarchical-namespaces/issues/292)
553
+
461
554
<a name="subns"/>
462
555
463
556
### Subnamespaces deep dive
@@ -672,7 +765,7 @@ Of course, the annotation can also be part of the object when you create it:
0 commit comments