| 1 |
|
| 2 |
package commands |
| 3 |
|
| 4 |
var AnnotateShort = `[Alpha] Set an annotation on Resources.` |
| 5 |
var AnnotateLong = ` |
| 6 |
[Alpha] Set an annotation on Resources. |
| 7 |
|
| 8 |
DIR: |
| 9 |
Path to local directory. |
| 10 |
` |
| 11 |
var AnnotateExamples = ` |
| 12 |
kustomize cfg annotate my-dir/ --kv foo=bar |
| 13 |
|
| 14 |
kustomize cfg annotate my-dir/ --kv foo=bar --kv a=b |
| 15 |
|
| 16 |
kustomize cfg annotate my-dir/ --kv foo=bar --kind Deployment --name foo` |
| 17 |
|
| 18 |
var CatShort = `[Alpha] Print Resource Config from a local directory.` |
| 19 |
var CatLong = ` |
| 20 |
[Alpha] Print Resource Config from a local directory. |
| 21 |
|
| 22 |
DIR: |
| 23 |
Path to local directory. |
| 24 |
` |
| 25 |
var CatExamples = ` |
| 26 |
# print Resource config from a directory |
| 27 |
kustomize cfg cat my-dir/ |
| 28 |
|
| 29 |
# wrap Resource config from a directory in an ResourceList |
| 30 |
kustomize cfg cat my-dir/ --wrap-kind ResourceList --wrap-version config.kubernetes.io/v1alpha1 --function-config fn.yaml |
| 31 |
|
| 32 |
# unwrap Resource config from a directory in an ResourceList |
| 33 |
... | kustomize cfg cat` |
| 34 |
|
| 35 |
var CompletionShort = `Generate shell completion.` |
| 36 |
var CompletionLong = ` |
| 37 |
Generate shell completion for ` + "`" + `kustomize` + "`" + ` -- supports bash, zsh, fish and powershell. |
| 38 |
` |
| 39 |
var CompletionExamples = ` |
| 40 |
# load completion for Bash |
| 41 |
source <(kustomize completion bash) |
| 42 |
|
| 43 |
# install for Bash in Linux |
| 44 |
kustomize completion bash > /etc/bash_completion.d/kustomize |
| 45 |
|
| 46 |
# install for Bash in MacOS |
| 47 |
kustomize completion bash > /usr/local/etc/bash_completion.d/kustomize |
| 48 |
|
| 49 |
# package for Bash |
| 50 |
kustomize completion bash > /usr/share/bash-completion/completions/kustomize |
| 51 |
|
| 52 |
# package for zsh |
| 53 |
kustomize completion zsh > /usr/share/zsh/site-functions/_kustomize |
| 54 |
` |
| 55 |
|
| 56 |
var CountShort = `[Alpha] Count Resources Config from a local directory.` |
| 57 |
var CountLong = ` |
| 58 |
[Alpha] Count Resources Config from a local directory. |
| 59 |
|
| 60 |
DIR: |
| 61 |
Path to local directory. |
| 62 |
` |
| 63 |
var CountExamples = ` |
| 64 |
# print Resource counts from a directory |
| 65 |
kustomize cfg count my-dir/` |
| 66 |
|
| 67 |
var CreateSetterShort = `[Alpha] Create a custom setter for a Resource field` |
| 68 |
var CreateSetterLong = ` |
| 69 |
Create a custom setter for a Resource field by inlining OpenAPI as comments. |
| 70 |
|
| 71 |
DIR |
| 72 |
|
| 73 |
A directory containing Resource configuration. |
| 74 |
|
| 75 |
NAME |
| 76 |
|
| 77 |
The name of the setter to create. |
| 78 |
|
| 79 |
VALUE |
| 80 |
|
| 81 |
The current value of the field, or a substring within the field. |
| 82 |
` |
| 83 |
var CreateSetterExamples = ` |
| 84 |
# create a setter for port fields matching "8080" |
| 85 |
kustomize cfg create-setter DIR/ port 8080 --type "integer" --field port \ |
| 86 |
--description "default port used by the app" |
| 87 |
|
| 88 |
# create a setter for a substring of a field rather than the full field -- e.g. only the |
| 89 |
# image tag, not the full image |
| 90 |
kustomize cfg create-setter DIR/ image-tag v1.0.1 --type "string" \ |
| 91 |
--field image --description "current stable release"` |
| 92 |
|
| 93 |
var DeleteSetterShort = `[Alpha] Delete a custom setter for a Resource field` |
| 94 |
var DeleteSetterLong = ` |
| 95 |
Delete a custom setter for a Resource field. |
| 96 |
|
| 97 |
DIR |
| 98 |
|
| 99 |
A directory containing Resource configuration. |
| 100 |
|
| 101 |
NAME |
| 102 |
|
| 103 |
The name of the setter to create. |
| 104 |
` |
| 105 |
var DeleteSetterExamples = ` |
| 106 |
# delete a setter for port |
| 107 |
kustomize cfg create-setter DIR/ port` |
| 108 |
|
| 109 |
var FmtShort = `[Alpha] Format yaml configuration files.` |
| 110 |
var FmtLong = ` |
| 111 |
[Alpha] Format yaml configuration files. |
| 112 |
|
| 113 |
Fmt will format input by ordering fields and unordered list items in Kubernetes |
| 114 |
objects. Inputs may be directories, files or stdin, and their contents must |
| 115 |
include both apiVersion and kind fields. |
| 116 |
|
| 117 |
- Stdin inputs are formatted and written to stdout |
| 118 |
- File inputs (args) are formatted and written back to the file |
| 119 |
- Directory inputs (args) are walked, each encountered .yaml and .yml file |
| 120 |
acts as an input |
| 121 |
|
| 122 |
For inputs which contain multiple yaml documents separated by \n---\n, |
| 123 |
each document will be formatted and written back to the file in the original |
| 124 |
order. |
| 125 |
|
| 126 |
Field ordering roughly follows the ordering defined in the source Kubernetes |
| 127 |
resource definitions (i.e. go structures), falling back on lexicographical |
| 128 |
sorting for unrecognized fields. |
| 129 |
|
| 130 |
Unordered list item ordering is defined for specific Resource types and |
| 131 |
field paths. |
| 132 |
|
| 133 |
- .spec.template.spec.containers (by element name) |
| 134 |
- .webhooks.rules.operations (by element value) |
| 135 |
` |
| 136 |
var FmtExamples = ` |
| 137 |
# format file1.yaml and file2.yml |
| 138 |
kustomize cfg fmt file1.yaml file2.yml |
| 139 |
|
| 140 |
# format all *.yaml and *.yml recursively traversing directories |
| 141 |
kustomize cfg fmt my-dir/ |
| 142 |
|
| 143 |
# format kubectl output |
| 144 |
kubectl get -o yaml deployments | kustomize cfg fmt |
| 145 |
|
| 146 |
# format kustomize output |
| 147 |
kustomize build | kustomize cfg fmt` |
| 148 |
|
| 149 |
var GrepShort = `[Alpha] Search for matching Resources in a directory or from stdin` |
| 150 |
var GrepLong = ` |
| 151 |
[Alpha] Search for matching Resources in a directory or from stdin. |
| 152 |
|
| 153 |
QUERY: |
| 154 |
Query to match expressed as 'path.to.field=value'. |
| 155 |
Maps and fields are matched as '.field-name' or '.map-key' |
| 156 |
List elements are matched as '[list-elem-field=field-value]' |
| 157 |
The value to match is expressed as '=value' |
| 158 |
'.' as part of a key or value can be escaped as '\.' |
| 159 |
|
| 160 |
DIR: |
| 161 |
Path to local directory. |
| 162 |
` |
| 163 |
var GrepExamples = ` |
| 164 |
# find Deployment Resources |
| 165 |
kustomize cfg grep "kind=Deployment" my-dir/ |
| 166 |
|
| 167 |
# find Resources named nginx |
| 168 |
kustomize cfg grep "metadata.name=nginx" my-dir/ |
| 169 |
|
| 170 |
# use tree to display matching Resources |
| 171 |
kustomize cfg grep "metadata.name=nginx" my-dir/ | kustomize cfg tree |
| 172 |
|
| 173 |
# look for Resources matching a specific container image |
| 174 |
kustomize cfg grep "spec.template.spec.containers[name=nginx].image=nginx:1\.7\.9" my-dir/ | kustomize cfg tree` |
| 175 |
|
| 176 |
var InitShort = `[Alpha] Initialize a directory with a Krmfile.` |
| 177 |
var InitLong = ` |
| 178 |
[Alpha] Initialize a directory with a Krmfile. |
| 179 |
|
| 180 |
DIR: |
| 181 |
Path to local directory. |
| 182 |
` |
| 183 |
var InitExamples = ` |
| 184 |
# create a Krmfile in the local directory |
| 185 |
kustomize cfg init |
| 186 |
|
| 187 |
# create a Krmfile in my-dir/ |
| 188 |
kustomize cfg init my-dir/` |
| 189 |
|
| 190 |
var ListSettersShort = `[Alpha] List setters for Resources.` |
| 191 |
var ListSettersLong = ` |
| 192 |
List setters for Resources. |
| 193 |
|
| 194 |
DIR |
| 195 |
|
| 196 |
A directory containing Resource configuration. |
| 197 |
|
| 198 |
NAME |
| 199 |
|
| 200 |
Optional. The name of the setter to display. |
| 201 |
` |
| 202 |
var ListSettersExamples = ` |
| 203 |
Show setters: |
| 204 |
|
| 205 |
$ kustomize cfg list-setters DIR/ |
| 206 |
NAME DESCRIPTION VALUE TYPE COUNT SETBY |
| 207 |
name-prefix '' PREFIX string 2` |
| 208 |
|
| 209 |
var MergeShort = `[Alpha] Merge Resource configuration files` |
| 210 |
var MergeLong = ` |
| 211 |
[Alpha] Merge Resource configuration files |
| 212 |
|
| 213 |
Merge reads Kubernetes Resource yaml configuration files from stdin or sources packages and write |
| 214 |
the result to stdout or a destination package. |
| 215 |
|
| 216 |
Resources are merged using the Resource [apiVersion, kind, name, namespace] as the key. If any of |
| 217 |
these are missing, merge will default the missing values to empty. |
| 218 |
|
| 219 |
Resources specified later are high-precedence (the source) and Resources specified |
| 220 |
earlier are lower-precedence (the destination). |
| 221 |
|
| 222 |
For information on merge rules, run: |
| 223 |
|
| 224 |
kustomize cfg docs merge |
| 225 |
` |
| 226 |
var MergeExamples = ` |
| 227 |
cat resources_and_patches.yaml | kustomize cfg merge > merged_resources.yaml` |
| 228 |
|
| 229 |
var Merge3Short = `[Alpha] Merge diff of Resource configuration files into a destination (3-way)` |
| 230 |
var Merge3Long = ` |
| 231 |
[Alpha] Merge diff of Resource configuration files into a destination (3-way) |
| 232 |
|
| 233 |
Merge3 performs a 3-way merge by applying the diff between 2 sets of Resources to a 3rd set. |
| 234 |
|
| 235 |
Merge3 may be for rebasing changes to a forked set of configuration -- e.g. compute the difference between the original |
| 236 |
set of Resources that was forked and an updated set of those Resources, then apply that difference to the fork. |
| 237 |
|
| 238 |
If a field value differs between the ORIGINAL_DIR and UPDATED_DIR, the value from the UPDATED_DIR is taken and applied |
| 239 |
to the Resource in the DEST_DIR. |
| 240 |
|
| 241 |
For information on merge rules, run: |
| 242 |
|
| 243 |
kustomize cfg docs-merge3 |
| 244 |
` |
| 245 |
var Merge3Examples = ` |
| 246 |
kustomize cfg merge3 --ancestor a/ --from b/ --to c/` |
| 247 |
|
| 248 |
var RunFnsShort = `[Alpha] Reoncile config functions to Resources.` |
| 249 |
var RunFnsLong = ` |
| 250 |
[Alpha] Reconcile config functions to Resources. |
| 251 |
|
| 252 |
run sequentially invokes all config functions in the directory, providing Resources |
| 253 |
in the directory as input to the first function, and writing the output of the last |
| 254 |
function back to the directory. |
| 255 |
|
| 256 |
The ordering of functions is determined by the order they are encountered when walking the |
| 257 |
directory. To clearly specify an ordering of functions, multiple functions may be |
| 258 |
declared in the same file, separated by '---' (the functions will be invoked in the |
| 259 |
order they appear in the file). |
| 260 |
|
| 261 |
#### Arguments: |
| 262 |
|
| 263 |
DIR: |
| 264 |
Path to local directory. |
| 265 |
|
| 266 |
#### Config Functions: |
| 267 |
|
| 268 |
Config functions are specified as Kubernetes types containing a metadata.annotations.[config.kubernetes.io/function] |
| 269 |
field specifying an image for the container to run. This image tells run how to invoke the container. |
| 270 |
|
| 271 |
Example config function: |
| 272 |
|
| 273 |
# in file example/fn.yaml |
| 274 |
apiVersion: fn.example.com/v1beta1 |
| 275 |
kind: ExampleFunctionKind |
| 276 |
metadata: |
| 277 |
annotations: |
| 278 |
config.kubernetes.io/function: | |
| 279 |
container: |
| 280 |
# function is invoked as a container running this image |
| 281 |
image: gcr.io/example/examplefunction:v1.0.1 |
| 282 |
config.kubernetes.io/local-config: "true" # tools should ignore this |
| 283 |
spec: |
| 284 |
configField: configValue |
| 285 |
|
| 286 |
In the preceding example, 'kustomize fn run example/' would identify the function by |
| 287 |
the metadata.annotations.[config.kubernetes.io/function] field. It would then write all Resources in the directory to |
| 288 |
a container stdin (running the gcr.io/example/examplefunction:v1.0.1 image). It |
| 289 |
would then write the container stdout back to example/, replacing the directory |
| 290 |
file contents. |
| 291 |
|
| 292 |
See ` + "`" + `kustomize help cfg docs-fn` + "`" + ` for more details on writing functions. |
| 293 |
` |
| 294 |
var RunFnsExamples = ` |
| 295 |
kustomize fn run example/` |
| 296 |
|
| 297 |
var SetShort = `[Alpha] Set values on Resources fields values.` |
| 298 |
var SetLong = ` |
| 299 |
Set values on Resources fields. May set either the complete or partial field value. |
| 300 |
|
| 301 |
` + "`" + `set` + "`" + ` identifies setters using field metadata published as OpenAPI extensions. |
| 302 |
` + "`" + `set` + "`" + ` parses both the Kubernetes OpenAPI, as well OpenAPI published inline in |
| 303 |
the configuration as comments. |
| 304 |
|
| 305 |
` + "`" + `set` + "`" + ` maybe be used to: |
| 306 |
|
| 307 |
- edit configuration programmatically from the cli |
| 308 |
- create reusable bundles of configuration with custom setters |
| 309 |
|
| 310 |
DIR |
| 311 |
|
| 312 |
A directory containing Resource configuration. |
| 313 |
|
| 314 |
NAME |
| 315 |
|
| 316 |
Optional. The name of the setter to perform or display. |
| 317 |
|
| 318 |
VALUE |
| 319 |
|
| 320 |
Optional. The value to set on the field. |
| 321 |
|
| 322 |
|
| 323 |
To print the possible setters for the Resources in a directory, run |
| 324 |
` + "`" + `list-setters` + "`" + ` on a directory -- e.g. ` + "`" + `kustomize cfg list-setters DIR/` + "`" + `. |
| 325 |
|
| 326 |
#### Tips |
| 327 |
|
| 328 |
- A description of the value may be specified with ` + "`" + `--description` + "`" + `. |
| 329 |
- The last setter for the field's value may be defined with ` + "`" + `--set-by` + "`" + `. |
| 330 |
- Create custom setters on Resources, Kustomization.yaml's, patches, etc |
| 331 |
|
| 332 |
The description and setBy fields are left unmodified unless specified with flags. |
| 333 |
|
| 334 |
To create a custom setter for a field see: ` + "`" + `kustomize help cfg create-setter` + "`" + ` |
| 335 |
` |
| 336 |
var SetExamples = ` |
| 337 |
Resource YAML: Name Prefix Setter |
| 338 |
|
| 339 |
# DIR/resources.yaml |
| 340 |
... |
| 341 |
metadata: |
| 342 |
name: PREFIX-app1 # {"type":"string","x-kustomize":{"setter":[{"name":"name-prefix","value":"PREFIX"}]}} |
| 343 |
... |
| 344 |
--- |
| 345 |
... |
| 346 |
metadata: |
| 347 |
name: PREFIX-app2 # {"type":"string","x-kustomize":{"setter":[{"name":"name-prefix","value":"PREFIX"}]}} |
| 348 |
... |
| 349 |
|
| 350 |
List setters: Show the possible setters |
| 351 |
|
| 352 |
$ config list-setters DIR/ |
| 353 |
NAME DESCRIPTION VALUE TYPE COUNT SETBY |
| 354 |
name-prefix '' PREFIX string 2 |
| 355 |
|
| 356 |
Perform set: set a new value, owner and description |
| 357 |
|
| 358 |
$ kustomize cfg set DIR/ name-prefix "test" --description "test environment" --set-by "dev" |
| 359 |
set 2 values |
| 360 |
|
| 361 |
List setters: Show the new values |
| 362 |
|
| 363 |
$ config list-setters DIR/ |
| 364 |
NAME DESCRIPTION VALUE TYPE COUNT SETBY |
| 365 |
name-prefix 'test environment' test string 2 dev |
| 366 |
|
| 367 |
New Resource YAML: |
| 368 |
|
| 369 |
# DIR/resources.yaml |
| 370 |
... |
| 371 |
metadata: |
| 372 |
name: test-app1 # {"description":"test environment","type":"string","x-kustomize":{"setBy":"dev","setter":[{"name":"name-prefix","value":"test"}]}} |
| 373 |
... |
| 374 |
--- |
| 375 |
... |
| 376 |
metadata: |
| 377 |
name: test-app2 # {"description":"test environment","type":"string","x-kustomize":{"setBy":"dev","setter":[{"name":"name-prefix","value":"test"}]}} |
| 378 |
...` |
| 379 |
|
| 380 |
var SinkShort = `[Alpha] Implement a Sink by writing input to a local directory.` |
| 381 |
var SinkLong = ` |
| 382 |
[Alpha] Implement a Sink by writing input to a local directory. |
| 383 |
|
| 384 |
kustomize fn sink [DIR] |
| 385 |
|
| 386 |
DIR: |
| 387 |
Path to local directory. If unspecified, sink will write to stdout as if it were a single file. |
| 388 |
|
| 389 |
` + "`" + `sink` + "`" + ` writes its input to a directory |
| 390 |
` |
| 391 |
var SinkExamples = ` |
| 392 |
kustomize fn source DIR/ | your-function | kustomize fn sink DIR/` |
| 393 |
|
| 394 |
var SourceShort = `[Alpha] Implement a Source by reading a local directory.` |
| 395 |
var SourceLong = ` |
| 396 |
[Alpha] Implement a Source by reading a local directory. |
| 397 |
|
| 398 |
kustomize fn source DIR... |
| 399 |
|
| 400 |
DIR: |
| 401 |
One or more paths to local directories. Contents from directories will be concatenated. |
| 402 |
If no directories are provided, source will read from stdin as if it were a single file. |
| 403 |
|
| 404 |
` + "`" + `source` + "`" + ` emits configuration to act as input to a function |
| 405 |
` |
| 406 |
var SourceExamples = ` |
| 407 |
# emity configuration directory as input source to a function |
| 408 |
kustomize fn source DIR/ |
| 409 |
|
| 410 |
kustomize fn source DIR/ | your-function | kustomize fn sink DIR/` |
| 411 |
|
| 412 |
var TreeShort = `[Alpha] Display Resource structure from a directory or stdin.` |
| 413 |
var TreeLong = ` |
| 414 |
[Alpha] Display Resource structure from a directory or stdin. |
| 415 |
|
| 416 |
kustomize cfg tree may be used to print Resources in a directory or cluster, preserving structure |
| 417 |
|
| 418 |
Args: |
| 419 |
|
| 420 |
DIR: |
| 421 |
Path to local directory directory. |
| 422 |
|
| 423 |
Resource fields may be printed as part of the Resources by specifying the fields as flags. |
| 424 |
|
| 425 |
kustomize cfg tree has build-in support for printing common fields, such as replicas, container images, |
| 426 |
container names, etc. |
| 427 |
|
| 428 |
kustomize cfg tree supports printing arbitrary fields using the '--field' flag. |
| 429 |
|
| 430 |
By default, kustomize cfg tree uses Resource graph structure if any relationships between resources (ownerReferences) |
| 431 |
are detected, as is typically the case when printing from a cluster. Otherwise, directory graph structure is used. The |
| 432 |
graph structure can also be selected explicitly using the '--graph-structure' flag. |
| 433 |
` |
| 434 |
var TreeExamples = ` |
| 435 |
# print Resources using directory structure |
| 436 |
kustomize cfg tree my-dir/ |
| 437 |
|
| 438 |
# print replicas, container name, and container image and fields for Resources |
| 439 |
kustomize cfg tree my-dir --replicas --image --name |
| 440 |
|
| 441 |
# print all common Resource fields |
| 442 |
kustomize cfg tree my-dir/ --all |
| 443 |
|
| 444 |
# print the "foo"" annotation |
| 445 |
kustomize cfg tree my-dir/ --field "metadata.annotations.foo" |
| 446 |
|
| 447 |
# print the "foo"" annotation |
| 448 |
kubectl get all -o yaml | kustomize cfg tree \ |
| 449 |
--field="status.conditions[type=Completed].status" |
| 450 |
|
| 451 |
# print live Resources from a cluster using owners for graph structure |
| 452 |
kubectl get all -o yaml | kustomize cfg tree --replicas --name --image |
| 453 |
|
| 454 |
# print live Resources with status condition fields |
| 455 |
kubectl get all -o yaml | kustomize cfg tree \ |
| 456 |
--name --image --replicas \ |
| 457 |
--field="status.conditions[type=Completed].status" \ |
| 458 |
--field="status.conditions[type=Complete].status" \ |
| 459 |
--field="status.conditions[type=Ready].status" \ |
| 460 |
--field="status.conditions[type=ContainersReady].status"` |