Skip to content

Commit 0990569

Browse files
authored
Merge pull request kubernetes-sigs#1982 from shiftstack/filterparamdocs
📖 Document changes to Filters
2 parents e636957 + 2901efe commit 0990569

File tree

1 file changed

+80
-16
lines changed

1 file changed

+80
-16
lines changed

docs/book/src/topics/crd-changes/v1alpha7-to-v1beta1.md

Lines changed: 80 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
- [Changes to apiServerLoadBalancer](#changes-to-apiserverloadbalancer)
3131
- [Changes to bastion](#changes-to-bastion)
3232
- [Changes to filters](#changes-to-filters)
33+
- [Filters are replaced by params with separate id and filter](#filters-are-replaced-by-params-with-separate-id-and-filter)
3334
- [Changes to filter tags](#changes-to-filter-tags)
3435
- [Field capitalization consistency](#field-capitalization-consistency)
3536

@@ -65,9 +66,9 @@ This has moved to `identityRef.cloudName`.
6566

6667
#### Change to serverGroupID
6768

68-
The field `serverGroupID` has been renamed to `serverGroup` and is now a `ServerGroupFilter` object rather than a string ID.
69+
The field `serverGroupID` has been renamed to `serverGroup` and is now a `ServerGroupParam` object rather than a string ID.
6970

70-
The `ServerGroupFilter` object allows selection of a server group by name or by ID.
71+
The `ServerGroupParam` object allows selection of a server group by name or by ID.
7172

7273
```yaml
7374
serverGroupID: "e60f19e7-cb37-49f9-a2ee-0a1281f6e03e"
@@ -84,16 +85,18 @@ To select a server group by name instead of ID:
8485
8586
```yaml
8687
serverGroup:
87-
name: "workers"
88+
filter:
89+
name: "workers"
8890
```
8991
90-
If a server group is provided and found, it'll be added to `OpenStackMachine.Status.ReferencedResources.ServerGroupID`. If the server group can't be found or filter matches multiple server groups, an error will be returned.
91-
If empty object or null is provided, Machine will not be added to any server group and `OpenStackMachine.Status.ReferencedResources.ServerGroupID` will be empty.
92+
If a server group is provided and found, it will be added to `OpenStackMachine.Status.ReferencedResources.ServerGroupID`. If the server group can't be found or filter matches multiple server groups, an error will be returned.
93+
If no serverGroup is provided, Machine will not be added to any server group and `OpenStackMachine.Status.ReferencedResources.ServerGroupID` will be empty.
94+
It is an error to provide an empty serverGroup.
9295

9396
#### Change to image
9497

95-
The field `image` is now an `ImageFilter` object rather than a string name.
96-
The `ImageFilter` object allows selection of an image by ID or by name and tags. If ID is set, no other fields can be set in the object.
98+
The field `image` is now an `ImageParam` object rather than a string name.
99+
The `ImageParam` object allows selection of an image by ID or by filter. Either ID or a filter may be set, but not both.
97100

98101
```yaml
99102
image: "test-image"
@@ -103,7 +106,8 @@ becomes
103106

104107
```yaml
105108
image:
106-
name: "test-image"
109+
filter:
110+
name: "test-image"
107111
```
108112

109113
The image ID will be added to `OpenStackMachine.Status.ReferencedResources.ImageID`. If the image can't be found or filter matches multiple images, an error will be returned.
@@ -171,8 +175,8 @@ Note that this is in contrast `identityRef` in `OpenStackMachine`, which remains
171175

172176
#### Change to externalNetworkID
173177

174-
The field `externalNetworkID` has been renamed to `externalNetwork` and is now a `NetworkFilter` object rather than a string ID.
175-
The `NetworkFilter` object allows selection of a network by name, by ID or by tags.
178+
The field `externalNetworkID` has been renamed to `externalNetwork` and is now a `NetworkParam` object rather than a string ID.
179+
The `NetworkParam` object allows selection of a network by id or filter parameters.
176180

177181
```yaml
178182
externalNetworkID: "e60f19e7-cb37-49f9-a2ee-0a1281f6e03e"
@@ -185,14 +189,15 @@ externalNetwork:
185189
id: "e60f19e7-cb37-49f9-a2ee-0a1281f6e03e"
186190
```
187191

188-
It is now possible to specify a `NetworkFilter` object to select the external network to use for the cluster. The `NetworkFilter` object allows to select the network by name, by ID or by tags.
192+
It is now possible to specify a `NetworkParam` object to select the external network to use for the cluster. The `NetworkParam` object allows to select the network by id or by filter, which can select by name, ID or tags.
189193

190194
```yaml
191195
externalNetwork:
192-
name: "public"
196+
filter:
197+
name: "public"
193198
```
194199

195-
If a network is provided, it'll be added to `OpenStackCluster.Status.ExternalNetwork`. If the network can't be found, an error will be returned.
200+
If a network is provided, it will be added to `OpenStackCluster.Status.ExternalNetwork`. If the network can't be found, an error will be returned.
196201
If no network is provided, CAPO will try to find network marked "External" and add it to `OpenStackCluster.Status.ExternalNetwork`. If it can't find a network marked "External",
197202
`OpenStackCluster.Status.ExternalNetwork` will be set to nil.
198203
If more than one network is found, an error will be returned.
@@ -239,7 +244,7 @@ The new field has IPv4 validation added.
239244

240245
#### Change to subnet
241246

242-
In v1beta1, `Subnet` of `OpenStackCluster` is modified to `Subnets` to allow specification of two existent subnets for the dual-stack scenario.
247+
In v1beta1, `Subnet` of `OpenStackCluster` is modified to `Subnets` to allow specification of two existing subnets for the dual-stack scenario.
243248

244249
```yaml
245250
subnet:
@@ -253,10 +258,12 @@ In v1beta1, this will be automatically converted to:
253258
- id: a532beb0-c73a-4b5d-af66-3ad05b73d063
254259
```
255260

256-
`Subnets` allows specifications of maximum two `SubnetFilter` one being IPv4 and the other IPv6. Both subnets must be on the same network. Any filtered subnets will be added to `OpenStackCluster.Status.Network.Subnets`.
261+
`Subnets` allows specifications of maximum two `SubnetParam`s one being IPv4 and the other IPv6. Both subnets must be on the same network. Any filtered subnets will be added to `OpenStackCluster.Status.Network.Subnets`.
257262

258263
When subnets are not specified on `OpenStackCluster` and only the network is, the network is used to identify the subnets to use. If more than two subnets exist in the network, the user must specify which ones to use by defining the `OpenStackCluster.Spec.Subnets` field.
259264

265+
See [Filters are replaced by params with separate id and filter](#filters-are-replaced-by-params-with-separate-id-and-filter) for changes to the `SubnetFilter`.
266+
260267
#### Change to nodeCidr and dnsNameservers
261268

262269
In v1beta1, `OpenStackCluster.Spec.ManagedSubnets` array field is introduced. The `NodeCIDR` and `DNSNameservers` fields of `OpenStackCluster.Spec` are moved into that structure (renaming `NodeCIDR` to `CIDR`). For example:
@@ -388,11 +395,68 @@ spec:
388395
bastion:
389396
spec:
390397
image:
391-
name: foobar
398+
filter:
399+
name: foobar
392400
```
393401

394402
### Changes to filters
395403

404+
#### Filters are replaced by params with separate id and filter
405+
406+
We previously defined filters for specifying each of the following:
407+
* Images
408+
* Networks
409+
* Subnets
410+
* Security Groups
411+
* Routers
412+
413+
In addition, ServerGroupParam is new in v1beta1, but works in the same way.
414+
415+
Taking Images as an example, in `OpenStackMachineSpec` the `image` parameter accepted the following fields:
416+
* id
417+
* name
418+
* tags
419+
420+
However, there were 2 different behaviours here depending on which fields were specified. If `id` was specified we both ignored all other fields, and made no attempt to validate the id because it cannot be known unless it exists. If `id` was not specified we performed an OpenStack query using the other parameters to determine the id. This behaviour is both difficult to describe and validate, so in v1beta1 we have separated the 2 different behaviours into different fields. The `id` field remains, but all other fields become part of a new `filter` parameter. It is required to specify either `id` or `filter`. Specifying both, neither, or an empty filter, will now result in an admission failure (the API server will reject the operation immediately).
421+
422+
We have also added validation to the id field, which must now parse as a uuid. An id field which does not parse as a uuid will also result in an admission failure.
423+
424+
Specifying a filter object by id remains unchanged.
425+
```yaml
426+
image:
427+
id: 02e31c38-d5ba-4c57-addb-00fc71eb5b19
428+
```
429+
430+
Specifying a filter object by a filter parameter must now move filter parameters into the filter field:
431+
```yaml
432+
image:
433+
name: my-image
434+
tags:
435+
- my-tag
436+
```
437+
becomes:
438+
```yaml
439+
image:
440+
filter:
441+
name: my-image
442+
tags:
443+
- my-tag
444+
```
445+
446+
The same principle applies to all the filter types. For example:
447+
448+
To specify `externalNetwork` by id in `OpenStackClusterSpec`:
449+
```yaml
450+
externalNetwork:
451+
id: 0a5d4e3d-0a2c-4bed-9172-72544db1f8da
452+
```
453+
or by name:
454+
```yaml
455+
externalNetwork:
456+
filter:
457+
name: my-external-network
458+
```
459+
396460
#### Changes to filter tags
397461

398462
We currently define filters on 4 different Neutron resources which are used throughout the API:

0 commit comments

Comments
 (0)