kubebuilder 中文文档由云原生社区主导翻译。任何问题可以在这儿提issue。issue模版可以参考这个

CRD 处理

当你有自定义资源请求时,这些标记有助于 Kubernetes API 服务器控制处理 API。

作为例子可查看章节生成 CRDs.

kubebuilder:pruning:PreserveUnknownFields
PreserveUnknownFields stops the apiserver from pruning fields which are not specified.

By default the apiserver drops unknown fields from the request payload during the decoding step. This marker stops the API server from doing so. It affects fields recursively, but switches back to normal pruning behaviour if nested properties or additionalProperties are specified in the schema. This can either be true or undefined. False is forbidden.

kubebuilder:validation:XPreserveUnknownFields
PreserveUnknownFields stops the apiserver from pruning fields which are not specified.

By default the apiserver drops unknown fields from the request payload during the decoding step. This marker stops the API server from doing so. It affects fields recursively, but switches back to normal pruning behaviour if nested properties or additionalProperties are specified in the schema. This can either be true or undefined. False is forbidden.

kubebuilder:validation:XPreserveUnknownFields
PreserveUnknownFields stops the apiserver from pruning fields which are not specified.

By default the apiserver drops unknown fields from the request payload during the decoding step. This marker stops the API server from doing so. It affects fields recursively, but switches back to normal pruning behaviour if nested properties or additionalProperties are specified in the schema. This can either be true or undefined. False is forbidden.

listMapKey
string
specifies the keys to map listTypes.

It indicates the index of a map list. They can be repeated if multiple keys must be used. It can only be used when ListType is set to map, and the keys should be scalar types.

string
listType
string
specifies the type of data-structure that the list represents (map, set, atomic).

Possible data-structure types of a list are:

  • “map“: it needs to have a key field, which will be used to build an associative list. A typical example is a the pod container list, which is indexed by the container name.
  • “set“: Fields need to be “scalar“, and there can be only one occurrence of each.
  • “atomic“: All the fields in the list are treated as a single value, are typically manipulated together by the same actor.
string
mapType
string
specifies the level of atomicity of the map; i.e. whether each item in the map is independent of the others, or all fields are treated as a single unit.

Possible values:

  • “granular“: items in the map are independent of each other, and can be manipulated by different actors. This is the default behavior.
  • “atomic“: all fields are treated as one unit. Any changes have to replace the entire map.
string
structType
string
specifies the level of atomicity of the struct; i.e. whether each field in the struct is independent of the others, or all fields are treated as a single unit.

Possible values:

  • “granular“: fields in the struct are independent of each other, and can be manipulated by different actors. This is the default behavior.
  • “atomic“: all fields are treated as one unit. Any changes have to replace the entire struct.
string