@@ -28,19 +28,25 @@ to use ResourceGroup only.
28
28
29
29
### Read standard input resources
30
30
31
- We will add a reserved keyword “-” as a special kpt directory. This "-" accepts resources
32
- from the standard input. For example, ` kustomize build | kpt live apply - `
31
+ We will change the existing ` kpt live apply ` from STDIN to not require the existence of Kptfile (
32
+ to be more specific, the ` inventory ` file from Kptfile). As long as the STDIN contains
33
+ one and only one valid ResourceGroup, ` kpt live apply ` should be able to create/match the
34
+ ResourceGroup in cluster.
33
35
34
36
### Initialize a ` ResourceGroup ` object
35
37
36
- ` kpt live init ` will create a ResourceGroup CR in resourcegroup.yaml. Only three fields
37
- should be given to the CR.
38
+ ` kpt live init ` will create a ResourceGroup CR in resourcegroup.yaml.
39
+
40
+ By default, the ResoureGroup will have name and namespace assigned as below. And users can
41
+ override via existing flags "--name" and "--namespace".
38
42
39
43
- metadata.name: A client-provided valid RFC 1123 DNS subdomain name. Default value has prefix “inventory-” with
40
- 8 digit numbers. E.g. “inventory-02014045”
41
- - metadata.namespace: a valid namespace. default to value “default”
42
- - metadata.labels.cli-utils.sigs.k8s.io/inventory-id: A client-provided valid label.
43
- Default value is a UUID e.g. 7c5af957-a3e2-4d68-8c0f-6c1864a66050
44
+ 8 digit numbers. E.g. "inventory-02014045"
45
+ - metadata.namespace: a valid namespace. default to value "default"
46
+
47
+ If users want to reuse an existing inventory (from Kptfile) or ResourceGroup (which has been deployed to the cluster),
48
+ they shall provide the value of the inventory's inventory-id or the ResourceGroup's "metadata.labels[ 0] .cli-utils.sigs.k8s.io/inventory-id"
49
+ via "--inventory-id" flag.
44
50
45
51
### Convert Inventory to ResourceGroup
46
52
@@ -50,12 +56,12 @@ the ResourceGroup is unique. This requires Kptfile to exist to use `kpt live app
50
56
51
57
To split the Inventory from Kptfile to resourcegroup.yaml and convert the Inventory to
52
58
ResourceGroup, ` kpt live migrate ` should be extended to map the inventory.name,
53
- inventory.namespace, inventory.inventoryID to ResourceGroup CR metadata.name,
59
+ inventory.namespace, inventory.inventoryID to ResourceGroup CR metadata.name,
54
60
metadata.namespace, metadata.labels.cli-utils.sigs.k8s.io/inventory-id correspondingly.
55
61
56
62
Inventory in Kptfile
57
63
``` yaml
58
- apiVersion : kpt.dev/v1betaX
64
+ apiVersion : kpt.dev/v1
59
65
kind : Kptfile
60
66
inventory :
61
67
name : <INVENTORY_NAME>
@@ -73,33 +79,74 @@ metadata
73
79
cli-utils.sigs.k8s.io/inventory-id : <INVENTORY_ID>
74
80
` ` `
75
81
82
+ ### Simplify the Inventory
83
+
84
+ Current inventory contains inventory-id which is required to match the label ` cli-utils.sigs.k8s.io/inventory-id`.
85
+
86
+ For new users, they should no longer need to be exposed to the inventory-id, but kpt will
87
+ build one composed by `name-namespace` on the fly.
88
+
89
+ For existing users, the inventory-id is still
90
+ required in the standalone ResourceGroup file to guarantee the adoption matches, unless they use "--inventory-policy=adopt"
91
+ to override the label. This flag is only required as a one-off via `kpt live apply -` to override the label to `name-namespace`.
92
+
76
93
# ## ResourceGroup as a singleton object
77
94
78
- ` kpt live apply [--resourcegroup-path ] -` from STDIN accepts and only accepts a single
95
+ ` kpt live apply [--resourcegroup-file ] -` from STDIN accepts and only accepts a single
79
96
ResourceGroup, including the ResourceGroup provided by the flag. It detects
80
97
1. If more than one ResourceGroup is found, raise errors and display all the ResourceGroup objects.
81
98
2. If no ResourceGroup is found in STDIN and and Kptfile inventory does not exists, raise errors and suggest users to
82
99
run kpt live init
83
100
3. If no ResourceGroup is found in STDIN and Kptfile inventory exists, raise errors and
84
101
suggest users to run kpt live migrate
85
102
103
+ # ## New flags
104
+
105
+ # ### `--resourcegroup-file`
106
+
107
+ - description : The file path to the ResourceGroup CR, default to `resourcegroup.yaml`
108
+ - short form `--rg`
109
+ - This flag will be added to `kpt live init`, `kpt live migrate` and `kpt live apply`
110
+
111
+ # ### `--name` for invectory
112
+
113
+ - description : The name for the ResourceGroup
114
+ - This flag will continue to be used by `kpt live init`. Rather than overriding the
115
+ inventory.name in Kptfile, it will override the default metadata.name in the standalone ResourceGroup file.
116
+
117
+ # ### `--namespace` for invectory
118
+
119
+ - description : The namespace for the ResourceGroup
120
+ - This flag will continue to be used by `kpt live init`, Rather than overriding the
121
+ inventory.namespace in Kptfile, it will override the default metadata.namespace in the standalone ResourceGroup file.
122
+
123
+ # ### `--inventory-id` for invectory
124
+
125
+ - description : Inventory identifier. This is used to detect overlap between
126
+ two sets of ResourceGroup managed resources that might use the same name and namespace.
127
+ - This flag will continue to be accepted by `kpt live init` for backward compatibility reasons.
128
+ If given, ResourceGroup will store the inventory-id value in "metadata.labels[0].cli-utils.sigs.k8s.io/inventory-id"
129
+ of the ResourceGroup.
130
+ If not given, the ResourceGroup labels will be empty and the value of "<name>-<namespace>" will be
131
+ used as the "cli-utils.sigs.k8s.io/inventory-id" label in `kpt live apply` from STD.
132
+
86
133
# # User Guide
87
134
88
135
# ## To hydrate via kustomize and deploy via kpt
89
136
90
137
# ### Day 1
91
138
92
- <b> For new users to start from scratch (no Kptfile)</b>
139
+ # #### For new users to start from scratch (no Kptfile)
93
140
User can run `kpt live init [--resourcegroup-file=CUSTOM_RG.yaml]` to create a
94
141
ResourceGroup object and store it in a resourcegroup.yaml file.
95
142
Users can customize the file path with the flag “--resourcegroup-file”.
96
143
97
- <b> For existing kpt users to migrate from Kptfile</b>
144
+ # #### For existing kpt users to migrate from Kptfile
98
145
Users run `kpt live migrate [--resourcegroup-file=CUSTOM_RG.yaml]` to convert the
99
146
Inventory object from Kptfile to a standalone resourcegroup.yaml file.
100
147
Users can customize the file path with the flag “--resourcegroup-file”.
101
148
102
- <b> [optional] : Add shareable ResourceGroup to kustomize resources</b>
149
+ # #### [optional]: Add shareable ResourceGroup to kustomize resources
103
150
If the ResourceGroup is expected to be shared in the Gitops workflow, users can add
104
151
the resourcegroup.yaml file path to the .resources field in kustomization.yaml.
105
152
This simplifies the Day N deployment by omitting the “–resourcegroup-file“ flag.
@@ -116,11 +163,11 @@ This simplifies the Day N deployment by omitting the “–resourcegroup-file“
116
163
117
164
# ### Day 1
118
165
119
- <b> For new users to start from scratch (no Kptfile)</b>
166
+ # #### For new users to start from scratch (no Kptfile)
120
167
User can run `kpt live init --resourcegroup-file=<DIR>/resourcegroup.yaml` to create
121
168
a ResourceGroup object and store it in the helm template <DIR>.
122
169
123
- <b> For existing kpt users to migrate from Kptfile</b>
170
+ # #### For existing kpt users to migrate from Kptfile
124
171
Users run `kpt live migrate --resourcegroup-file=<DIR>/resourcegroup.yaml` to convert
125
172
the Inventory object from Kptfile to a standalone resourcegroup.yaml file.
126
173
@@ -180,7 +227,7 @@ the ResourceGroup unintentionally (e.g. via kubectl apply).
180
227
181
228
inventory.yaml
182
229
` ` ` yaml
183
- apiVersion: kpt.dev/v1betaX
230
+ apiVersion: kpt.dev/v1
184
231
kind: Inventory
185
232
metadata:
186
233
name: <INVENTORY_NAME>
@@ -205,7 +252,7 @@ inventoryID: <INVENTORY_ID>
205
252
206
253
inventory.yaml
207
254
` ` ` yaml
208
- apiVersion: kpt.dev/v1betaX
255
+ apiVersion: kpt.dev/v1
209
256
kind: Inventory
210
257
spec:
211
258
resourceGroup:
0 commit comments