Clarify Server-Side Apply docs and example

pull/48695/head
yongruilin 2024-11-11 16:00:41 -08:00
parent 2a234b2f82
commit aae228c037
1 changed files with 18 additions and 9 deletions

View File

@ -96,6 +96,11 @@ becomes available.
A simple example of an object created using Server-Side Apply could look like this: A simple example of an object created using Server-Side Apply could look like this:
{{< note >}}
`kubectl get` omits managed fields by default.
Add `--show-managed-fields` to show `managedFields` when the output format is either `json` or `yaml`.
{{< /note >}}
```yaml ```yaml
--- ---
apiVersion: v1 apiVersion: v1
@ -249,8 +254,10 @@ metadata:
managedFields: managedFields:
- manager: kubectl - manager: kubectl
operation: Apply operation: Apply
time: '2019-03-30T15:00:00.000Z'
apiVersion: v1 apiVersion: v1
fields: fieldsType: FieldsV1
fieldsV1:
f:metadata: f:metadata:
f:labels: f:labels:
f:test-label: {} f:test-label: {}
@ -258,7 +265,8 @@ metadata:
operation: Update operation: Update
apiVersion: v1 apiVersion: v1
time: '2019-03-30T16:00:00.000Z' time: '2019-03-30T16:00:00.000Z'
fields: fieldsType: FieldsV1
fieldsV1:
f:data: f:data:
f:key: {} f:key: {}
data: data:
@ -295,11 +303,11 @@ For a {{< glossary_tooltip term_id="CustomResourceDefinition" text="CustomResour
you can set these markers when you define the custom resource. you can set these markers when you define the custom resource.
| Golang marker | OpenAPI extension | Possible values | Description | | Golang marker | OpenAPI extension | Possible values | Description |
|---|---|---|---|---| | --------------- | ---------------------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| `//+listType` | `x-kubernetes-list-type` | `atomic`/`set`/`map` | Applicable to lists. `set` applies to lists that include only scalar elements. These elements must be unique. `map` applies to lists of nested types only. The key values (see `listMapKey`) must be unique in the list. `atomic` can apply to any list. If configured as `atomic`, the entire list is replaced during merge. At any point in time, a single manager owns the list. If `set` or `map`, different managers can manage entries separately. | | `//+listType` | `x-kubernetes-list-type` | `atomic`/`set`/`map` | Applicable to lists. `set` applies to lists that include only scalar elements. These elements must be unique. `map` applies to lists of nested types only. The key values (see `listMapKey`) must be unique in the list. `atomic` can apply to any list. If configured as `atomic`, the entire list is replaced during merge. At any point in time, a single manager owns the list. If `set` or `map`, different managers can manage entries separately. |
| `//+listMapKey` | `x-kubernetes-list-map-keys` | List of field names, e.g. `["port", "protocol"]` | Only applicable when `+listType=map`. A list of field names whose values uniquely identify entries in the list. While there can be multiple keys, `listMapKey` is singular because keys need to be specified individually in the Go type. The key fields must be scalars. | | `//+listMapKey` | `x-kubernetes-list-map-keys` | List of field names, e.g. `["port", "protocol"]` | Only applicable when `+listType=map`. A list of field names whose values uniquely identify entries in the list. While there can be multiple keys, `listMapKey` is singular because keys need to be specified individually in the Go type. The key fields must be scalars. |
| `//+mapType` | `x-kubernetes-map-type` | `atomic`/`granular` | Applicable to maps. `atomic` means that the map can only be entirely replaced by a single manager. `granular` means that the map supports separate managers updating individual fields. | | `//+mapType` | `x-kubernetes-map-type` | `atomic`/`granular` | Applicable to maps. `atomic` means that the map can only be entirely replaced by a single manager. `granular` means that the map supports separate managers updating individual fields. |
| `//+structType` | `x-kubernetes-map-type` | `atomic`/`granular` | Applicable to structs; otherwise same usage and OpenAPI annotation as `//+mapType`.| | `//+structType` | `x-kubernetes-map-type` | `atomic`/`granular` | Applicable to structs; otherwise same usage and OpenAPI annotation as `//+mapType`. |
If `listType` is missing, the API server interprets a If `listType` is missing, the API server interprets a
`patchStrategy=merge` marker as a `listType=map` and the `patchStrategy=merge` marker as a `listType=map` and the
@ -355,7 +363,8 @@ metadata:
- manager: "manager-one" - manager: "manager-one"
operation: Apply operation: Apply
apiVersion: example.com/v1 apiVersion: example.com/v1
fields: fieldsType: FieldsV1
fieldsV1:
f:spec: f:spec:
f:data: {} f:data: {}
spec: spec: