在阅读 Kubernetes API 或 其他项目的 API时,细心的读者会发现这些 API 中有些字段包含了 // +optional 标记(下面简称optional标记),比如 Deployment API中的 Replicas 字段就包含这个标记:
// DeploymentSpec is the specification of the desired behavior of the Deployment.
type DeploymentSpec struct {
// Number of desired pods. This is a pointer to distinguish between explicit
// zero and not specified. Defaults to 1.
// +optional
Replicas *int32 `json:"replicas,omitempty"`
...
// Template describes the pods that will be created.
Template v1.PodTemplateSpec `json:"template"`
...
}