From 7cd8c90f52825f0bb3777d86383742e1f93dd50a Mon Sep 17 00:00:00 2001 From: zyy17 Date: Thu, 19 Sep 2024 17:53:21 +0800 Subject: [PATCH] refactor: make some fields optional --- apis/v1alpha1/common.go | 4 ++-- apis/v1alpha1/greptimedbcluster_types.go | 6 +++--- .../greptime.io_greptimedbclusters.yaml | 16 ++++------------ .../greptime.io_greptimedbstandalones.yaml | 1 - docs/api-references/docs.md | 12 ++++++------ manifests/bundle.yaml | 17 ++++------------- manifests/crds.yaml | 17 ++++------------- 7 files changed, 23 insertions(+), 50 deletions(-) diff --git a/apis/v1alpha1/common.go b/apis/v1alpha1/common.go index 5239cbdb..d2039572 100644 --- a/apis/v1alpha1/common.go +++ b/apis/v1alpha1/common.go @@ -254,7 +254,7 @@ type MainContainerSpec struct { // Defaults to `Always` if `:latest` tag is specified, or IfNotPresent otherwise. // Cannot be updated. // More info: `https://kubernetes.io/docs/concepts/containers/images#updating-images` - // ImagePullPolicy field is from `orev1.Container.ImagePullPolicy`. + // ImagePullPolicy field is from `corev1.Container.ImagePullPolicy`. // +optional ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` @@ -635,7 +635,7 @@ type PrometheusMonitorSpec struct { Enabled bool `json:"enabled"` // Labels is the labels for the PodMonitor. - // +required + // +optional Labels map[string]string `json:"labels"` // Interval is the scape interval for the PodMonitor. diff --git a/apis/v1alpha1/greptimedbcluster_types.go b/apis/v1alpha1/greptimedbcluster_types.go index 9833b23f..e4b9ad6b 100644 --- a/apis/v1alpha1/greptimedbcluster_types.go +++ b/apis/v1alpha1/greptimedbcluster_types.go @@ -21,9 +21,9 @@ import ( // ComponentSpec is the common specification for all components(`frontend`/`meta`/`datanode`/`flownode`). type ComponentSpec struct { // The number of replicas of the components. - // +required - // +kubebuilder:validation:Minimum=1 - Replicas *int32 `json:"replicas"` + // +optional + // +kubebuilder:validation:Minimum=0 + Replicas *int32 `json:"replicas,omitempty"` // The content of the configuration file of the component in TOML format. // +optional diff --git a/config/crd/resources/greptime.io_greptimedbclusters.yaml b/config/crd/resources/greptime.io_greptimedbclusters.yaml index 3886115f..f2c21b1b 100644 --- a/config/crd/resources/greptime.io_greptimedbclusters.yaml +++ b/config/crd/resources/greptime.io_greptimedbclusters.yaml @@ -2821,7 +2821,7 @@ spec: type: integer replicas: format: int32 - minimum: 1 + minimum: 0 type: integer rpcPort: format: int32 @@ -5610,8 +5610,6 @@ spec: type: object type: array type: object - required: - - replicas type: object flownode: properties: @@ -5619,7 +5617,7 @@ spec: type: string replicas: format: int32 - minimum: 1 + minimum: 0 type: integer rpcPort: format: int32 @@ -8386,8 +8384,6 @@ spec: type: object type: array type: object - required: - - replicas type: object frontend: properties: @@ -8395,7 +8391,7 @@ spec: type: string replicas: format: int32 - minimum: 1 + minimum: 0 type: integer service: properties: @@ -11181,8 +11177,6 @@ spec: required: - secretName type: object - required: - - replicas type: object httpPort: format: int32 @@ -11209,7 +11203,7 @@ spec: type: integer replicas: format: int32 - minimum: 1 + minimum: 0 type: integer rpcPort: format: int32 @@ -13980,7 +13974,6 @@ spec: type: object required: - etcdEndpoints - - replicas type: object mysqlPort: format: int32 @@ -14075,7 +14068,6 @@ spec: type: object required: - enabled - - labels type: object rpcPort: format: int32 diff --git a/config/crd/resources/greptime.io_greptimedbstandalones.yaml b/config/crd/resources/greptime.io_greptimedbstandalones.yaml index 2ef67b33..6d74a4ee 100644 --- a/config/crd/resources/greptime.io_greptimedbstandalones.yaml +++ b/config/crd/resources/greptime.io_greptimedbstandalones.yaml @@ -2925,7 +2925,6 @@ spec: type: object required: - enabled - - labels type: object rpcPort: format: int32 diff --git a/docs/api-references/docs.md b/docs/api-references/docs.md index c4232b1c..b2df40f7 100644 --- a/docs/api-references/docs.md +++ b/docs/api-references/docs.md @@ -50,7 +50,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | -| `replicas` _integer_ | The number of replicas of the components. | | Minimum: 1
| +| `replicas` _integer_ | The number of replicas of the components. | | Minimum: 0
| | `config` _string_ | The content of the configuration file of the component in TOML format. | | | | `template` _[PodTemplateSpec](#podtemplatespec)_ | Template defines the pod template for the component, if not specified, the pod template will use the default value. | | | @@ -106,7 +106,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | -| `replicas` _integer_ | The number of replicas of the components. | | Minimum: 1
| +| `replicas` _integer_ | The number of replicas of the components. | | Minimum: 0
| | `config` _string_ | The content of the configuration file of the component in TOML format. | | | | `template` _[PodTemplateSpec](#podtemplatespec)_ | Template defines the pod template for the component, if not specified, the pod template will use the default value. | | | | `rpcPort` _integer_ | RPCPort is the gRPC port of the datanode. | | | @@ -186,7 +186,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | -| `replicas` _integer_ | The number of replicas of the components. | | Minimum: 1
| +| `replicas` _integer_ | The number of replicas of the components. | | Minimum: 0
| | `config` _string_ | The content of the configuration file of the component in TOML format. | | | | `template` _[PodTemplateSpec](#podtemplatespec)_ | Template defines the pod template for the component, if not specified, the pod template will use the default value. | | | | `rpcPort` _integer_ | The gRPC port of the flownode. | | | @@ -222,7 +222,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | -| `replicas` _integer_ | The number of replicas of the components. | | Minimum: 1
| +| `replicas` _integer_ | The number of replicas of the components. | | Minimum: 0
| | `config` _string_ | The content of the configuration file of the component in TOML format. | | | | `template` _[PodTemplateSpec](#podtemplatespec)_ | Template defines the pod template for the component, if not specified, the pod template will use the default value. | | | | `service` _[ServiceSpec](#servicespec)_ | Service is the service configuration of the frontend. | | | @@ -458,7 +458,7 @@ _Appears in:_ | `livenessProbe` _[Probe](https://kubernetes.io/docs/reference/generated/kubernetes-api/v/#probe-v1-core)_ | Periodic probe of container liveness.
Container will be restarted if the probe fails.
More info: `https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes`
LivenessProbe field is from `corev1.Container.LivenessProbe`. | | | | `readinessProbe` _[Probe](https://kubernetes.io/docs/reference/generated/kubernetes-api/v/#probe-v1-core)_ | Periodic probe of container service readiness.
Container will be removed from service endpoints if the probe fails.
ReadinessProbe field is from `corev1.Container.LivenessProbe`.
More info: `https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes` | | | | `lifecycle` _[Lifecycle](https://kubernetes.io/docs/reference/generated/kubernetes-api/v/#lifecycle-v1-core)_ | Actions that the management system should take in response to container lifecycle events.
Cannot be updated.
Lifecycle field is from `corev1.Container.Lifecycle`. | | | -| `imagePullPolicy` _[PullPolicy](https://kubernetes.io/docs/reference/generated/kubernetes-api/v/#pullpolicy-v1-core)_ | Image pull policy.
One of `Always`, `Never`, `IfNotPresent`.
Defaults to `Always` if `:latest` tag is specified, or IfNotPresent otherwise.
Cannot be updated.
More info: `https://kubernetes.io/docs/concepts/containers/images#updating-images`
ImagePullPolicy field is from `orev1.Container.ImagePullPolicy`. | | | +| `imagePullPolicy` _[PullPolicy](https://kubernetes.io/docs/reference/generated/kubernetes-api/v/#pullpolicy-v1-core)_ | Image pull policy.
One of `Always`, `Never`, `IfNotPresent`.
Defaults to `Always` if `:latest` tag is specified, or IfNotPresent otherwise.
Cannot be updated.
More info: `https://kubernetes.io/docs/concepts/containers/images#updating-images`
ImagePullPolicy field is from `corev1.Container.ImagePullPolicy`. | | | | `volumeMounts` _[VolumeMount](https://kubernetes.io/docs/reference/generated/kubernetes-api/v/#volumemount-v1-core) array_ | Pod volumes to mount into the container's filesystem.
Cannot be updated. | | | @@ -475,7 +475,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | -| `replicas` _integer_ | The number of replicas of the components. | | Minimum: 1
| +| `replicas` _integer_ | The number of replicas of the components. | | Minimum: 0
| | `config` _string_ | The content of the configuration file of the component in TOML format. | | | | `template` _[PodTemplateSpec](#podtemplatespec)_ | Template defines the pod template for the component, if not specified, the pod template will use the default value. | | | | `rpcPort` _integer_ | RPCPort is the gRPC port of the meta. | | | diff --git a/manifests/bundle.yaml b/manifests/bundle.yaml index 815d37b3..bdd25189 100644 --- a/manifests/bundle.yaml +++ b/manifests/bundle.yaml @@ -2827,7 +2827,7 @@ spec: type: integer replicas: format: int32 - minimum: 1 + minimum: 0 type: integer rpcPort: format: int32 @@ -5616,8 +5616,6 @@ spec: type: object type: array type: object - required: - - replicas type: object flownode: properties: @@ -5625,7 +5623,7 @@ spec: type: string replicas: format: int32 - minimum: 1 + minimum: 0 type: integer rpcPort: format: int32 @@ -8392,8 +8390,6 @@ spec: type: object type: array type: object - required: - - replicas type: object frontend: properties: @@ -8401,7 +8397,7 @@ spec: type: string replicas: format: int32 - minimum: 1 + minimum: 0 type: integer service: properties: @@ -11187,8 +11183,6 @@ spec: required: - secretName type: object - required: - - replicas type: object httpPort: format: int32 @@ -11215,7 +11209,7 @@ spec: type: integer replicas: format: int32 - minimum: 1 + minimum: 0 type: integer rpcPort: format: int32 @@ -13986,7 +13980,6 @@ spec: type: object required: - etcdEndpoints - - replicas type: object mysqlPort: format: int32 @@ -14081,7 +14074,6 @@ spec: type: object required: - enabled - - labels type: object rpcPort: format: int32 @@ -17141,7 +17133,6 @@ spec: type: object required: - enabled - - labels type: object rpcPort: format: int32 diff --git a/manifests/crds.yaml b/manifests/crds.yaml index 736ecaa5..e38c8c0c 100644 --- a/manifests/crds.yaml +++ b/manifests/crds.yaml @@ -2820,7 +2820,7 @@ spec: type: integer replicas: format: int32 - minimum: 1 + minimum: 0 type: integer rpcPort: format: int32 @@ -5609,8 +5609,6 @@ spec: type: object type: array type: object - required: - - replicas type: object flownode: properties: @@ -5618,7 +5616,7 @@ spec: type: string replicas: format: int32 - minimum: 1 + minimum: 0 type: integer rpcPort: format: int32 @@ -8385,8 +8383,6 @@ spec: type: object type: array type: object - required: - - replicas type: object frontend: properties: @@ -8394,7 +8390,7 @@ spec: type: string replicas: format: int32 - minimum: 1 + minimum: 0 type: integer service: properties: @@ -11180,8 +11176,6 @@ spec: required: - secretName type: object - required: - - replicas type: object httpPort: format: int32 @@ -11208,7 +11202,7 @@ spec: type: integer replicas: format: int32 - minimum: 1 + minimum: 0 type: integer rpcPort: format: int32 @@ -13979,7 +13973,6 @@ spec: type: object required: - etcdEndpoints - - replicas type: object mysqlPort: format: int32 @@ -14074,7 +14067,6 @@ spec: type: object required: - enabled - - labels type: object rpcPort: format: int32 @@ -17134,7 +17126,6 @@ spec: type: object required: - enabled - - labels type: object rpcPort: format: int32