@@ -4,5 +4,75 @@ linkTitle: "CLI"
44weight : 3
55date : 2023-07-28
66description : >
7- The command line tools to interact with Kustomize.
8- ---
7+ Reference for the Command Line Interface.
8+ ---
9+
10+ This overview covers ` kustomize ` syntax, describes the command operations, and provides common examples.
11+
12+ ## Syntax
13+ Use the following syntax to run ` kustomize ` commands from your terminal window:
14+
15+ ``` bash
16+ kustomize [command]
17+ ```
18+
19+ The ` command ` flag specifies the operation that you want to perform, for example ` create ` , ` build ` , ` cfg ` .
20+
21+ If you need help, run ` kustomize help ` from the terminal window.
22+
23+ ## Operations
24+ The following table includes short descriptions and the general syntax for all the ` kustomize ` operations.
25+
26+ Operation | Syntax | Description
27+ --- | --- | ---
28+ build | ` kustomize build DIR [flags] ` | Build a kustomization target from a directory or URL.
29+ cfg | ` kustomize cfg [command] ` | Commands for reading and writing configuration.
30+ completion | ` kustomize completion ` [ bash\| zsh\| fish\| powershell] | Generate shell completion script.
31+ create | ` kustomize create [flags] ` | Create a new kustomization in the current directory.
32+ edit | ` kustomize edit [command] ` | Edits a kustomization file.
33+ fn | ` kustomize fn [command] ` | Commands for running functions against configuration.
34+ localize | ` kustomize localize [target [destination]] [flags] ` | [ Alpha] Creates localized copy of target kustomization root at destination.
35+ version | ` kustomize version [flags] ` | Prints the kustomize version.
36+
37+ ## Examples: Common Operations
38+ Use the following set of examples to help you familiarize yourself with running the commonly used ` kustomize ` operations:
39+
40+ ` kustomize build ` - Build a kustomization target from a directory or URL.
41+
42+ ``` bash
43+ # Build the current working directory
44+ kustomize build
45+
46+ # Build some shared configuration directory
47+ kustomize build /home/config/production
48+
49+ # Build from github
50+ kustomize build https://github.com/kubernetes-sigs/kustomize.git/examples/helloWorld? ref=v1.0.6
51+ ```
52+
53+ ` kustomize create ` - Create a new kustomization in the current directory.
54+ ``` bash
55+ # Create an empty kustomization.yaml file
56+ kustomize create
57+
58+ # Create a new overlay from the base '../base".
59+ kustomize create --resources ../base
60+
61+ # Create a new kustomization detecting resources in the current directory.
62+ kustomize create --autodetect
63+
64+ # Create a new kustomization with multiple resources and fields set.
65+ kustomize create --resources deployment.yaml,service.yaml,../base --namespace staging --nameprefix acme-
66+ ```
67+
68+ ` kustomize edit ` - Edits a kustomization file.
69+ ``` bash
70+ # Adds a configmap to the kustomization file
71+ kustomize edit add configmap NAME --from-literal=k=v
72+
73+ # Sets the nameprefix field
74+ kustomize edit set nameprefix < prefix-value>
75+
76+ # Sets the namesuffix field
77+ kustomize edit set namesuffix < suffix-value>
78+ ```
0 commit comments