@@ -6,19 +6,22 @@ description: "Command reference for the Crossplane CLI"
6
6
7
7
8
8
<!-- 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.
10
10
11
- Read the [ Crossplane CLI overview] ({{<ref "../cli">}}) page for information on
11
+ Read the [ Crossplane CLI overview] ({{<ref "../cli">}}) page for information on
12
12
installing ` crossplane ` .
13
13
14
14
## Global flags
15
+
15
16
The following flags are available for all commands.
16
17
17
18
{{< table "table table-sm table-striped">}}
19
+
18
20
| Short flag | Long flag | Description |
19
21
| ------------| -------------| ------------------------------|
20
22
| ` -h ` | ` --help ` | Show context sensitive help. |
21
23
| | ` --verbose ` | Print verbose output. |
24
+
22
25
{{< /table >}}
23
26
24
27
## version
@@ -28,29 +31,29 @@ and the control plane.
28
31
29
32
``` shell
30
33
crossplane 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
33
36
```
34
37
35
- ## render
38
+ ## render
36
39
37
40
The ` 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
39
42
any [ composition functions] ({{<ref "../concepts/compositions">}}).
40
43
41
44
{{< hint "important" >}}
42
45
The ` crossplane render ` command requires you to use composition functions.
43
46
{{< /hint >}}
44
47
45
- The ` crossplane render ` command connects to the locally running Docker
48
+ The ` crossplane render ` command connects to the locally running Docker
46
49
Engine to pull and run composition functions.
47
50
48
51
{{<hint "important">}}
49
52
Running ` crossplane render ` requires [ Docker] ( https://www.docker.com/ ) .
50
53
{{< /hint >}}
51
54
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.
54
57
55
58
For example,
56
59
` crossplane render xr.yaml composition.yaml function.yaml `
@@ -59,6 +62,7 @@ The output includes the original composite resource followed by the generated
59
62
managed resources.
60
63
61
64
{{<expand "An example render output" >}}
65
+
62
66
``` yaml
63
67
---
64
68
apiVersion : nopexample.org/v1
@@ -87,62 +91,64 @@ spec:
87
91
forProvider :
88
92
region : us-east-2
89
93
` ` `
94
+
90
95
{{< /expand >}}
91
96
92
97
### Flags
93
98
94
99
{{< table "table table-sm table-striped">}}
100
+
95
101
| Short flag | Long flag | Description |
96
102
| ------------ | ------------- | ------------------------------ |
97
103
| | ` --context-files=<key>=<file>,<key>=<file>` | A comma separated list of files to load for function "contexts." |
98
104
| | `--context-values=<key>=<value>,<key>=<value>` | A comma separated list of key-value pairs to load for function "contexts." |
99
105
| `-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. |
103
109
| `-x` | `--include-full-xr` | Include a copy of the input Composite Resource spec and metadata fields in the rendered output. |
104
110
| | `--timeout=` | Amount of time to wait for a function to finish. (Default 1 minute) |
105
- {{< /table >}}
106
111
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 >}}
110
113
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.
111
117
112
118
# ## Provide function context
113
119
114
- The `--context-files` and `--context-values` flags can provide data
120
+ The `--context-files` and `--context-values` flags can provide data
115
121
to a function's `context`.
116
122
The context is JSON formatted data.
117
123
118
124
# ## Include function results
119
125
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.
123
129
124
- # ## Include the composite resource
130
+ # ## Include the composite resource
125
131
126
- Composition functions can only change the `status` field of a composite
132
+ Composition functions can only change the `status` field of a composite
127
133
resource. By default, the `crossplane render` command only prints the
128
134
` status` field with `metadata.name`.
129
135
130
- Use `--include-full-xr` to print the full composite resource,
136
+ Use `--include-full-xr` to print the full composite resource,
131
137
including the `spec` and `metadata` fields.
132
138
133
139
# ## Mock managed resources
134
140
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.
138
144
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
140
146
running the function.
141
147
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
143
149
directory of YAML files representing multiple resources.
144
150
145
- Inside the YAML file include an
151
+ Inside the YAML file include an
146
152
{{<hover label="apiVersion" line="1">}}apiVersion{{</hover>}},
147
153
{{<hover label="apiVersion" line="2">}}kind{{</hover>}},
148
154
{{<hover label="apiVersion" line="3">}}metadata{{</hover>}} and
@@ -161,31 +167,40 @@ spec:
161
167
162
168
The schema of the resource isn't validated and may contain any data.
163
169
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
+
164
178
# # xpkg
165
179
166
180
The `crossplane xpkg` commands create, install and update Crossplane
167
181
[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.
169
183
170
184
# ## xpkg build
171
185
172
- Using `crossplane xpkg build` provides automation and simplification to build
186
+ Using `crossplane xpkg build` provides automation and simplification to build
173
187
Crossplane packages.
174
188
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
176
190
an [OCI container image](https://opencontainers.org/).
177
191
178
- The CLI applies the required annotations and values to meet the
192
+ The CLI applies the required annotations and values to meet the
179
193
[Crossplane XPKG specification](https://github.com/crossplane/crossplane/blob/main/contributing/specifications/xpkg.md).
180
194
181
195
The `crossplane` CLI supports building
182
196
[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.
186
199
187
200
# ### Flags
201
+
188
202
{{< table "table table-sm table-striped">}}
203
+
189
204
| Short flag | Long flag | Description |
190
205
| ------------ | ------------- | ------------------------------ |
191
206
| | `--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
196
211
| `-f` | `--package-root="."` | Directory to search for YAML files. |
197
212
{{< /table >}}
198
213
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`
201
216
into a package.
202
217
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.
205
220
206
221
# ### Ignore files
207
222
@@ -972,16 +987,15 @@ crossplane beta validate provider.yaml managedResource.yaml
972
987
Total 1 resources: 0 missing schemas, 1 success case, 0 failure cases
973
988
` ` `
974
989
975
-
976
990
# ### Validate render command output
977
991
978
- You can pipe the output of `crossplane render` into
992
+ You can pipe the output of `crossplane render` into
979
993
` crossplane beta validate` to validate complete Crossplane resource pipelines,
980
- including XRs, compositions and composition functions.
994
+ including XRs, compositions and composition functions.
981
995
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`.
985
999
986
1000
` ` ` shell {copy-lines="1"}
987
1001
crossplane 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
994
1008
Total 5 resources: 0 missing schemas, 4 success cases, 1 failure cases
995
1009
` ` `
996
1010
997
-
998
1011
# ### Validate Common Expression Language rules
1012
+
999
1013
XRDs can define [validation rules](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation-rules) expressed in the Common Expression Language
1000
1014
([CEL](https://kubernetes.io/docs/reference/using-api/cel/)).
1001
1015
@@ -1031,7 +1045,7 @@ spec:
1031
1045
1032
1046
The rule in this example checks that the vale of the
1033
1047
{{<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
1035
1049
{{<hover label="celXR" line="8">}}maxReplicas{{</hover>}} values.
1036
1050
1037
1051
` ` ` yaml {label="celXR"}
@@ -1054,17 +1068,16 @@ error.
1054
1068
Total 1 resources : 0 missing schemas, 0 success cases, 1 failure cases
1055
1069
` ` `
1056
1070
1057
-
1058
1071
#### Validate against a directory of schemas
1059
1072
1060
- The ` crossplane render` command can validate a directory of YAML files.
1073
+ The ` crossplane render` command can validate a directory of YAML files.
1061
1074
1062
1075
The command only processes `.yaml` and `.yml` files, while ignoring all other
1063
1076
file types.
1064
1077
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.
1066
1079
1067
- For example, using a directory named
1080
+ For example, using a directory named
1068
1081
{{<hover label="validateDir" line="2">}}schemas{{</hover>}} containing the XRD
1069
1082
and Provider schemas.
1070
1083
@@ -1079,8 +1092,8 @@ schemas
1079
1092
` -- xrd.yaml
1080
1093
```
1081
1094
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.
1084
1097
1085
1098
``` shell
1086
1099
crossplane beta validate schema resources.yaml
0 commit comments