CRD处理
这些标记有助于控制 Kubernetes API 服务器如何处理涉及您的自定义资源的 API 请求。
请参阅 生成 CRD 以获取示例。
- // +structType
-
- string
specifies the level of atomicity of the struct;
即 struct 中各字段是否彼此独立,或所有字段视为一个整体。
这对于 Server-Side Apply 正确合并 struct 更新很重要。
可能的值:
-
“granular”:结构体中的字段彼此独立,可由不同参与者操作。这是默认行为。
-
“atomic”:所有字段视为一个整体。任何变更都必须替换整个 struct。
Examples:
// Granular struct (default) - individual fields can be updated independently // +structType=granular type Config struct { Host string Port int } // Atomic struct - entire struct is replaced on update // +structType=atomic type Credentials struct { Username string Password string }- string
-
- // +structType
-
- string
specifies the level of atomicity of the struct;
即 struct 中各字段是否彼此独立,或所有字段视为一个整体。
这对于 Server-Side Apply 正确合并 struct 更新很重要。
可能的值:
-
“granular”:结构体中的字段彼此独立,可由不同参与者操作。这是默认行为。
-
“atomic”:所有字段视为一个整体。任何变更都必须替换整个 struct。
Examples:
// Granular struct (default) - individual fields can be updated independently // +structType=granular type Config struct { Host string Port int } // Atomic struct - entire struct is replaced on update // +structType=atomic type Credentials struct { Username string Password string }- string
-
- // +mapType
-
- string
specifies the level of atomicity of the map;
即 map 中各项是否彼此独立,或所有字段视为一个整体。
这对于 Server-Side Apply 正确合并 map 更新很重要。
可能的值:
-
“granular”:map 中的条目彼此独立,可由不同参与者操作。这是默认行为。
-
“atomic”:所有字段视为一个整体。任何变更都必须替换整个 map。
Examples:
// Granular map (default) - individual keys can be updated independently // +mapType=granular Labels map[string]string // Atomic map - entire map is replaced on update // +mapType=atomic Config map[string]string- string
-
- // +mapType
-
- string
specifies the level of atomicity of the map;
即 map 中各项是否彼此独立,或所有字段视为一个整体。
这对于 Server-Side Apply 正确合并 map 更新很重要。
可能的值:
-
“granular”:map 中的条目彼此独立,可由不同参与者操作。这是默认行为。
-
“atomic”:所有字段视为一个整体。任何变更都必须替换整个 map。
Examples:
// Granular map (default) - individual keys can be updated independently // +mapType=granular Labels map[string]string // Atomic map - entire map is replaced on update // +mapType=atomic Config map[string]string- string
-
- // +listType
-
- string
specifies the type of data-structure that the list
表示(map、set、atomic)。
这对于 Server-Side Apply 正确合并 list 更新很重要。
列表可能的数据结构类型为:
-
“map”:需要有一个键字段,用于构建关联列表。典型例子是按容器名索引的 pod container 列表。
-
“set”:字段需为 “scalar”,且每个值只能出现一次。
-
“atomic”:列表中的所有字段视为单个值,通常由同一参与者一起操作。
Examples:
// Map list (associative list) - items are merged by key // +listType=map // +listMapKey=name Containers []Container // Set list - items must be unique scalars // +listType=set Tags []string // Atomic list - entire list is replaced on update // +listType=atomic Args []string- string
-
- // +listType
-
- string
specifies the type of data-structure that the list
表示(map、set、atomic)。
这对于 Server-Side Apply 正确合并 list 更新很重要。
列表可能的数据结构类型为:
-
“map”:需要有一个键字段,用于构建关联列表。典型例子是按容器名索引的 pod container 列表。
-
“set”:字段需为 “scalar”,且每个值只能出现一次。
-
“atomic”:列表中的所有字段视为单个值,通常由同一参与者一起操作。
Examples:
// Map list (associative list) - items are merged by key // +listType=map // +listMapKey=name Containers []Container // Set list - items must be unique scalars // +listType=set Tags []string // Atomic list - entire list is replaced on update // +listType=atomic Args []string- string
-
- // +listMapKey
-
- string
specifies the keys to map listTypes.
它表示 map 列表的索引。若必须使用多个键可以重复。仅当 ListType 设为 map 时可用,且键应为标量类型。
Examples:
// Single key // +listType=map // +listMapKey=name Containers []Container // Composite key (multiple keys) // +listType=map // +listMapKey=name // +listMapKey=protocol Ports []Port- string
- // +listMapKey
-
- string
specifies the keys to map listTypes.
它表示 map 列表的索引。若必须使用多个键可以重复。仅当 ListType 设为 map 时可用,且键应为标量类型。
Examples:
// Single key // +listType=map // +listMapKey=name Containers []Container // Composite key (multiple keys) // +listType=map // +listMapKey=name // +listMapKey=protocol Ports []Port- string
- // +kubebuilder:validation:items:XPreserveUnknownFields
-
for array items stops the apiserver from pruning fields which are not specified.
默认情况下,apiserver 在解码步骤会丢弃请求载荷中的未知字段。此 marker 阻止 API 服务器这样做。它会递归影响字段,但若 schema 中指定了嵌套 properties 或 additionalProperties,则恢复正常裁剪行为。可为 true 或未定义。禁止为 false。
注意:kubebuilder:validation:XPreserveUnknownFields 变体已弃用,请改用 kubebuilder:pruning:PreserveUnknownFields 变体。二者功能相同。
Example:
// +kubebuilder:pruning:PreserveUnknownFields RawConfig map[string]interface{}- // +kubebuilder:validation:items:XPreserveUnknownFields
-
for array items stops the apiserver from pruning fields which are not specified.
默认情况下,apiserver 在解码步骤会丢弃请求载荷中的未知字段。此 marker 阻止 API 服务器这样做。它会递归影响字段,但若 schema 中指定了嵌套 properties 或 additionalProperties,则恢复正常裁剪行为。可为 true 或未定义。禁止为 false。
注意:kubebuilder:validation:XPreserveUnknownFields 变体已弃用,请改用 kubebuilder:pruning:PreserveUnknownFields 变体。二者功能相同。
Example:
// +kubebuilder:pruning:PreserveUnknownFields RawConfig map[string]interface{}- // +kubebuilder:validation:XPreserveUnknownFields
-
stops the apiserver from pruning fields which are not specified.
默认情况下,apiserver 在解码步骤会丢弃请求载荷中的未知字段。此 marker 阻止 API 服务器这样做。它会递归影响字段,但若 schema 中指定了嵌套 properties 或 additionalProperties,则恢复正常裁剪行为。可为 true 或未定义。禁止为 false。
注意:kubebuilder:validation:XPreserveUnknownFields 变体已弃用,请改用 kubebuilder:pruning:PreserveUnknownFields 变体。二者功能相同。
Example:
// +kubebuilder:pruning:PreserveUnknownFields RawConfig map[string]interface{}- // +kubebuilder:validation:XPreserveUnknownFields
-
stops the apiserver from pruning fields which are not specified.
默认情况下,apiserver 在解码步骤会丢弃请求载荷中的未知字段。此 marker 阻止 API 服务器这样做。它会递归影响字段,但若 schema 中指定了嵌套 properties 或 additionalProperties,则恢复正常裁剪行为。可为 true 或未定义。禁止为 false。
注意:kubebuilder:validation:XPreserveUnknownFields 变体已弃用,请改用 kubebuilder:pruning:PreserveUnknownFields 变体。二者功能相同。
Example:
// +kubebuilder:pruning:PreserveUnknownFields RawConfig map[string]interface{}- // +kubebuilder:pruning:PreserveUnknownFields
-
stops the apiserver from pruning fields which are not specified.
默认情况下,apiserver 在解码步骤会丢弃请求载荷中的未知字段。此 marker 阻止 API 服务器这样做。它会递归影响字段,但若 schema 中指定了嵌套 properties 或 additionalProperties,则恢复正常裁剪行为。可为 true 或未定义。禁止为 false。
注意:kubebuilder:validation:XPreserveUnknownFields 变体已弃用,请改用 kubebuilder:pruning:PreserveUnknownFields 变体。二者功能相同。
Example:
// +kubebuilder:pruning:PreserveUnknownFields RawConfig map[string]interface{}- // +kubebuilder:pruning:PreserveUnknownFields
-
stops the apiserver from pruning fields which are not specified.
默认情况下,apiserver 在解码步骤会丢弃请求载荷中的未知字段。此 marker 阻止 API 服务器这样做。它会递归影响字段,但若 schema 中指定了嵌套 properties 或 additionalProperties,则恢复正常裁剪行为。可为 true 或未定义。禁止为 false。
注意:kubebuilder:validation:XPreserveUnknownFields 变体已弃用,请改用 kubebuilder:pruning:PreserveUnknownFields 变体。二者功能相同。
Example:
// +kubebuilder:pruning:PreserveUnknownFields RawConfig map[string]interface{}- // +k8s:listType
-
- string
specifies the type of data-structure that the list
表示(map、set、atomic)。
这对于 Server-Side Apply 正确合并 list 更新很重要。
列表可能的数据结构类型为:
-
“map”:需要有一个键字段,用于构建关联列表。典型例子是按容器名索引的 pod container 列表。
-
“set”:字段需为 “scalar”,且每个值只能出现一次。
-
“atomic”:列表中的所有字段视为单个值,通常由同一参与者一起操作。
Examples:
// Map list (associative list) - items are merged by key // +listType=map // +listMapKey=name Containers []Container // Set list - items must be unique scalars // +listType=set Tags []string // Atomic list - entire list is replaced on update // +listType=atomic Args []string- string
-
- // +k8s:listType
-
- string
specifies the type of data-structure that the list
表示(map、set、atomic)。
这对于 Server-Side Apply 正确合并 list 更新很重要。
列表可能的数据结构类型为:
-
“map”:需要有一个键字段,用于构建关联列表。典型例子是按容器名索引的 pod container 列表。
-
“set”:字段需为 “scalar”,且每个值只能出现一次。
-
“atomic”:列表中的所有字段视为单个值,通常由同一参与者一起操作。
Examples:
// Map list (associative list) - items are merged by key // +listType=map // +listMapKey=name Containers []Container // Set list - items must be unique scalars // +listType=set Tags []string // Atomic list - entire list is replaced on update // +listType=atomic Args []string- string
-
- // +k8s:listMapKey
-
- string
specifies the keys to map listTypes.
它表示 map 列表的索引。若必须使用多个键可以重复。仅当 ListType 设为 map 时可用,且键应为标量类型。
Examples:
// Single key // +listType=map // +listMapKey=name Containers []Container // Composite key (multiple keys) // +listType=map // +listMapKey=name // +listMapKey=protocol Ports []Port- string
- // +k8s:listMapKey
-
- string
specifies the keys to map listTypes.
它表示 map 列表的索引。若必须使用多个键可以重复。仅当 ListType 设为 map 时可用,且键应为标量类型。
Examples:
// Single key // +listType=map // +listMapKey=name Containers []Container // Composite key (multiple keys) // +listType=map // +listMapKey=name // +listMapKey=protocol Ports []Port- string