forked from kubernetes-sigs/cli-experimental
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kustomize has a new field called "sortOptions" to sort resources: kubernetes-sigs/kustomize#3913 kubernetes-sigs/kustomize#4019 Document what it does and how to use it. Signed-off-by: Yannis Zarkadas <yanniszark@gmail.com>
- Loading branch information
1 parent
28bc5ff
commit d8ea52b
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
site/content/en/references/kustomize/kustomization/sortoptions/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
--- | ||
title: "sortOptions" | ||
linkTitle: "sortOptions" | ||
type: docs | ||
weight: 23 | ||
description: > | ||
Sort the kustomize resources. | ||
--- | ||
|
||
The `sortOptions` field is used to sort the resources kustomize outputs. | ||
|
||
IMPORTANT: | ||
- Currently, this field is enforced only for the top-level kustomization. | ||
- This is the endorsed way to sort resources. Users should avoid using | ||
the CLI flag `--reorder` and instead use `sortOptions`. | ||
|
||
Currently, we support the following sort options: | ||
- `legacy` | ||
- `fifo` | ||
|
||
## Legacy Sorting | ||
|
||
In `legacy` order, kustomize sorts resources by using two priority lists: | ||
- An `orderFirst` list for resources which should be first in the output. | ||
- An `orderLast` list for resources which should be last in the output. | ||
- Resources not on the lists are will appear in-between, sorted by their GVK. | ||
|
||
### Example 1: Legacy Sorting with orderFirst / orderLast lists | ||
|
||
In this example, we use the `legacy` sort order to output `Namespace` objects | ||
first and `Deployment` objects last. | ||
|
||
```yaml | ||
kind: Kustomization | ||
sortOptions: | ||
order: legacy | ||
legacySortOptions: | ||
orderFirst: | ||
- Namespace | ||
orderLast: | ||
- Deployment | ||
``` | ||
### Example 2: Default Legacy Sorting | ||
If you specify `legacy` sort order without any arguments for the lists, | ||
kustomize will fall back to the lists we were using before introducing this | ||
feature. This is useful if you want to continue using the sort order kustomize | ||
was using by-default before introducing this feature. | ||
|
||
These two configs are equivalent: | ||
|
||
```yaml | ||
kind: Kustomization | ||
sortOptions: | ||
order: legacy | ||
``` | ||
|
||
is equivalent to: | ||
|
||
```yaml | ||
kind: Kustomization | ||
sortOptions: | ||
order: legacy | ||
legacySortOptions: | ||
orderFirst: | ||
- Namespace | ||
- ResourceQuota | ||
- StorageClass | ||
- CustomResourceDefinition | ||
- ServiceAccount | ||
- PodSecurityPolicy | ||
- Role | ||
- ClusterRole | ||
- RoleBinding | ||
- ClusterRoleBinding | ||
- ConfigMap | ||
- Secret | ||
- Endpoints | ||
- Service | ||
- LimitRange | ||
- PriorityClass | ||
- PersistentVolume | ||
- PersistentVolumeClaim | ||
- Deployment | ||
- StatefulSet | ||
- CronJob | ||
- PodDisruptionBudget | ||
orderLast: | ||
- MutatingWebhookConfiguration | ||
- ValidatingWebhookConfiguration | ||
``` | ||
|
||
## FIFO Sorting | ||
|
||
In `fifo` order, kustomize does not change the order of resources. They appear | ||
in the order they are loaded in `resources`. | ||
|
||
### Example 3: FIFO Sorting | ||
|
||
```yaml | ||
kind: Kustomization | ||
sortOptions: | ||
order: fifo | ||
``` |