Update cmd/config docs from using yaml to using kustomize config

This commit is contained in:
Phillip Wittrock
2019-11-27 11:59:45 -08:00
parent 1a9d62617e
commit 7ce1f7e95a
12 changed files with 78 additions and 72 deletions

View File

@@ -3,8 +3,12 @@
This package exists to expose config filters directly as cli commands for the purposes This package exists to expose config filters directly as cli commands for the purposes
of development of the kyaml package and as a reference implementation for using the libraries. of development of the kyaml package and as a reference implementation for using the libraries.
## Docs: ## Docs
All documentation is also built directly into the `config` command group using
`kustomize help config`.
- [tutorials](docs/tutorials)
- [commands](docs/commands) - [commands](docs/commands)
- [api-conventions](docs/api-conventions) - [api-conventions](docs/api-conventions)

View File

@@ -63,7 +63,7 @@ var ExitOnError bool
// StackOnError if true, will print a stack trace on failure. // StackOnError if true, will print a stack trace on failure.
var StackOnError bool var StackOnError bool
const cmdName = "kyaml" const cmdName = "kustomize config"
// FixDocs replaces instances of old with new in the docs for c // FixDocs replaces instances of old with new in the docs for c
func fixDocs(new string, c *cobra.Command) { func fixDocs(new string, c *cobra.Command) {

View File

@@ -59,7 +59,7 @@ var ConfigFnLong = `# Configuration Functions API Semantics
generated Resources -- e.g. 1. the function generates a Deployment, but doesn't generated Resources -- e.g. 1. the function generates a Deployment, but doesn't
specify ` + "`" + `cpu` + "`" + `, 2. the user sets the ` + "`" + `cpu` + "`" + ` on the generated Resource, 3. the specify ` + "`" + `cpu` + "`" + `, 2. the user sets the ` + "`" + `cpu` + "`" + ` on the generated Resource, 3. the
function should keep the ` + "`" + `cpu` + "`" + ` when regenerating the Resource a second time. function should keep the ` + "`" + `cpu` + "`" + ` when regenerating the Resource a second time.
- Functions **SHOULD** be usable outside ` + "`" + `kyaml run-fns` + "`" + ` -- e.g. though pipeline - Functions **SHOULD** be usable outside ` + "`" + `kustomize config run-fns` + "`" + ` -- e.g. though pipeline
mechanisms such as Tekton. mechanisms such as Tekton.
#### Input Format #### Input Format
@@ -126,7 +126,8 @@ var ConfigFnLong = `# Configuration Functions API Semantics
#### Container Environment #### Container Environment
When run by ` + "`" + `kyaml run-fns` + "`" + `, functions are run in containers with the following environment: When run by ` + "`" + `kustomize config run-fns` + "`" + `, functions are run in containers with the
following environment:
- Network: ` + "`" + `none` + "`" + ` - Network: ` + "`" + `none` + "`" + `
- User: ` + "`" + `nobody` + "`" + ` - User: ` + "`" + `nobody` + "`" + `
@@ -152,8 +153,8 @@ var ConfigFnLong = `# Configuration Functions API Semantics
4. Format the output 4. Format the output
#!/bin/bash #!/bin/bash
# script must run wrapped by kyaml for parsing input # script must run wrapped by ` + "`" + `kustomize config run-fns wrap` + "`" + `
# the functionConfig into env vars # for parsing input the functionConfig into env vars
if [ -z ${WRAPPED} ]; then if [ -z ${WRAPPED} ]; then
export WRAPPED=true export WRAPPED=true
config run-fns wrap -- $0 config run-fns wrap -- $0
@@ -205,7 +206,7 @@ var ConfigFnLong = `# Configuration Functions API Semantics
#### ` + "`" + `Dockerfile` + "`" + ` #### ` + "`" + `Dockerfile` + "`" + `
` + "`" + `Dockerfile` + "`" + ` installs ` + "`" + `kyaml` + "`" + ` and copies the script into the container image. ` + "`" + `Dockerfile` + "`" + ` installs ` + "`" + `kustomize config` + "`" + ` and copies the script into the container image.
FROM golang:1.13-stretch FROM golang:1.13-stretch
RUN go get sigs.k8s.io/kustomize/cmd/config RUN go get sigs.k8s.io/kustomize/cmd/config
@@ -215,7 +216,7 @@ var ConfigFnLong = `# Configuration Functions API Semantics
### Example Function Usage ### Example Function Usage
Following is an example of running the ` + "`" + `kyaml run-fns` + "`" + ` using the preceding API. Following is an example of running the ` + "`" + `kustomize config run-fns` + "`" + ` using the preceding API.
#### ` + "`" + `nginx.yaml` + "`" + ` (Input) #### ` + "`" + `nginx.yaml` + "`" + ` (Input)
@@ -238,7 +239,7 @@ Following is an example of running the ` + "`" + `kyaml run-fns` + "`" + ` using
- ` + "`" + `annotations[config.kubernetes.io/local-config]` + "`" + `: mark this as not a Resource that should - ` + "`" + `annotations[config.kubernetes.io/local-config]` + "`" + `: mark this as not a Resource that should
be applied be applied
#### ` + "`" + `kyaml run-fns dir/` + "`" + ` (Output) #### ` + "`" + `kustomize config run-fns dir/` + "`" + ` (Output)
` + "`" + `dir/my-instance_deployment.yaml` + "`" + ` contains the Deployment: ` + "`" + `dir/my-instance_deployment.yaml` + "`" + ` contains the Deployment:

View File

@@ -13,13 +13,13 @@ var CatLong = `
` `
var CatExamples = ` var CatExamples = `
# print Resource config from a directory # print Resource config from a directory
kyaml cat my-dir/ kustomize config cat my-dir/
# wrap Resource config from a directory in an ResourceList # wrap Resource config from a directory in an ResourceList
kyaml cat my-dir/ --wrap-kind ResourceList --wrap-version config.kubernetes.io/v1alpha1 --function-config fn.yaml kustomize config cat my-dir/ --wrap-kind ResourceList --wrap-version config.kubernetes.io/v1alpha1 --function-config fn.yaml
# unwrap Resource config from a directory in an ResourceList # unwrap Resource config from a directory in an ResourceList
... | kyaml cat` ... | kustomize config cat`
var CountShort = `[Alpha] Count Resources Config from a local directory.` var CountShort = `[Alpha] Count Resources Config from a local directory.`
var CountLong = ` var CountLong = `
@@ -30,7 +30,7 @@ var CountLong = `
` `
var CountExamples = ` var CountExamples = `
# print Resource counts from a directory # print Resource counts from a directory
kyaml count my-dir/` kustomize config count my-dir/`
var FmtShort = `[Alpha] Format yaml configuration files.` var FmtShort = `[Alpha] Format yaml configuration files.`
var FmtLong = ` var FmtLong = `
@@ -61,16 +61,16 @@ field paths.
` `
var FmtExamples = ` var FmtExamples = `
# format file1.yaml and file2.yml # format file1.yaml and file2.yml
kyaml fmt file1.yaml file2.yml kustomize config fmt file1.yaml file2.yml
# format all *.yaml and *.yml recursively traversing directories # format all *.yaml and *.yml recursively traversing directories
kyaml fmt my-dir/ kustomize config fmt my-dir/
# format kubectl output # format kubectl output
kubectl get -o yaml deployments | kyaml fmt kubectl get -o yaml deployments | kustomize config fmt
# format kustomize output # format kustomize output
kustomize build | kyaml fmt` kustomize build | kustomize config fmt`
var GrepShort = `[Alpha] Search for matching Resources in a directory or from stdin` var GrepShort = `[Alpha] Search for matching Resources in a directory or from stdin`
var GrepLong = ` var GrepLong = `
@@ -88,16 +88,16 @@ var GrepLong = `
` `
var GrepExamples = ` var GrepExamples = `
# find Deployment Resources # find Deployment Resources
kyaml grep "kind=Deployment" my-dir/ kustomize config grep "kind=Deployment" my-dir/
# find Resources named nginx # find Resources named nginx
kyaml grep "metadata.name=nginx" my-dir/ kustomize config grep "metadata.name=nginx" my-dir/
# use tree to display matching Resources # use tree to display matching Resources
kyaml grep "metadata.name=nginx" my-dir/ | kyaml tree kustomize config grep "metadata.name=nginx" my-dir/ | kustomize config tree
# look for Resources matching a specific container image # look for Resources matching a specific container image
kyaml grep "spec.template.spec.containers[name=nginx].image=nginx:1\.7\.9" my-dir/ | kyaml tree` kustomize config grep "spec.template.spec.containers[name=nginx].image=nginx:1\.7\.9" my-dir/ | kustomize config tree`
var MergeShort = `[Alpha] Merge Resource configuration files` var MergeShort = `[Alpha] Merge Resource configuration files`
var MergeLong = ` var MergeLong = `
@@ -114,10 +114,10 @@ earlier are lower-precedence (the destination).
For information on merge rules, run: For information on merge rules, run:
kyaml docs merge kustomize config docs merge
` `
var MergeExamples = ` var MergeExamples = `
cat resources_and_patches.yaml | kyaml merge > merged_resources.yaml` cat resources_and_patches.yaml | kustomize config merge > merged_resources.yaml`
var RunFnsShort = `[Alpha] Reoncile config functions to Resources.` var RunFnsShort = `[Alpha] Reoncile config functions to Resources.`
var RunFnsLong = ` var RunFnsLong = `
@@ -157,22 +157,22 @@ order they appear in the file).
spec: spec:
configField: configValue configField: configValue
In the preceding example, 'kyaml run-fns example/' would identify the function by In the preceding example, 'kustomize config run-fns example/' would identify the function by
the metadata.configFn field. It would then write all Resources in the directory to the metadata.configFn field. It would then write all Resources in the directory to
a container stdin (running the gcr.io/example/examplefunction:v1.0.1 image). It a container stdin (running the gcr.io/example/examplefunction:v1.0.1 image). It
would then writer the container stdout back to example/, replacing the directory would then writer the container stdout back to example/, replacing the directory
file contents. file contents.
See ` + "`" + `kyaml help docs-fn` + "`" + ` for more details on writing functions. See ` + "`" + `kustomize config help docs-fn` + "`" + ` for more details on writing functions.
` `
var RunFnsExamples = ` var RunFnsExamples = `
kyaml run-fns example/` kustomize config run-fns example/`
var TreeShort = `[Alpha] Display Resource structure from a directory or stdin.` var TreeShort = `[Alpha] Display Resource structure from a directory or stdin.`
var TreeLong = ` var TreeLong = `
[Alpha] Display Resource structure from a directory or stdin. [Alpha] Display Resource structure from a directory or stdin.
kyaml tree may be used to print Resources in a directory or cluster, preserving structure kustomize config tree may be used to print Resources in a directory or cluster, preserving structure
Args: Args:
@@ -181,37 +181,37 @@ Args:
Resource fields may be printed as part of the Resources by specifying the fields as flags. Resource fields may be printed as part of the Resources by specifying the fields as flags.
kyaml tree has build-in support for printing common fields, such as replicas, container images, kustomize config tree has build-in support for printing common fields, such as replicas, container images,
container names, etc. container names, etc.
kyaml tree supports printing arbitrary fields using the '--field' flag. kustomize config tree supports printing arbitrary fields using the '--field' flag.
By default, kyaml tree uses the directory structure for the tree structure, however when printing By default, kustomize config tree uses the directory structure for the tree structure, however when printing
from the cluster, the Resource graph structure may be used instead. from the cluster, the Resource graph structure may be used instead.
` `
var TreeExamples = ` var TreeExamples = `
# print Resources using directory structure # print Resources using directory structure
kyaml tree my-dir/ kustomize config tree my-dir/
# print replicas, container name, and container image and fields for Resources # print replicas, container name, and container image and fields for Resources
kyaml tree my-dir --replicas --image --name kustomize config tree my-dir --replicas --image --name
# print all common Resource fields # print all common Resource fields
kyaml tree my-dir/ --all kustomize config tree my-dir/ --all
# print the "foo"" annotation # print the "foo"" annotation
kyaml tree my-dir/ --field "metadata.annotations.foo" kustomize config tree my-dir/ --field "metadata.annotations.foo"
# print the "foo"" annotation # print the "foo"" annotation
kubectl get all -o yaml | kyaml tree my-dir/ --structure=graph \ kubectl get all -o yaml | kustomize config tree my-dir/ --structure=graph \
--field="status.conditions[type=Completed].status" --field="status.conditions[type=Completed].status"
# print live Resources from a cluster using graph for structure # print live Resources from a cluster using graph for structure
kubectl get all -o yaml | kyaml tree --replicas --name --image --structure=graph kubectl get all -o yaml | kustomize config tree --replicas --name --image --structure=graph
# print live Resources using graph for structure # print live Resources using graph for structure
kubectl get all,applications,releasetracks -o yaml | kyaml tree --structure=graph \ kubectl get all,applications,releasetracks -o yaml | kustomize config tree --structure=graph \
--name --image --replicas \ --name --image --replicas \
--field="status.conditions[type=Completed].status" \ --field="status.conditions[type=Completed].status" \
--field="status.conditions[type=Complete].status" \ --field="status.conditions[type=Complete].status" \

View File

@@ -53,7 +53,7 @@
generated Resources -- e.g. 1. the function generates a Deployment, but doesn't generated Resources -- e.g. 1. the function generates a Deployment, but doesn't
specify `cpu`, 2. the user sets the `cpu` on the generated Resource, 3. the specify `cpu`, 2. the user sets the `cpu` on the generated Resource, 3. the
function should keep the `cpu` when regenerating the Resource a second time. function should keep the `cpu` when regenerating the Resource a second time.
- Functions **SHOULD** be usable outside `kyaml run-fns` -- e.g. though pipeline - Functions **SHOULD** be usable outside `kustomize config run-fns` -- e.g. though pipeline
mechanisms such as Tekton. mechanisms such as Tekton.
#### Input Format #### Input Format
@@ -120,7 +120,8 @@
#### Container Environment #### Container Environment
When run by `kyaml run-fns`, functions are run in containers with the following environment: When run by `kustomize config run-fns`, functions are run in containers with the
following environment:
- Network: `none` - Network: `none`
- User: `nobody` - User: `nobody`
@@ -146,8 +147,8 @@
4. Format the output 4. Format the output
#!/bin/bash #!/bin/bash
# script must run wrapped by kyaml for parsing input # script must run wrapped by `kustomize config run-fns wrap`
# the functionConfig into env vars # for parsing input the functionConfig into env vars
if [ -z ${WRAPPED} ]; then if [ -z ${WRAPPED} ]; then
export WRAPPED=true export WRAPPED=true
config run-fns wrap -- $0 config run-fns wrap -- $0
@@ -199,7 +200,7 @@
#### `Dockerfile` #### `Dockerfile`
`Dockerfile` installs `kyaml` and copies the script into the container image. `Dockerfile` installs `kustomize config` and copies the script into the container image.
FROM golang:1.13-stretch FROM golang:1.13-stretch
RUN go get sigs.k8s.io/kustomize/cmd/config RUN go get sigs.k8s.io/kustomize/cmd/config
@@ -209,7 +210,7 @@
### Example Function Usage ### Example Function Usage
Following is an example of running the `kyaml run-fns` using the preceding API. Following is an example of running the `kustomize config run-fns` using the preceding API.
#### `nginx.yaml` (Input) #### `nginx.yaml` (Input)
@@ -232,7 +233,7 @@ Following is an example of running the `kyaml run-fns` using the preceding API.
- `annotations[config.kubernetes.io/local-config]`: mark this as not a Resource that should - `annotations[config.kubernetes.io/local-config]`: mark this as not a Resource that should
be applied be applied
#### `kyaml run-fns dir/` (Output) #### `kustomize config run-fns dir/` (Output)
`dir/my-instance_deployment.yaml` contains the Deployment: `dir/my-instance_deployment.yaml` contains the Deployment:

View File

@@ -12,10 +12,10 @@
### Examples ### Examples
# print Resource config from a directory # print Resource config from a directory
kyaml cat my-dir/ kustomize config cat my-dir/
# wrap Resource config from a directory in an ResourceList # wrap Resource config from a directory in an ResourceList
kyaml cat my-dir/ --wrap-kind ResourceList --wrap-version config.kubernetes.io/v1alpha1 --function-config fn.yaml kustomize config cat my-dir/ --wrap-kind ResourceList --wrap-version config.kubernetes.io/v1alpha1 --function-config fn.yaml
# unwrap Resource config from a directory in an ResourceList # unwrap Resource config from a directory in an ResourceList
... | kyaml cat ... | kustomize config cat

View File

@@ -12,4 +12,4 @@
### Examples ### Examples
# print Resource counts from a directory # print Resource counts from a directory
kyaml count my-dir/ kustomize config count my-dir/

View File

@@ -32,13 +32,13 @@ field paths.
### Examples ### Examples
# format file1.yaml and file2.yml # format file1.yaml and file2.yml
kyaml fmt file1.yaml file2.yml kustomize config fmt file1.yaml file2.yml
# format all *.yaml and *.yml recursively traversing directories # format all *.yaml and *.yml recursively traversing directories
kyaml fmt my-dir/ kustomize config fmt my-dir/
# format kubectl output # format kubectl output
kubectl get -o yaml deployments | kyaml fmt kubectl get -o yaml deployments | kustomize config fmt
# format kustomize output # format kustomize output
kustomize build | kyaml fmt kustomize build | kustomize config fmt

View File

@@ -19,13 +19,13 @@
### Examples ### Examples
# find Deployment Resources # find Deployment Resources
kyaml grep "kind=Deployment" my-dir/ kustomize config grep "kind=Deployment" my-dir/
# find Resources named nginx # find Resources named nginx
kyaml grep "metadata.name=nginx" my-dir/ kustomize config grep "metadata.name=nginx" my-dir/
# use tree to display matching Resources # use tree to display matching Resources
kyaml grep "metadata.name=nginx" my-dir/ | kyaml tree kustomize config grep "metadata.name=nginx" my-dir/ | kustomize config tree
# look for Resources matching a specific container image # look for Resources matching a specific container image
kyaml grep "spec.template.spec.containers[name=nginx].image=nginx:1\.7\.9" my-dir/ | kyaml tree kustomize config grep "spec.template.spec.containers[name=nginx].image=nginx:1\.7\.9" my-dir/ | kustomize config tree

View File

@@ -17,8 +17,8 @@ earlier are lower-precedence (the destination).
For information on merge rules, run: For information on merge rules, run:
kyaml docs merge kustomize config docs merge
### Examples ### Examples
cat resources_and_patches.yaml | kyaml merge > merged_resources.yaml cat resources_and_patches.yaml | kustomize config merge > merged_resources.yaml

View File

@@ -40,14 +40,14 @@ order they appear in the file).
spec: spec:
configField: configValue configField: configValue
In the preceding example, 'kyaml run-fns example/' would identify the function by In the preceding example, 'kustomize config run-fns example/' would identify the function by
the metadata.configFn field. It would then write all Resources in the directory to the metadata.configFn field. It would then write all Resources in the directory to
a container stdin (running the gcr.io/example/examplefunction:v1.0.1 image). It a container stdin (running the gcr.io/example/examplefunction:v1.0.1 image). It
would then writer the container stdout back to example/, replacing the directory would then writer the container stdout back to example/, replacing the directory
file contents. file contents.
See `kyaml help docs-fn` for more details on writing functions. See `kustomize config help docs-fn` for more details on writing functions.
### Examples ### Examples
kyaml run-fns example/ kustomize config run-fns example/

