|
| 1 | +--- |
| 2 | +title: Kustomize File Processing Integration |
| 3 | +authors: |
| 4 | + - "@pwittrock" |
| 5 | +owning-sig: sig-cli |
| 6 | +participating-sigs: |
| 7 | + - sig-apps |
| 8 | + - sig-api-machinery |
| 9 | +reviewers: |
| 10 | + - "@apelisse" |
| 11 | + - "@monopole" |
| 12 | + - "@anguslees" |
| 13 | +approvers: |
| 14 | + - "@monopole" |
| 15 | +editors: |
| 16 | + - "@pwittrock" |
| 17 | +creation-date: 2019-03-1 |
| 18 | +last-updated: 2019-03-1 |
| 19 | +status: implementable |
| 20 | +see-also: |
| 21 | +replaces: |
| 22 | +superseded-by: |
| 23 | + - n/a |
| 24 | +--- |
| 25 | + |
| 26 | +# Kustomize Resource Ordering |
| 27 | + |
| 28 | +## Table of Contents |
| 29 | +* [Table of Contents](#table-of-contents) |
| 30 | +* [Summary](#summary) |
| 31 | +* [Motivation](#motivation) |
| 32 | + * [Goals](#goals) |
| 33 | + * [Non-Goals](#non-goals) |
| 34 | +* [Proposal](#proposal) |
| 35 | + * [Implementation Details/Notes/Constraints](#implementation-detailsnotesconstraints) |
| 36 | + * [Risks and Mitigations](#risks-and-mitigations) |
| 37 | +* [Graduation Criteria](#graduation-criteria) |
| 38 | +* [Implementation History](#implementation-history) |
| 39 | +* [Alternatives](#alternatives) |
| 40 | + |
| 41 | +[Tools for generating]: https://github.com/ekalinin/github-markdown-toc |
| 42 | + |
| 43 | +## Summary |
| 44 | + |
| 45 | +Kustomize orders Resource creation by sorting the Resources it emits based off their type. While |
| 46 | +this works well for most types (e.g. create Namespaces before other things), it doesn't work |
| 47 | +in all cases and users will need the ability to break glass. |
| 48 | + |
| 49 | +See [kubernetes-sigs/kustomize#836] for an example. |
| 50 | + |
| 51 | +## Motivation |
| 52 | + |
| 53 | +Users may need direct control of the Resource create / update / delete ordering in cases were |
| 54 | +sorting by Resource Type is insufficient. |
| 55 | + |
| 56 | +### Goals |
| 57 | + |
| 58 | +- Provide the ability for users to break glass and override Kustomize's sort ordering. |
| 59 | + |
| 60 | +### Non-Goals |
| 61 | + |
| 62 | +## Proposal |
| 63 | + |
| 64 | +Add a new field `resourceOrdering` that is a list of `key, value, type` tuples to define the ordering. |
| 65 | + |
| 66 | +Example: |
| 67 | + |
| 68 | +``` |
| 69 | +resourceOrdering: |
| 70 | +- type: label |
| 71 | + key: some-label-name-1 |
| 72 | + value: some-label-value-1 |
| 73 | +- type: annotation |
| 74 | + key: some-annotation-name-a |
| 75 | + value: some-annotation-value-b |
| 76 | +- type: label |
| 77 | + key: some-label-name-1 |
| 78 | + value: some-label-value-2 |
| 79 | +- type: label |
| 80 | + key: some-label-name-2 |
| 81 | + value: some-label-value-2 |
| 82 | +``` |
| 83 | + |
| 84 | +The explicit user defined ordering using labels and annotations would take precedence over the |
| 85 | + ordering based off types. Types would be used as a secondary sorting function. |
| 86 | + |
| 87 | +- Resources labeled with `some-label-name-1=some-label-value-1` are first |
| 88 | + - These Resources are sorted by type |
| 89 | +- Resources annotated with `some-annotation-name-a=some-annotation-value-b` are second |
| 90 | + - These Resources are sorted by type |
| 91 | +- Resources labeled with `some-label-name-1=some-label-value-2` are third |
| 92 | + - These Resources are sorted by type |
| 93 | +- Resources labeled with `some-label-name-4=some-label-value-2` are fourth |
| 94 | + - These Resources are sorted by type |
| 95 | +- Resources not matching any label or annotation are last |
| 96 | + - These Resources are sorted by type |
| 97 | + |
| 98 | +Resources matching multiple orderings (e.g. have multiple matching labels and annotations) appear |
| 99 | +in the position matching the earliest label / annotation. |
| 100 | + |
| 101 | +### Risks and Mitigations |
| 102 | + |
| 103 | +Risk: Users build complex orderings that are hard to reason about. |
| 104 | +Mitigation: Good documentation and recommendations about how to keep things simple. |
| 105 | + |
| 106 | +## Graduation Criteria |
| 107 | + |
| 108 | +NA |
| 109 | + |
| 110 | + |
| 111 | +## Docs |
| 112 | + |
| 113 | +Update Kubectl Book and Kustomize Documentation |
| 114 | + |
| 115 | +## Test plan |
| 116 | + |
| 117 | +Unit Tests for: |
| 118 | + |
| 119 | +- [ ] Resources with labels and annotations follow the ordering override semantics |
| 120 | +- [ ] Resources matching multiple orderings land in the right spot |
| 121 | +- [ ] Resources are sorted by type as a secondary factor |
| 122 | +- [ ] Having multiple labels / annotations with the same key and different values works correctly |
| 123 | +- [ ] Having multiple labels / annotations with different keys and the same values works correctly |
| 124 | +- [ ] Mixing labels and annotations works |
| 125 | +- [ ] Unrecognized type values throw and error |
| 126 | +- [ ] Resources that don't appear in the ordering overrides appear last and are sorted by type |
| 127 | + |
| 128 | +### Version Skew Tests |
| 129 | + |
| 130 | +## Implementation History |
| 131 | + |
| 132 | +## Alternatives |
0 commit comments