@@ -6,19 +6,22 @@ description: "Command reference for the Crossplane CLI"
66
77
88<!-- vale Google.Headings = NO -->
9- The ` crossplane ` CLI provides utilities to make using Crossplane easier.
9+ The ` crossplane ` CLI provides utilities to make using Crossplane easier.
1010
11- Read the [ Crossplane CLI overview] ({{<ref "../cli">}}) page for information on
11+ Read the [ Crossplane CLI overview] ({{<ref "../cli">}}) page for information on
1212installing ` crossplane ` .
1313
1414## Global flags
15+
1516The following flags are available for all commands.
1617
1718{{< table "table table-sm table-striped">}}
19+
1820| Short flag | Long flag | Description |
1921| ------------| -------------| ------------------------------|
2022| ` -h ` | ` --help ` | Show context sensitive help. |
2123| | ` --verbose ` | Print verbose output. |
24+
2225{{< /table >}}
2326
2427## version
@@ -28,29 +31,29 @@ and the control plane.
2831
2932``` shell
3033crossplane version
31- Client Version: v1.16 .0
32- Server Version: v1.16 .0
34+ Client Version: v1.17 .0
35+ Server Version: v1.17 .0
3336```
3437
35- ## render
38+ ## render
3639
3740The ` crossplane render ` command previews the output of a
38- [ composite resource] ({{<ref "../concepts/composite-resources">}}) after applying
41+ [ composite resource] ({{<ref "../concepts/composite-resources">}}) after applying
3942any [ composition functions] ({{<ref "../concepts/compositions">}}).
4043
4144{{< hint "important" >}}
4245The ` crossplane render ` command requires you to use composition functions.
4346{{< /hint >}}
4447
45- The ` crossplane render ` command connects to the locally running Docker
48+ The ` crossplane render ` command connects to the locally running Docker
4649Engine to pull and run composition functions.
4750
4851{{<hint "important">}}
4952Running ` crossplane render ` requires [ Docker] ( https://www.docker.com/ ) .
5053{{< /hint >}}
5154
52- Provide a composite resource, composition and composition function YAML
53- definition with the command to render the output locally.
55+ Provide a composite resource, composition and composition function YAML
56+ definition with the command to render the output locally.
5457
5558For example,
5659` crossplane render xr.yaml composition.yaml function.yaml `
@@ -59,6 +62,7 @@ The output includes the original composite resource followed by the generated
5962managed resources.
6063
6164{{<expand "An example render output" >}}
65+
6266``` yaml
6367---
6468apiVersion : nopexample.org/v1
@@ -87,62 +91,64 @@ spec:
8791 forProvider :
8892 region : us-east-2
8993` ` `
94+
9095{{< /expand >}}
9196
9297### Flags
9398
9499{{< table "table table-sm table-striped">}}
100+
95101| Short flag | Long flag | Description |
96102| ------------ | ------------- | ------------------------------ |
97103| | ` --context-files=<key>=<file>,<key>=<file>` | A comma separated list of files to load for function "contexts." |
98104| | `--context-values=<key>=<value>,<key>=<value>` | A comma separated list of key-value pairs to load for function "contexts." |
99105| `-r` | `--include-function-results` | Include the "results" or events from the function. |
100- | `-o` | `--observed-resources=<directory or file>` |
101- Provide artificial managed resource data to the function.
102- |
106+ | `-o` | `--observed-resources=<directory or file>` | Provide artificial managed resource data to the function. |
107+ | `-e` | `--extra-resources=PATH` | A YAML file or directory of YAML files specifying extra resources to pass to the Function pipeline. |
108+ | `-c` | `--include-context` | Include the context in the rendered output as a resource of kind : Context. |
103109| `-x` | `--include-full-xr` | Include a copy of the input Composite Resource spec and metadata fields in the rendered output. |
104110| | `--timeout=` | Amount of time to wait for a function to finish. (Default 1 minute) |
105- {{< /table >}}
106111
107- The `crossplane render` command relies on standard
108- [Docker environmental variables](https://docs.docker.com/engine/reference/commandline/cli/#environment-variables)
109- to connect to the local Docker Engine and run composition functions.
112+ {{< /table >}}
110113
114+ The `crossplane render` command relies on standard
115+ [Docker environmental variables](https://docs.docker.com/engine/reference/commandline/cli/#environment-variables)
116+ to connect to the local Docker Engine and run composition functions.
111117
112118# ## Provide function context
113119
114- The `--context-files` and `--context-values` flags can provide data
120+ The `--context-files` and `--context-values` flags can provide data
115121to a function's `context`.
116122The context is JSON formatted data.
117123
118124# ## Include function results
119125
120- If a function produces Kubernetes events with statuses use the
121- ` --include-function-results` to print them along with the managed resource
122- outputs.
126+ If a function produces Kubernetes events with statuses use the
127+ ` --include-function-results` to print them along with the managed resource
128+ outputs.
123129
124- # ## Include the composite resource
130+ # ## Include the composite resource
125131
126- Composition functions can only change the `status` field of a composite
132+ Composition functions can only change the `status` field of a composite
127133resource. By default, the `crossplane render` command only prints the
128134` status` field with `metadata.name`.
129135
130- Use `--include-full-xr` to print the full composite resource,
136+ Use `--include-full-xr` to print the full composite resource,
131137including the `spec` and `metadata` fields.
132138
133139# ## Mock managed resources
134140
135- Provide mocked, or artificial data representing a managed resource with
136- ` --observed-resources` . The `crossplane render` command treats the
137- provided inputs as if they were resources in a Crossplane cluster.
141+ Provide mocked, or artificial data representing a managed resource with
142+ ` --observed-resources` . The `crossplane render` command treats the
143+ provided inputs as if they were resources in a Crossplane cluster.
138144
139- A function can reference and manipulate the included resource as part of
145+ A function can reference and manipulate the included resource as part of
140146running the function.
141147
142- The `observed-resources` may be a single YAML file with multiple resources or a
148+ The `observed-resources` may be a single YAML file with multiple resources or a
143149directory of YAML files representing multiple resources.
144150
145- Inside the YAML file include an
151+ Inside the YAML file include an
146152{{<hover label="apiVersion" line="1">}}apiVersion{{</hover>}},
147153{{<hover label="apiVersion" line="2">}}kind{{</hover>}},
148154{{<hover label="apiVersion" line="3">}}metadata{{</hover>}} and
@@ -161,31 +167,40 @@ spec:
161167
162168The schema of the resource isn't validated and may contain any data.
163169
170+ # ## Mock Extra Resources
171+
172+ Extra Resources allow a Composition to request Crossplane Objects on the cluster that aren't
173+ part of the Composition. The `--extra-resources` option points at a directory containing
174+ YAML manifests of resources to mock. Use Extra Resources in combination with a function like
175+ [function-extra-resources](https://github.com/crossplane-contrib/function-extra-resources) or the
176+ built-in support in [function-go-templating](https://github.com/crossplane-contrib/function-go-templating?tab=readme-ov-file#extraresources).
177+
164178# # xpkg
165179
166180The `crossplane xpkg` commands create, install and update Crossplane
167181[packages]({{<ref "../concepts/packages">}}) as well as enable authentication
168- and publishing of Crossplane packages to a Crossplane package registry.
182+ and publishing of Crossplane packages to a Crossplane package registry.
169183
170184# ## xpkg build
171185
172- Using `crossplane xpkg build` provides automation and simplification to build
186+ Using `crossplane xpkg build` provides automation and simplification to build
173187Crossplane packages.
174188
175- The Crossplane CLI combines a directory of YAML files and packages them as
189+ The Crossplane CLI combines a directory of YAML files and packages them as
176190an [OCI container image](https://opencontainers.org/).
177191
178- The CLI applies the required annotations and values to meet the
192+ The CLI applies the required annotations and values to meet the
179193[Crossplane XPKG specification](https://github.com/crossplane/crossplane/blob/main/contributing/specifications/xpkg.md).
180194
181195The `crossplane` CLI supports building
182196[configuration]({{< ref "../concepts/packages" >}}),
183- [function]({{<ref "../concepts/compositions">}}) and
184- [provider]({{<ref "../concepts/providers" >}}) package types.
185-
197+ [function]({{<ref "../concepts/compositions">}}) and
198+ [provider]({{<ref "../concepts/providers" >}}) package types.
186199
187200# ### Flags
201+
188202{{< table "table table-sm table-striped">}}
203+
189204| Short flag | Long flag | Description |
190205| ------------ | ------------- | ------------------------------ |
191206| | `--embed-runtime-image-name=NAME` | The image name and tag of an image to include in the package. Only for provider and function packages. |
@@ -196,12 +211,12 @@ The `crossplane` CLI supports building
196211| `-f` | `--package-root="."` | Directory to search for YAML files. |
197212{{< /table >}}
198213
199- The `crossplane xpkg build` command recursively looks in the directory set by
200- ` --package-root` and attempts to combine any files ending in `.yml` or `.yaml`
214+ The `crossplane xpkg build` command recursively looks in the directory set by
215+ ` --package-root` and attempts to combine any files ending in `.yml` or `.yaml`
201216into a package.
202217
203- All YAML files must be valid Kubernetes manifests with `apiVersion`, `kind`,
204- ` metadata` and `spec` fields.
218+ All YAML files must be valid Kubernetes manifests with `apiVersion`, `kind`,
219+ ` metadata` and `spec` fields.
205220
206221# ### Ignore files
207222
@@ -972,16 +987,15 @@ crossplane beta validate provider.yaml managedResource.yaml
972987Total 1 resources: 0 missing schemas, 1 success case, 0 failure cases
973988` ` `
974989
975-
976990# ### Validate render command output
977991
978- You can pipe the output of `crossplane render` into
992+ You can pipe the output of `crossplane render` into
979993` crossplane beta validate` to validate complete Crossplane resource pipelines,
980- including XRs, compositions and composition functions.
994+ including XRs, compositions and composition functions.
981995
982- Use the `--include-full-xr` command with `crossplane render` and the `-`
983- option with `crossplane beta validate` to pipe the output from
984- ` crossplane render` to the input of `crossplane beta validate`.
996+ Use the `--include-full-xr` command with `crossplane render` and the `-`
997+ option with `crossplane beta validate` to pipe the output from
998+ ` crossplane render` to the input of `crossplane beta validate`.
985999
9861000` ` ` shell {copy-lines="1"}
9871001crossplane render xr.yaml composition.yaml function.yaml --include-full-xr | crossplane beta validate schemas.yaml -
@@ -994,8 +1008,8 @@ crossplane render xr.yaml composition.yaml function.yaml --include-full-xr | cro
9941008Total 5 resources: 0 missing schemas, 4 success cases, 1 failure cases
9951009` ` `
9961010
997-
9981011# ### Validate Common Expression Language rules
1012+
9991013XRDs can define [validation rules](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation-rules) expressed in the Common Expression Language
10001014([CEL](https://kubernetes.io/docs/reference/using-api/cel/)).
10011015
@@ -1031,7 +1045,7 @@ spec:
10311045
10321046The rule in this example checks that the vale of the
10331047{{<hover label="celXR" line="6">}}replicas{{</hover>}} field of an XR is between
1034- the {{<hover label="celXR" line="7">}}minReplicas{{</hover>}} and
1048+ the {{<hover label="celXR" line="7">}}minReplicas{{</hover>}} and
10351049{{<hover label="celXR" line="8">}}maxReplicas{{</hover>}} values.
10361050
10371051` ` ` yaml {label="celXR"}
@@ -1054,17 +1068,16 @@ error.
10541068Total 1 resources : 0 missing schemas, 0 success cases, 1 failure cases
10551069` ` `
10561070
1057-
10581071#### Validate against a directory of schemas
10591072
1060- The ` crossplane render` command can validate a directory of YAML files.
1073+ The ` crossplane render` command can validate a directory of YAML files.
10611074
10621075The command only processes `.yaml` and `.yml` files, while ignoring all other
10631076file types.
10641077
1065- With a directory of files, provide the directory and resource to validate.
1078+ With a directory of files, provide the directory and resource to validate.
10661079
1067- For example, using a directory named
1080+ For example, using a directory named
10681081{{<hover label="validateDir" line="2">}}schemas{{</hover>}} containing the XRD
10691082and Provider schemas.
10701083
@@ -1079,8 +1092,8 @@ schemas
10791092 ` -- xrd.yaml
10801093```
10811094
1082- Provide the directory name and a resource YAML file to the
1083- ` crossplane beta validate ` command.
1095+ Provide the directory name and a resource YAML file to the
1096+ ` crossplane beta validate ` command.
10841097
10851098``` shell
10861099crossplane beta validate schema resources.yaml
0 commit comments