View File

@@ -6,7 +6,7 @@
[Alpha] Display Resource structure from a directory or stdin. [Alpha] Display Resource structure from a directory or stdin.
kyaml tree may be used to print Resources in a directory or cluster, preserving structure kustomize config tree may be used to print Resources in a directory or cluster, preserving structure
Args: Args:
@@ -15,38 +15,38 @@ Args:
Resource fields may be printed as part of the Resources by specifying the fields as flags. Resource fields may be printed as part of the Resources by specifying the fields as flags.
kyaml tree has build-in support for printing common fields, such as replicas, container images, kustomize config tree has build-in support for printing common fields, such as replicas, container images,
container names, etc. container names, etc.
kyaml tree supports printing arbitrary fields using the '--field' flag. kustomize config tree supports printing arbitrary fields using the '--field' flag.
By default, kyaml tree uses the directory structure for the tree structure, however when printing By default, kustomize config tree uses the directory structure for the tree structure, however when printing
from the cluster, the Resource graph structure may be used instead. from the cluster, the Resource graph structure may be used instead.
### Examples ### Examples
# print Resources using directory structure # print Resources using directory structure
kyaml tree my-dir/ kustomize config tree my-dir/
# print replicas, container name, and container image and fields for Resources # print replicas, container name, and container image and fields for Resources
kyaml tree my-dir --replicas --image --name kustomize config tree my-dir --replicas --image --name
# print all common Resource fields # print all common Resource fields
kyaml tree my-dir/ --all kustomize config tree my-dir/ --all
# print the "foo"" annotation # print the "foo"" annotation
kyaml tree my-dir/ --field "metadata.annotations.foo" kustomize config tree my-dir/ --field "metadata.annotations.foo"
# print the "foo"" annotation # print the "foo"" annotation
kubectl get all -o yaml | kyaml tree my-dir/ --structure=graph \ kubectl get all -o yaml | kustomize config tree my-dir/ --structure=graph \
--field="status.conditions[type=Completed].status" --field="status.conditions[type=Completed].status"
# print live Resources from a cluster using graph for structure # print live Resources from a cluster using graph for structure
kubectl get all -o yaml | kyaml tree --replicas --name --image --structure=graph kubectl get all -o yaml | kustomize config tree --replicas --name --image --structure=graph
# print live Resources using graph for structure # print live Resources using graph for structure
kubectl get all,applications,releasetracks -o yaml | kyaml tree --structure=graph \ kubectl get all,applications,releasetracks -o yaml | kustomize config tree --structure=graph \
--name --image --replicas \ --name --image --replicas \
--field="status.conditions[type=Completed].status" \ --field="status.conditions[type=Completed].status" \
--field="status.conditions[type=Complete].status" \ --field="status.conditions[type=Complete].status" \