From e5b9090d8ab1baa3fad29b9c42f43ac89ca7fa8b Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Mon, 5 Jan 2026 16:57:48 +0800 Subject: [PATCH 01/22] Support adding observer role Signed-off-by: zhaohehuhu --- config/crd/bases/starrocks.com_starrocksclusters.yaml | 3 +++ deploy/starrocks.com_starrocksclusters.yaml | 3 +++ .../charts/kube-starrocks/charts/starrocks/values.yaml | 2 ++ pkg/apis/starrocks/v1/labels.go | 1 + pkg/apis/starrocks/v1/load_type.go | 2 -- pkg/apis/starrocks/v1/starrockscluster_types.go | 10 ++++++++++ pkg/apis/starrocks/v1/zz_generated.deepcopy.go | 5 +++++ pkg/k8sutils/templates/pod/spec.go | 7 ++++++- 8 files changed, 30 insertions(+), 3 deletions(-) diff --git a/config/crd/bases/starrocks.com_starrocksclusters.yaml b/config/crd/bases/starrocks.com_starrocksclusters.yaml index 7ce09afb2..c8d5e3c33 100644 --- a/config/crd/bases/starrocks.com_starrocksclusters.yaml +++ b/config/crd/bases/starrocks.com_starrocksclusters.yaml @@ -13601,6 +13601,9 @@ spec: description: (Optional) If specified, the pod's nodeSelector,displayName="Map of nodeSelectors to match when scheduling pods on nodes" type: object + observerNumber: + format: int32 + type: integer persistentVolumeClaimRetentionPolicy: description: |- PersistentVolumeClaimRetentionPolicy specifies the retention policy for PersistentVolumeClaims associated with the component. diff --git a/deploy/starrocks.com_starrocksclusters.yaml b/deploy/starrocks.com_starrocksclusters.yaml index 57502d6c9..196cac8c2 100644 --- a/deploy/starrocks.com_starrocksclusters.yaml +++ b/deploy/starrocks.com_starrocksclusters.yaml @@ -6413,6 +6413,9 @@ spec: additionalProperties: type: string type: object + observerNumber: + format: int32 + type: integer persistentVolumeClaimRetentionPolicy: properties: whenDeleted: diff --git a/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml b/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml index 4952ff352..55729fa30 100644 --- a/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml @@ -195,6 +195,8 @@ starrocksCluster: starrocksFESpec: # number of replicas to deploy for a FE statefulset. replicas: 1 + # the number of observer for FE. + # observerNumber: 0 image: # image sliced by "repository:tag" repository: starrocks/fe-ubuntu diff --git a/pkg/apis/starrocks/v1/labels.go b/pkg/apis/starrocks/v1/labels.go index f0b9e7254..1cfebcffc 100644 --- a/pkg/apis/starrocks/v1/labels.go +++ b/pkg/apis/starrocks/v1/labels.go @@ -40,4 +40,5 @@ const ( const ( COMPONENT_NAME = "COMPONENT_NAME" FE_SERVICE_NAME = "FE_SERVICE_NAME" + OBSERVER_NUMBER = "OBSERVER_NUMBER" ) diff --git a/pkg/apis/starrocks/v1/load_type.go b/pkg/apis/starrocks/v1/load_type.go index 1645446ee..a1568ba8b 100644 --- a/pkg/apis/starrocks/v1/load_type.go +++ b/pkg/apis/starrocks/v1/load_type.go @@ -85,7 +85,6 @@ type StarRocksLoadSpec struct { // +kubebuilder:default=1 // +optional Replicas *int32 `json:"replicas,omitempty"` - // Image for a starrocks deployment. // +optional Image string `json:"image"` @@ -304,7 +303,6 @@ type StarRocksProbe struct { func (spec *StarRocksLoadSpec) GetReplicas() *int32 { return spec.Replicas } - func (spec *StarRocksLoadSpec) GetStorageVolumes() []StorageVolume { return spec.StorageVolumes } diff --git a/pkg/apis/starrocks/v1/starrockscluster_types.go b/pkg/apis/starrocks/v1/starrockscluster_types.go index e7b5b8172..0af5f3fbc 100644 --- a/pkg/apis/starrocks/v1/starrockscluster_types.go +++ b/pkg/apis/starrocks/v1/starrockscluster_types.go @@ -149,6 +149,8 @@ type StarRocksClusterStatus struct { type StarRocksFeSpec struct { StarRocksComponentSpec `json:",inline"` + ObserverNumber *int32 `json:"observerNumber,omitempty"` + // +optional // feEnvVars is a slice of environment variables that are added to the pods, the default is empty. FeEnvVars []corev1.EnvVar `json:"feEnvVars,omitempty"` @@ -243,6 +245,14 @@ func (spec *StarRocksFeProxySpec) GetReplicas() *int32 { return spec.StarRocksLoadSpec.GetReplicas() } +func (spec *StarRocksFeSpec) GetObserverNumber() *int32 { + var DefaultObserverNumber int32 = 0 + if spec.ObserverNumber != nil { + return spec.ObserverNumber + } + return &DefaultObserverNumber +} + // GetHostAliases // fe proxy does not have field HostAliases, the reason why implementing this method is // that StarRocksFeProxySpec needs to implement SpecInterface interface diff --git a/pkg/apis/starrocks/v1/zz_generated.deepcopy.go b/pkg/apis/starrocks/v1/zz_generated.deepcopy.go index 3b50a79e7..03d196da7 100644 --- a/pkg/apis/starrocks/v1/zz_generated.deepcopy.go +++ b/pkg/apis/starrocks/v1/zz_generated.deepcopy.go @@ -575,6 +575,11 @@ func (in *StarRocksFeProxyStatus) DeepCopy() *StarRocksFeProxyStatus { func (in *StarRocksFeSpec) DeepCopyInto(out *StarRocksFeSpec) { *out = *in in.StarRocksComponentSpec.DeepCopyInto(&out.StarRocksComponentSpec) + if in.ObserverNumber != nil { + in, out := &in.ObserverNumber, &out.ObserverNumber + *out = new(int32) + **out = **in + } if in.FeEnvVars != nil { in, out := &in.FeEnvVars, &out.FeEnvVars *out = make([]corev1.EnvVar, len(*in)) diff --git a/pkg/k8sutils/templates/pod/spec.go b/pkg/k8sutils/templates/pod/spec.go index 8a220bc18..11bc71573 100644 --- a/pkg/k8sutils/templates/pod/spec.go +++ b/pkg/k8sutils/templates/pod/spec.go @@ -89,7 +89,6 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, feExternalServiceName string, namespace string, envs []corev1.EnvVar) []corev1.EnvVar { // copy envs envs = append([]corev1.EnvVar(nil), envs...) - keys := make(map[string]bool) for _, env := range envs { keys[env.Name] = true @@ -143,7 +142,9 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, } switch spec.(type) { + case *v1.StarRocksFeSpec: + observerNumber := spec.(*v1.StarRocksFeSpec).GetObserverNumber() for _, envVar := range []corev1.EnvVar{ { Name: v1.COMPONENT_NAME, @@ -153,6 +154,10 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, Name: v1.FE_SERVICE_NAME, Value: feExternalServiceName + "." + namespace, }, + { + Name: v1.OBSERVER_NUMBER, + Value: strconv.FormatInt(int64(*observerNumber), 10), + }, } { addEnv(envVar) } From 05f3d9e9b016e9caf5b07dde985f75f606dab003 Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Tue, 6 Jan 2026 16:58:47 +0800 Subject: [PATCH 02/22] fix Signed-off-by: zhaohehuhu --- helm-charts/charts/kube-starrocks/values.yaml | 2 ++ pkg/k8sutils/templates/pod/spec.go | 5 ++--- pkg/k8sutils/templates/pod/spec_test.go | 5 +++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/helm-charts/charts/kube-starrocks/values.yaml b/helm-charts/charts/kube-starrocks/values.yaml index 454f1b83e..d0b349510 100644 --- a/helm-charts/charts/kube-starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/values.yaml @@ -311,6 +311,8 @@ starrocks: starrocksFESpec: # number of replicas to deploy for a FE statefulset. replicas: 1 + # the number of observer for FE. + # observerNumber: 0 image: # image sliced by "repository:tag" repository: starrocks/fe-ubuntu diff --git a/pkg/k8sutils/templates/pod/spec.go b/pkg/k8sutils/templates/pod/spec.go index 11bc71573..3b7d75e58 100644 --- a/pkg/k8sutils/templates/pod/spec.go +++ b/pkg/k8sutils/templates/pod/spec.go @@ -141,10 +141,9 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, addEnv(envVar) } - switch spec.(type) { - + switch s := spec.(type) { case *v1.StarRocksFeSpec: - observerNumber := spec.(*v1.StarRocksFeSpec).GetObserverNumber() + observerNumber := s.GetObserverNumber() for _, envVar := range []corev1.EnvVar{ { Name: v1.COMPONENT_NAME, diff --git a/pkg/k8sutils/templates/pod/spec_test.go b/pkg/k8sutils/templates/pod/spec_test.go index 674bab65d..b96a4e994 100644 --- a/pkg/k8sutils/templates/pod/spec_test.go +++ b/pkg/k8sutils/templates/pod/spec_test.go @@ -18,6 +18,7 @@ import ( "fmt" "os" "reflect" + "strconv" "testing" corev1 "k8s.io/api/core/v1" @@ -237,6 +238,10 @@ func TestEnvs(t *testing.T) { Name: v1.FE_SERVICE_NAME, Value: service.ExternalServiceName("test", &v1.StarRocksFeSpec{}) + "." + "ns", }, + { + Name: v1.OBSERVER_NUMBER, + Value: strconv.FormatInt(int64(0), 10), + }, }...), unsupportedEnvs: "", }, From a6a4a8b27b3b4ec20e7c440a5287ca287e8fa0ea Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Fri, 9 Jan 2026 17:36:16 +0800 Subject: [PATCH 03/22] add FE observer as a deployment resource Signed-off-by: zhaohehuhu --- pkg/apis/starrocks/v1/labels.go | 9 +- .../starrocks/v1/starrockscluster_types.go | 29 +++ .../starrocks/v1/zz_generated.deepcopy.go | 49 ++++ pkg/controllers/controllers.go | 4 +- .../starrockscluster_controller.go | 10 + pkg/k8sutils/load/metadata.go | 4 + pkg/k8sutils/templates/pod/spec.go | 43 ++++ pkg/k8sutils/templates/service/spec.go | 4 + .../feobserver/feobserver_config.go | 19 ++ .../feobserver/feobserver_controller.go | 217 ++++++++++++++++++ .../feobserver/feobserver_pod.go | 101 ++++++++ 11 files changed, 484 insertions(+), 5 deletions(-) create mode 100644 pkg/subcontrollers/feobserver/feobserver_config.go create mode 100644 pkg/subcontrollers/feobserver/feobserver_controller.go create mode 100644 pkg/subcontrollers/feobserver/feobserver_pod.go diff --git a/pkg/apis/starrocks/v1/labels.go b/pkg/apis/starrocks/v1/labels.go index 1cfebcffc..6ed097d4c 100644 --- a/pkg/apis/starrocks/v1/labels.go +++ b/pkg/apis/starrocks/v1/labels.go @@ -30,10 +30,11 @@ const ( // the labels value. default statefulset name const ( - DEFAULT_FE = "fe" - DEFAULT_BE = "be" - DEFAULT_CN = "cn" - DEFAULT_FE_PROXY = "fe-proxy" + DEFAULT_FE = "fe" + DEFAULT_BE = "be" + DEFAULT_CN = "cn" + DEFAULT_FE_PROXY = "fe-proxy" + DEFAULT_FE_OBSERVER = "fe-observer" ) // the env of container diff --git a/pkg/apis/starrocks/v1/starrockscluster_types.go b/pkg/apis/starrocks/v1/starrockscluster_types.go index 0af5f3fbc..e1edab64d 100644 --- a/pkg/apis/starrocks/v1/starrockscluster_types.go +++ b/pkg/apis/starrocks/v1/starrockscluster_types.go @@ -90,6 +90,8 @@ type SpecInterface interface { var _ SpecInterface = &StarRocksFeSpec{} +var _ SpecInterface = &StarRocksFeObserverSpec{} + var _ SpecInterface = &StarRocksBeSpec{} var _ SpecInterface = &StarRocksCnSpec{} @@ -106,6 +108,9 @@ type StarRocksClusterSpec struct { // StarRocksFeSpec define fe configuration for start fe service. StarRocksFeSpec *StarRocksFeSpec `json:"starRocksFeSpec,omitempty"` + // StarRocksFeObserverSpec define fe observer configuration for start fe observer service. + StarRocksFeObserverSpec *StarRocksFeObserverSpec `json:"starRocksFeObserverSpec,omitempty"` + // StarRocksBeSpec define be configuration for start be service. StarRocksBeSpec *StarRocksBeSpec `json:"starRocksBeSpec,omitempty"` @@ -131,6 +136,9 @@ type StarRocksClusterStatus struct { // Represents the status of fe. the status have running, failed and creating pods. StarRocksFeStatus *StarRocksFeStatus `json:"starRocksFeStatus,omitempty"` + // Represents the status of fe observer. the status have running, failed and creating pods. + StarRocksFeObserverStatus *StarRocksFeObserverStatus `json:"starRocksFeObserverStatus,omitempty"` + // Represents the status of be. the status have running, failed and creating pods. StarRocksBeStatus *StarRocksBeStatus `json:"starRocksBeStatus,omitempty"` @@ -156,6 +164,15 @@ type StarRocksFeSpec struct { FeEnvVars []corev1.EnvVar `json:"feEnvVars,omitempty"` } +// StarRocksFeObserverSpec defines the desired state of fe observer. +type StarRocksFeObserverSpec struct { + StarRocksComponentSpec `json:",inline"` + + // +optional + // feEnvVars is a slice of environment variables that are added to the pods, the default is empty. + FeEnvVars []corev1.EnvVar `json:"feEnvVars,omitempty"` +} + // StarRocksBeSpec defines the desired state of be. type StarRocksBeSpec struct { StarRocksComponentSpec `json:",inline"` @@ -190,6 +207,11 @@ type StarRocksFeStatus struct { StarRocksComponentStatus `json:",inline"` } +// StarRocksFeObserverStatus represents the status of starrocks fe observer. +type StarRocksFeObserverStatus struct { + StarRocksComponentStatus `json:",inline"` +} + // StarRocksBeStatus represents the status of starrocks be. type StarRocksBeStatus struct { StarRocksComponentStatus `json:",inline"` @@ -224,6 +246,13 @@ func (spec *StarRocksFeSpec) GetReplicas() *int32 { return spec.StarRocksComponentSpec.GetReplicas() } +func (spec *StarRocksFeObserverSpec) GetReplicas() *int32 { + if spec == nil { + return nil + } + return spec.StarRocksComponentSpec.GetReplicas() +} + func (spec *StarRocksBeSpec) GetReplicas() *int32 { if spec == nil { return nil diff --git a/pkg/apis/starrocks/v1/zz_generated.deepcopy.go b/pkg/apis/starrocks/v1/zz_generated.deepcopy.go index 03d196da7..5d7f40093 100644 --- a/pkg/apis/starrocks/v1/zz_generated.deepcopy.go +++ b/pkg/apis/starrocks/v1/zz_generated.deepcopy.go @@ -290,6 +290,11 @@ func (in *StarRocksClusterSpec) DeepCopyInto(out *StarRocksClusterSpec) { *out = new(StarRocksFeSpec) (*in).DeepCopyInto(*out) } + if in.StarRocksFeObserverSpec != nil { + in, out := &in.StarRocksFeObserverSpec, &out.StarRocksFeObserverSpec + *out = new(StarRocksFeObserverSpec) + (*in).DeepCopyInto(*out) + } if in.StarRocksBeSpec != nil { in, out := &in.StarRocksBeSpec, &out.StarRocksBeSpec *out = new(StarRocksBeSpec) @@ -330,6 +335,11 @@ func (in *StarRocksClusterStatus) DeepCopyInto(out *StarRocksClusterStatus) { *out = new(StarRocksFeStatus) (*in).DeepCopyInto(*out) } + if in.StarRocksFeObserverStatus != nil { + in, out := &in.StarRocksFeObserverStatus, &out.StarRocksFeObserverStatus + *out = new(StarRocksFeObserverStatus) + (*in).DeepCopyInto(*out) + } if in.StarRocksBeStatus != nil { in, out := &in.StarRocksBeStatus, &out.StarRocksBeStatus *out = new(StarRocksBeStatus) @@ -599,6 +609,29 @@ func (in *StarRocksFeSpec) DeepCopy() *StarRocksFeSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StarRocksFeObserverSpec) DeepCopyInto(out *StarRocksFeObserverSpec) { + *out = *in + in.StarRocksComponentSpec.DeepCopyInto(&out.StarRocksComponentSpec) + if in.FeEnvVars != nil { + in, out := &in.FeEnvVars, &out.FeEnvVars + *out = make([]corev1.EnvVar, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StarRocksFeObserverSpec. +func (in *StarRocksFeObserverSpec) DeepCopy() *StarRocksFeObserverSpec { + if in == nil { + return nil + } + out := new(StarRocksFeObserverSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StarRocksFeStatus) DeepCopyInto(out *StarRocksFeStatus) { *out = *in @@ -615,6 +648,22 @@ func (in *StarRocksFeStatus) DeepCopy() *StarRocksFeStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StarRocksFeObserverStatus) DeepCopyInto(out *StarRocksFeObserverStatus) { + *out = *in + in.StarRocksComponentStatus.DeepCopyInto(&out.StarRocksComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StarRocksFeObserverStatus. +func (in *StarRocksFeObserverStatus) DeepCopy() *StarRocksFeObserverStatus { + if in == nil { + return nil + } + out := new(StarRocksFeObserverStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StarRocksLoadSpec) DeepCopyInto(out *StarRocksLoadSpec) { *out = *in diff --git a/pkg/controllers/controllers.go b/pkg/controllers/controllers.go index db75ba022..d4d2b474a 100644 --- a/pkg/controllers/controllers.go +++ b/pkg/controllers/controllers.go @@ -14,6 +14,7 @@ import ( "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/be" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/cn" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/fe" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/feobserver" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/feproxy" ) @@ -21,9 +22,10 @@ func SetupClusterReconciler(mgr ctrl.Manager) error { feController := fe.New(mgr.GetClient(), mgr.GetEventRecorderFor) beController := be.New(mgr.GetClient(), mgr.GetEventRecorderFor) cnController := cn.New(mgr.GetClient(), mgr.GetEventRecorderFor) + feObserverController := feobserver.New(mgr.GetClient(), mgr.GetEventRecorderFor) feProxyController := feproxy.New(mgr.GetClient(), mgr.GetEventRecorderFor) subcs := []subcontrollers.ClusterSubController{ - feController, beController, cnController, feProxyController, + feController, feObserverController, beController, cnController, feProxyController, } reconciler := &StarRocksClusterReconciler{ diff --git a/pkg/controllers/starrockscluster_controller.go b/pkg/controllers/starrockscluster_controller.go index 6f9cb3644..30725e06e 100644 --- a/pkg/controllers/starrockscluster_controller.go +++ b/pkg/controllers/starrockscluster_controller.go @@ -34,6 +34,7 @@ import ( "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/be" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/cn" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/fe" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/feobserver" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/feproxy" ) @@ -149,6 +150,13 @@ func (r *StarRocksClusterReconciler) reconcileStatus(_ context.Context, src *sra return } } + if src.Status.StarRocksFeObserverStatus != nil { + phase = GetPhaseFromComponent(&src.Status.StarRocksFeObserverStatus.StarRocksComponentStatus) + if phase != "" { + src.Status.Phase = phase + return + } + } if src.Status.StarRocksBeStatus != nil { phase = GetPhaseFromComponent(&src.Status.StarRocksBeStatus.StarRocksComponentStatus) if phase != "" { @@ -171,6 +179,8 @@ func handleSyncClusterError(src *srapi.StarRocksCluster, subController subcontro switch subController.(type) { case *fe.FeController: reason = fmt.Sprintf("error from FE controller: %v", reason) + case *feobserver.FeObserverController: + reason = fmt.Sprintf("error from FE observer controller: %v", reason) case *be.BeController: reason = fmt.Sprintf("error from BE controller: %v", reason) case *cn.CnController: diff --git a/pkg/k8sutils/load/metadata.go b/pkg/k8sutils/load/metadata.go index 532021ae2..66c023f6c 100644 --- a/pkg/k8sutils/load/metadata.go +++ b/pkg/k8sutils/load/metadata.go @@ -22,6 +22,8 @@ func Name(clusterName string, spec v1.SpecInterface) string { switch spec.(type) { case *v1.StarRocksFeSpec: return clusterName + "-" + v1.DEFAULT_FE + case *v1.StarRocksFeObserverSpec: + return clusterName + "-" + v1.DEFAULT_FE_OBSERVER case *v1.StarRocksBeSpec: return clusterName + "-" + v1.DEFAULT_BE case *v1.StarRocksCnSpec: @@ -38,6 +40,8 @@ func Labels(ownerReference string, spec v1.SpecInterface) map[string]string { switch spec.(type) { case *v1.StarRocksFeSpec: labels[v1.ComponentLabelKey] = v1.DEFAULT_FE + case *v1.StarRocksFeObserverSpec: + labels[v1.ComponentLabelKey] = v1.DEFAULT_FE_OBSERVER case *v1.StarRocksBeSpec: labels[v1.ComponentLabelKey] = v1.DEFAULT_BE case *v1.StarRocksCnSpec: diff --git a/pkg/k8sutils/templates/pod/spec.go b/pkg/k8sutils/templates/pod/spec.go index 3b7d75e58..027230035 100644 --- a/pkg/k8sutils/templates/pod/spec.go +++ b/pkg/k8sutils/templates/pod/spec.go @@ -77,6 +77,10 @@ func Labels(clusterName string, spec v1.SpecInterface) map[string]string { if v != nil { addLabels(labels, v.PodLabels) } + case *v1.StarRocksFeObserverSpec: + if v != nil { + addLabels(labels, v.PodLabels) + } case *v1.StarRocksFeProxySpec: if v != nil { addLabels(labels, v.PodLabels) @@ -160,6 +164,19 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, } { addEnv(envVar) } + case *v1.StarRocksFeObserverSpec: + for _, envVar := range []corev1.EnvVar{ + { + Name: v1.COMPONENT_NAME, + Value: v1.DEFAULT_FE_OBSERVER, + }, + { + Name: v1.FE_SERVICE_NAME, + Value: feExternalServiceName + "." + namespace, + }, + } { + addEnv(envVar) + } case *v1.StarRocksBeSpec: for _, envVar := range []corev1.EnvVar{ { @@ -218,6 +235,22 @@ func Ports(spec v1.SpecInterface, config map[string]interface{}) []corev1.Contai Protocol: corev1.ProtocolTCP, }, }...) + case *v1.StarRocksFeObserverSpec: + ports = append(ports, []corev1.ContainerPort{ + { + Name: "http-port", + ContainerPort: rutils.GetPort(config, rutils.HTTP_PORT), + Protocol: corev1.ProtocolTCP, + }, { + Name: "rpc-port", + ContainerPort: rutils.GetPort(config, rutils.RPC_PORT), + Protocol: corev1.ProtocolTCP, + }, { + Name: "query-port", + ContainerPort: rutils.GetPort(config, rutils.QUERY_PORT), + Protocol: corev1.ProtocolTCP, + }, + }...) case *v1.StarRocksBeSpec: ports = append(ports, []corev1.ContainerPort{ { @@ -339,6 +372,8 @@ func getDefaultEntrypointScript(spec v1.SpecInterface) string { switch v := spec.(type) { case *v1.StarRocksFeSpec: return fmt.Sprintf("%s/fe_entrypoint.sh", GetStarRocksRootPath(v.FeEnvVars)) + case *v1.StarRocksFeObserverSpec: + return fmt.Sprintf("%s/fe_entrypoint.sh", GetStarRocksRootPath(v.FeEnvVars)) case *v1.StarRocksBeSpec: return fmt.Sprintf("%s/be_entrypoint.sh", GetStarRocksRootPath(v.BeEnvVars)) case *v1.StarRocksCnSpec: @@ -351,6 +386,8 @@ func GetStorageDir(spec v1.SpecInterface) string { switch v := spec.(type) { case *v1.StarRocksFeSpec: return fmt.Sprintf("%s/fe/meta", GetStarRocksRootPath(v.FeEnvVars)) + case *v1.StarRocksFeObserverSpec: + return fmt.Sprintf("%s/fe/meta", GetStarRocksRootPath(v.FeEnvVars)) case *v1.StarRocksBeSpec: return fmt.Sprintf("%s/be/storage", GetStarRocksRootPath(v.BeEnvVars)) case *v1.StarRocksCnSpec: @@ -363,6 +400,8 @@ func GetLogDir(spec v1.SpecInterface) string { switch v := spec.(type) { case *v1.StarRocksFeSpec: return fmt.Sprintf("%s/fe/log", GetStarRocksRootPath(v.FeEnvVars)) + case *v1.StarRocksFeObserverSpec: + return fmt.Sprintf("%s/fe/log", GetStarRocksRootPath(v.FeEnvVars)) case *v1.StarRocksBeSpec: return fmt.Sprintf("%s/be/log", GetStarRocksRootPath(v.BeEnvVars)) case *v1.StarRocksCnSpec: @@ -375,6 +414,8 @@ func GetConfigDir(spec v1.SpecInterface) string { switch v := spec.(type) { case *v1.StarRocksFeSpec: return fmt.Sprintf("%s/fe/conf", GetStarRocksRootPath(v.FeEnvVars)) + case *v1.StarRocksFeObserverSpec: + return fmt.Sprintf("%s/fe/conf", GetStarRocksRootPath(v.FeEnvVars)) case *v1.StarRocksBeSpec: return fmt.Sprintf("%s/be/conf", GetStarRocksRootPath(v.BeEnvVars)) case *v1.StarRocksCnSpec: @@ -390,6 +431,8 @@ func GetPreStopCommand(spec v1.SpecInterface) []string { switch v := spec.(type) { case *v1.StarRocksFeSpec: command = append(command, fmt.Sprintf("%s/fe/bin/stop_fe.sh -g", GetStarRocksRootPath(v.FeEnvVars))) + case *v1.StarRocksFeObserverSpec: + command = append(command, fmt.Sprintf("%s/fe/bin/stop_fe.sh -g", GetStarRocksRootPath(v.FeEnvVars))) case *v1.StarRocksBeSpec: imageVersion := GetImageVersion(spec.GetImage()) b, err := IsLowerThanAny(imageVersion, []string{"3.3.19", "3.4.8", "3.5.6"}) diff --git a/pkg/k8sutils/templates/service/spec.go b/pkg/k8sutils/templates/service/spec.go index 80507440c..e50774f06 100644 --- a/pkg/k8sutils/templates/service/spec.go +++ b/pkg/k8sutils/templates/service/spec.go @@ -53,6 +53,8 @@ func SearchServiceName(clusterName string, spec v1.SpecInterface) string { return clusterName + "-cn-search" case *v1.StarRocksFeSpec: return clusterName + "-fe-search" + case *v1.StarRocksFeObserverSpec: + return clusterName + "-fe-observer-search" default: return "" } @@ -63,6 +65,8 @@ func ExternalServiceName(clusterName string, spec v1.SpecInterface) string { switch spec.(type) { case *v1.StarRocksFeSpec: return clusterName + "-" + v1.DEFAULT_FE + "-service" + case *v1.StarRocksFeObserverSpec: + return clusterName + "-" + v1.DEFAULT_FE_OBSERVER + "-service" case *v1.StarRocksBeSpec: return clusterName + "-" + v1.DEFAULT_BE + "-service" case *v1.StarRocksCnSpec: diff --git a/pkg/subcontrollers/feobserver/feobserver_config.go b/pkg/subcontrollers/feobserver/feobserver_config.go new file mode 100644 index 000000000..fb8dbb16c --- /dev/null +++ b/pkg/subcontrollers/feobserver/feobserver_config.go @@ -0,0 +1,19 @@ +package feobserver + +import ( + "context" + + "sigs.k8s.io/controller-runtime/pkg/client" + + srapi "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/pod" +) + +// GetFEObserverConfig get the fe observer config from configMap. +func GetFEObserverConfig(ctx context.Context, client client.Client, + observerSpec *srapi.StarRocksFeObserverSpec, namespace string) (map[string]interface{}, error) { + return k8sutils.GetConfig(ctx, client, observerSpec.ConfigMapInfo, + observerSpec.ConfigMaps, pod.GetConfigDir(observerSpec), "fe.conf", + namespace) +} diff --git a/pkg/subcontrollers/feobserver/feobserver_controller.go b/pkg/subcontrollers/feobserver/feobserver_controller.go new file mode 100644 index 000000000..c6d1b9d34 --- /dev/null +++ b/pkg/subcontrollers/feobserver/feobserver_controller.go @@ -0,0 +1,217 @@ +/* +Copyright 2021-present, StarRocks Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package feobserver + +import ( + "context" + "fmt" + + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/deployment" + "github.com/go-logr/logr" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/client-go/tools/record" + "sigs.k8s.io/controller-runtime/pkg/client" + + srapi "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/common/log" + rutils "github.com/StarRocks/starrocks-kubernetes-operator/pkg/common/resource_utils" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/load" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/object" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/pod" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/service" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers" +) + +type FeObserverController struct { + Client client.Client + Recorder record.EventRecorder +} + +// New construct a FeObserverController. +func New(k8sClient client.Client, recorderFor subcontrollers.GetEventRecorderForFunc) *FeObserverController { + controller := &FeObserverController{ + Client: k8sClient, + } + controller.Recorder = recorderFor(controller.GetControllerName()) + return controller +} + +func (fc *FeObserverController) GetControllerName() string { + return "feObserverController" +} + +// SyncCluster starRocksCluster spec to fe observer deployment and service. +func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.StarRocksCluster) error { + logger := logr.FromContextOrDiscard(ctx).WithName(fc.GetControllerName()).WithValues(log.ActionKey, log.ActionSyncCluster) + ctx = logr.NewContext(ctx, logger) + if src.Spec.StarRocksFeObserverSpec == nil { + logger.Info("src.Spec.StarRocksFeObserverSpec == nil, skip sync fe observer") + return nil + } + if src.Spec.StarRocksFeSpec == nil { + return fmt.Errorf("starRocksFeSpec is required before deploying fe observer") + } + + var err error + defer func() { + // we do not record an event if the error is nil, because this will cause too many events to be recorded. + if err != nil { + fc.Recorder.Event(src, corev1.EventTypeWarning, "SyncFeObserverFailed", err.Error()) + } + }() + + observerSpec := src.Spec.StarRocksFeObserverSpec + if err = fc.Validating(observerSpec); err != nil { + return err + } + + // get the fe observer configMap for resolve ports + logger.V(log.DebugLevel).Info("get fe observer configMap to resolve ports", "ConfigMapInfo", observerSpec.ConfigMapInfo) + observerConfig, err := GetFEObserverConfig(ctx, fc.Client, observerSpec, src.Namespace) + if err != nil { + logger.Error(err, "get fe observer config failed", "ConfigMapInfo", observerSpec.ConfigMapInfo) + return err + } + + // generate new fe observer service. + logger.V(log.DebugLevel).Info("build fe observer service", "StarRocksCluster", src) + object := object.NewFromCluster(src) + defaultLabels := load.Labels(src.Name, observerSpec) + svc := rutils.BuildExternalService(object, observerSpec, observerConfig, load.Selector(src.Name, observerSpec), defaultLabels) + searchServiceName := service.SearchServiceName(src.Name, observerSpec) + internalService := service.MakeSearchService(searchServiceName, &svc, []corev1.ServicePort{ + { + Name: "query-port", + Port: rutils.GetPort(observerConfig, rutils.QUERY_PORT), + TargetPort: intstr.FromInt(int(rutils.GetPort(observerConfig, rutils.QUERY_PORT))), + AppProtocol: func() *string { mysql := "mysql"; return &mysql }(), + }, + }, defaultLabels) + + podTemplateSpec, err := fc.buildPodTemplate(src, observerConfig) + if err != nil { + logger.Error(err, "build pod template failed") + return err + } + expectDeployment := deployment.MakeDeployment(src, observerSpec, *podTemplateSpec) + err = k8sutils.ApplyDeployment(ctx, fc.Client, expectDeployment) + if err != nil { + logger.Error(err, "fe observer deployment failed", "StarRocksCluster", src) + return err + } + + if err = k8sutils.ApplyService(ctx, fc.Client, internalService, rutils.ServiceDeepEqual); err != nil { + logger.Error(err, "deploy search service failed", "internalService", internalService) + fc.Recorder.Event(src, corev1.EventTypeWarning, "DeployFeObserverFailed", err.Error()) + return err + } + + if err = k8sutils.ApplyService(ctx, fc.Client, &svc, rutils.ServiceDeepEqual); err != nil { + logger.Error(err, "deploy external service failed", "externalService", svc) + return err + } + + return nil +} + +// UpdateClusterStatus update the all resource status about fe observer. +func (fc *FeObserverController) UpdateClusterStatus(_ context.Context, src *srapi.StarRocksCluster) error { + observerSpec := src.Spec.StarRocksFeObserverSpec + if observerSpec == nil { + src.Status.StarRocksFeObserverStatus = nil + return nil + } + + fs := &srapi.StarRocksFeObserverStatus{ + StarRocksComponentStatus: srapi.StarRocksComponentStatus{ + Phase: srapi.ComponentReconciling, + }, + } + + if src.Status.StarRocksFeObserverStatus != nil { + fs = src.Status.StarRocksFeObserverStatus.DeepCopy() + } + + src.Status.StarRocksFeObserverStatus = fs + fs.ServiceName = service.ExternalServiceName(src.Name, observerSpec) + deploymentName := load.Name(src.Name, observerSpec) + fs.ResourceNames = rutils.MergeSlices(fs.ResourceNames, []string{deploymentName}) + + if err := subcontrollers.UpdateStatus(&fs.StarRocksComponentStatus, fc.Client, + src.Namespace, deploymentName, pod.Labels(src.Name, observerSpec), subcontrollers.DeploymentLoadType); err != nil { + return err + } + + var deploy appsv1.Deployment + if err := fc.Client.Get(context.Background(), types.NamespacedName{Namespace: src.Namespace, Name: deploymentName}, &deploy); err != nil { + return err + } + + return nil +} + +// ClearCluster clears resource about fe observer. +func (fc *FeObserverController) ClearCluster(ctx context.Context, src *srapi.StarRocksCluster) error { + logger := logr.FromContextOrDiscard(ctx).WithName(fc.GetControllerName()).WithValues(log.ActionKey, log.ActionCluster) + ctx = logr.NewContext(ctx, logger) + + if src.Status.StarRocksFeObserverStatus == nil { + return nil + } + + if src.DeletionTimestamp.IsZero() { + return nil + } + + observerSpec := src.Spec.StarRocksFeObserverSpec + deploymentName := load.Name(src.Name, observerSpec) + if err := k8sutils.DeleteDeployment(ctx, fc.Client, src.Namespace, deploymentName); err != nil && !apierrors.IsNotFound(err) { + logger.Error(err, "delete deployment failed", "deploymentName", deploymentName) + return err + } + + searchServiceName := service.SearchServiceName(src.Name, observerSpec) + if err := k8sutils.DeleteService(ctx, fc.Client, src.Namespace, searchServiceName); err != nil && !apierrors.IsNotFound(err) { + logger.Error(err, "delete search service failed", "searchServiceName", searchServiceName) + return err + } + externalServiceName := service.ExternalServiceName(src.Name, observerSpec) + err := k8sutils.DeleteService(ctx, fc.Client, src.Namespace, externalServiceName) + if err != nil && !apierrors.IsNotFound(err) { + logger.Error(err, "delete external service failed", "externalServiceName", externalServiceName) + return err + } + + return nil +} + +func (fc *FeObserverController) Validating(observerSpec *srapi.StarRocksFeObserverSpec) error { + for i := range observerSpec.StorageVolumes { + if err := observerSpec.StorageVolumes[i].Validate(); err != nil { + return err + } + } + if err := srapi.ValidUpdateStrategy(observerSpec.UpdateStrategy); err != nil { + return err + } + return nil +} diff --git a/pkg/subcontrollers/feobserver/feobserver_pod.go b/pkg/subcontrollers/feobserver/feobserver_pod.go new file mode 100644 index 000000000..a85830d2e --- /dev/null +++ b/pkg/subcontrollers/feobserver/feobserver_pod.go @@ -0,0 +1,101 @@ +/* +Copyright 2021-present, StarRocks Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package feobserver + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + srapi "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1" + rutils "github.com/StarRocks/starrocks-kubernetes-operator/pkg/common/resource_utils" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/pod" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/service" +) + +const ( + _metaName = "fe-meta" + _logName = "fe-log" + _feConfigMountPath = "/etc/starrocks/fe/conf" + _envFeConfigMountPath = "CONFIGMAP_MOUNT_PATH" +) + +// buildPodTemplate construct the podTemplate for deploy fe observer. +func (fc *FeObserverController) buildPodTemplate(src *srapi.StarRocksCluster, config map[string]interface{}) (*corev1.PodTemplateSpec, error) { + metaName := src.Name + "-" + srapi.DEFAULT_FE_OBSERVER + observerSpec := src.Spec.StarRocksFeObserverSpec + + vols, volMounts := pod.MountStorageVolumes(observerSpec) + // add default volume about log, meta if not configure. + if !k8sutils.HasVolume(vols, _metaName) && !k8sutils.HasMountPath(volMounts, pod.GetStorageDir(observerSpec)) { + vols, volMounts = pod.MountEmptyDirVolume(vols, volMounts, _metaName, pod.GetStorageDir(observerSpec), "") + } + if !k8sutils.HasVolume(vols, _logName) && !k8sutils.HasMountPath(volMounts, pod.GetLogDir(observerSpec)) { + vols, volMounts = pod.MountEmptyDirVolume(vols, volMounts, _logName, pod.GetLogDir(observerSpec), "") + } + + // mount configmap, secrets to pod if needed + vols, volMounts = pod.MountConfigMapInfo(vols, volMounts, observerSpec.ConfigMapInfo, _feConfigMountPath) + vols, volMounts = pod.MountConfigMaps(observerSpec, vols, volMounts, observerSpec.ConfigMaps) + vols, volMounts = pod.MountSecrets(vols, volMounts, observerSpec.Secrets) + if err := k8sutils.CheckVolumes(vols, volMounts); err != nil { + return nil, err + } + + feServiceName := service.ExternalServiceName(src.Name, src.Spec.StarRocksFeSpec) + envs := pod.Envs(observerSpec, config, feServiceName, src.Namespace, observerSpec.FeEnvVars) + httpPort := rutils.GetPort(config, rutils.HTTP_PORT) + feObserverContainer := corev1.Container{ + Name: srapi.DEFAULT_FE_OBSERVER, + Image: observerSpec.Image, + Command: pod.ContainerCommand(observerSpec), + Args: pod.ContainerArgs(observerSpec), + Ports: pod.Ports(observerSpec, config), + Env: envs, + Resources: observerSpec.ResourceRequirements, + VolumeMounts: volMounts, + ImagePullPolicy: observerSpec.GetImagePullPolicy(), + StartupProbe: pod.StartupProbe(observerSpec.GetStartupProbeFailureSeconds(), httpPort, pod.HEALTH_API_PATH), + LivenessProbe: pod.LivenessProbe(observerSpec.GetLivenessProbeFailureSeconds(), httpPort, pod.HEALTH_API_PATH), + ReadinessProbe: pod.ReadinessProbe(observerSpec.GetReadinessProbeFailureSeconds(), httpPort, pod.HEALTH_API_PATH), + Lifecycle: pod.LifeCycle(observerSpec.GetLifecycle(), pod.GetPreStopCommand(observerSpec)), + SecurityContext: pod.ContainerSecurityContext(observerSpec), + } + if pod.GetStarRocksRootPath(observerSpec.FeEnvVars) != pod.GetStarRocksDefaultRootPath() { + feObserverContainer.WorkingDir = pod.GetStarRocksRootPath(observerSpec.FeEnvVars) + } + + if observerSpec.ConfigMapInfo.ConfigMapName != "" && observerSpec.ConfigMapInfo.ResolveKey != "" { + feObserverContainer.Env = append(feObserverContainer.Env, corev1.EnvVar{ + Name: _envFeConfigMountPath, + Value: _feConfigMountPath, + }) + } + + podSpec := pod.Spec(observerSpec, feObserverContainer, vols) + annotations := pod.Annotations(observerSpec) + podSpec.SecurityContext = pod.PodSecurityContext(observerSpec) + return &corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Name: metaName, + Namespace: src.Namespace, + Annotations: annotations, + Labels: pod.Labels(src.Name, observerSpec), + }, + Spec: podSpec, + }, nil +} From 3725cb5ecf6cdee6879d62ac5bb6b3ae373a6f0f Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Mon, 12 Jan 2026 16:48:59 +0800 Subject: [PATCH 04/22] add UTs Signed-off-by: zhaohehuhu --- .../starrocks.com_starrocksclusters.yaml | 4456 +++++++++++++++++ deploy/starrocks.com_starrocksclusters.yaml | 2082 ++++++++ .../starrocks/templates/starrockscluster.yaml | 178 + .../charts/starrocks/values.yaml | 204 + helm-charts/charts/kube-starrocks/values.yaml | 204 + .../starrocks/v1/zz_generated.deepcopy.go | 78 +- .../feobserver/feobserver_controller.go | 2 +- .../feobserver/feobserver_controller_test.go | 332 ++ .../feobserver/feobserver_pod.go | 3 +- 9 files changed, 7498 insertions(+), 41 deletions(-) create mode 100644 pkg/subcontrollers/feobserver/feobserver_controller_test.go diff --git a/config/crd/bases/starrocks.com_starrocksclusters.yaml b/config/crd/bases/starrocks.com_starrocksclusters.yaml index c8d5e3c33..e8ce6dc69 100644 --- a/config/crd/bases/starrocks.com_starrocksclusters.yaml +++ b/config/crd/bases/starrocks.com_starrocksclusters.yaml @@ -9450,6 +9450,4424 @@ spec: - Ignore: node taints are ignored. All nodes are included. + If this value is nil, the behavior is equivalent to the Ignore policy. + This is a beta-level feature default enabled by the NodeInclusionPolicyInPodTopologySpread feature flag. + type: string + topologyKey: + description: |- + TopologyKey is the key of node labels. Nodes that have a label with this key + and identical values are considered to be in the same topology. + We consider each as a "bucket", and try to put balanced number + of pods into each bucket. + We define a domain as a particular instance of a topology. + Also, we define an eligible domain as a domain whose nodes meet the requirements of + nodeAffinityPolicy and nodeTaintsPolicy. + e.g. If TopologyKey is "kubernetes.io/hostname", each Node is a domain of that topology. + And, if TopologyKey is "topology.kubernetes.io/zone", each zone is a domain of that topology. + It's a required field. + type: string + whenUnsatisfiable: + description: |- + WhenUnsatisfiable indicates how to deal with a pod if it doesn't satisfy + the spread constraint. + - DoNotSchedule (default) tells the scheduler not to schedule it. + - ScheduleAnyway tells the scheduler to schedule the pod in any location, + but giving higher precedence to topologies that would help reduce the + skew. + A constraint is considered "Unsatisfiable" for an incoming pod + if and only if every possible node assignment for that pod would violate + "MaxSkew" on some topology. + For example, in a 3-zone cluster, MaxSkew is set to 1, and pods with the same + labelSelector spread as 3/1/1: + | zone1 | zone2 | zone3 | + | P P P | P | P | + If WhenUnsatisfiable is set to DoNotSchedule, incoming pod can only be scheduled + to zone2(zone3) to become 3/2/1(3/1/2) as ActualSkew(2-1) on zone2(zone3) satisfies + MaxSkew(1). In other words, the cluster can still be imbalanced, but scheduler + won't make it *more* imbalanced. + It's a required field. + type: string + required: + - maxSkew + - topologyKey + - whenUnsatisfiable + type: object + type: array + updateStrategy: + description: |- + StarRocksCluster use StatefulSet to deploy FE/BE/CN components. + UpdateStrategy indicates the StatefulSetUpdateStrategy that will be + employed to update Pods in the StatefulSet when a revision is made to + Template. See https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#rolling-updates for more details. + Note: The maxUnavailable field is in Alpha stage and it is honored only by API servers that are running with the + MaxUnavailableStatefulSet feature gate enabled. + properties: + rollingUpdate: + description: RollingUpdate is used to communicate parameters + when Type is RollingUpdateStatefulSetStrategyType. + properties: + maxUnavailable: + anyOf: + - type: integer + - type: string + description: |- + The maximum number of pods that can be unavailable during the update. + Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). + Absolute number is calculated from percentage by rounding up. This can not be 0. + Defaults to 1. This field is alpha-level and is only honored by servers that enable the + MaxUnavailableStatefulSet feature. The field applies to all pods in the range 0 to + Replicas-1. That means if there is any unavailable pod in the range 0 to Replicas-1, it + will be counted towards MaxUnavailable. + x-kubernetes-int-or-string: true + partition: + description: |- + Partition indicates the ordinal at which the StatefulSet should be partitioned + for updates. During a rolling update, all pods from ordinal Replicas-1 to + Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched. + This is helpful in being able to do a canary based deployment. The default value is 0. + format: int32 + type: integer + type: object + type: + description: |- + Type indicates the type of the StatefulSetUpdateStrategy. + Default is RollingUpdate. + type: string + type: object + type: object + starRocksFeObserverSpec: + description: StarRocksFeObserverSpec define fe observer configuration + for start fe observer service. + properties: + affinity: + description: If specified, the pod's scheduling constraints. + properties: + nodeAffinity: + description: Describes node affinity scheduling rules for + the pod. + properties: + preferredDuringSchedulingIgnoredDuringExecution: + description: |- + The scheduler will prefer to schedule pods to nodes that satisfy + the affinity expressions specified by this field, but it may choose + a node that violates one or more of the expressions. The node that is + most preferred is the one with the greatest sum of weights, i.e. + for each node that meets all of the scheduling requirements (resource + request, requiredDuringScheduling affinity expressions, etc.), + compute a sum by iterating through the elements of this field and adding + "weight" to the sum if the node matches the corresponding matchExpressions; the + node(s) with the highest sum are the most preferred. + items: + description: |- + An empty preferred scheduling term matches all objects with implicit weight 0 + (i.e. it's a no-op). A null preferred scheduling term matches no objects (i.e. is also a no-op). + properties: + preference: + description: A node selector term, associated with + the corresponding weight. + properties: + matchExpressions: + description: A list of node selector requirements + by node's labels. + items: + description: |- + A node selector requirement is a selector that contains values, a key, and an operator + that relates the key and values. + properties: + key: + description: The label key that the selector + applies to. + type: string + operator: + description: |- + Represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. + type: string + values: + description: |- + An array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. If the operator is Gt or Lt, the values + array must have a single element, which will be interpreted as an integer. + This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchFields: + description: A list of node selector requirements + by node's fields. + items: + description: |- + A node selector requirement is a selector that contains values, a key, and an operator + that relates the key and values. + properties: + key: + description: The label key that the selector + applies to. + type: string + operator: + description: |- + Represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. + type: string + values: + description: |- + An array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. If the operator is Gt or Lt, the values + array must have a single element, which will be interpreted as an integer. + This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + type: object + x-kubernetes-map-type: atomic + weight: + description: Weight associated with matching the + corresponding nodeSelectorTerm, in the range 1-100. + format: int32 + type: integer + required: + - preference + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + description: |- + If the affinity requirements specified by this field are not met at + scheduling time, the pod will not be scheduled onto the node. + If the affinity requirements specified by this field cease to be met + at some point during pod execution (e.g. due to an update), the system + may or may not try to eventually evict the pod from its node. + properties: + nodeSelectorTerms: + description: Required. A list of node selector terms. + The terms are ORed. + items: + description: |- + A null or empty node selector term matches no objects. The requirements of + them are ANDed. + The TopologySelectorTerm type implements a subset of the NodeSelectorTerm. + properties: + matchExpressions: + description: A list of node selector requirements + by node's labels. + items: + description: |- + A node selector requirement is a selector that contains values, a key, and an operator + that relates the key and values. + properties: + key: + description: The label key that the selector + applies to. + type: string + operator: + description: |- + Represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. + type: string + values: + description: |- + An array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. If the operator is Gt or Lt, the values + array must have a single element, which will be interpreted as an integer. + This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchFields: + description: A list of node selector requirements + by node's fields. + items: + description: |- + A node selector requirement is a selector that contains values, a key, and an operator + that relates the key and values. + properties: + key: + description: The label key that the selector + applies to. + type: string + operator: + description: |- + Represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. + type: string + values: + description: |- + An array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. If the operator is Gt or Lt, the values + array must have a single element, which will be interpreted as an integer. + This array is replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + type: object + x-kubernetes-map-type: atomic + type: array + required: + - nodeSelectorTerms + type: object + x-kubernetes-map-type: atomic + type: object + podAffinity: + description: Describes pod affinity scheduling rules (e.g. + co-locate this pod in the same node, zone, etc. as some + other pod(s)). + properties: + preferredDuringSchedulingIgnoredDuringExecution: + description: |- + The scheduler will prefer to schedule pods to nodes that satisfy + the affinity expressions specified by this field, but it may choose + a node that violates one or more of the expressions. The node that is + most preferred is the one with the greatest sum of weights, i.e. + for each node that meets all of the scheduling requirements (resource + request, requiredDuringScheduling affinity expressions, etc.), + compute a sum by iterating through the elements of this field and adding + "weight" to the sum if the node has pods which matches the corresponding podAffinityTerm; the + node(s) with the highest sum are the most preferred. + items: + description: The weights of all of the matched WeightedPodAffinityTerm + fields are added per-node to find the most preferred + node(s) + properties: + podAffinityTerm: + description: Required. A pod affinity term, associated + with the corresponding weight. + properties: + labelSelector: + description: A label query over a set of resources, + in this case pods. + properties: + matchExpressions: + description: matchExpressions is a list + of label selector requirements. The requirements + are ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key + that the selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + namespaceSelector: + description: |- + A label query over the set of namespaces that the term applies to. + The term is applied to the union of the namespaces selected by this field + and the ones listed in the namespaces field. + null selector and null or empty namespaces list means "this pod's namespace". + An empty selector ({}) matches all namespaces. + properties: + matchExpressions: + description: matchExpressions is a list + of label selector requirements. The requirements + are ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key + that the selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + namespaces: + description: |- + namespaces specifies a static list of namespace names that the term applies to. + The term is applied to the union of the namespaces listed in this field + and the ones selected by namespaceSelector. + null or empty namespaces list and null namespaceSelector means "this pod's namespace". + items: + type: string + type: array + topologyKey: + description: |- + This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching + the labelSelector in the specified namespaces, where co-located is defined as running on a node + whose value of the label with key topologyKey matches that of any node on which any of the + selected pods is running. + Empty topologyKey is not allowed. + type: string + required: + - topologyKey + type: object + weight: + description: |- + weight associated with matching the corresponding podAffinityTerm, + in the range 1-100. + format: int32 + type: integer + required: + - podAffinityTerm + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + description: |- + If the affinity requirements specified by this field are not met at + scheduling time, the pod will not be scheduled onto the node. + If the affinity requirements specified by this field cease to be met + at some point during pod execution (e.g. due to a pod label update), the + system may or may not try to eventually evict the pod from its node. + When there are multiple elements, the lists of nodes corresponding to each + podAffinityTerm are intersected, i.e. all terms must be satisfied. + items: + description: |- + Defines a set of pods (namely those matching the labelSelector + relative to the given namespace(s)) that this pod should be + co-located (affinity) or not co-located (anti-affinity) with, + where co-located is defined as running on a node whose value of + the label with key matches that of any node on which + a pod of the set of pods is running + properties: + labelSelector: + description: A label query over a set of resources, + in this case pods. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + namespaceSelector: + description: |- + A label query over the set of namespaces that the term applies to. + The term is applied to the union of the namespaces selected by this field + and the ones listed in the namespaces field. + null selector and null or empty namespaces list means "this pod's namespace". + An empty selector ({}) matches all namespaces. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + namespaces: + description: |- + namespaces specifies a static list of namespace names that the term applies to. + The term is applied to the union of the namespaces listed in this field + and the ones selected by namespaceSelector. + null or empty namespaces list and null namespaceSelector means "this pod's namespace". + items: + type: string + type: array + topologyKey: + description: |- + This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching + the labelSelector in the specified namespaces, where co-located is defined as running on a node + whose value of the label with key topologyKey matches that of any node on which any of the + selected pods is running. + Empty topologyKey is not allowed. + type: string + required: + - topologyKey + type: object + type: array + type: object + podAntiAffinity: + description: Describes pod anti-affinity scheduling rules + (e.g. avoid putting this pod in the same node, zone, etc. + as some other pod(s)). + properties: + preferredDuringSchedulingIgnoredDuringExecution: + description: |- + The scheduler will prefer to schedule pods to nodes that satisfy + the anti-affinity expressions specified by this field, but it may choose + a node that violates one or more of the expressions. The node that is + most preferred is the one with the greatest sum of weights, i.e. + for each node that meets all of the scheduling requirements (resource + request, requiredDuringScheduling anti-affinity expressions, etc.), + compute a sum by iterating through the elements of this field and adding + "weight" to the sum if the node has pods which matches the corresponding podAffinityTerm; the + node(s) with the highest sum are the most preferred. + items: + description: The weights of all of the matched WeightedPodAffinityTerm + fields are added per-node to find the most preferred + node(s) + properties: + podAffinityTerm: + description: Required. A pod affinity term, associated + with the corresponding weight. + properties: + labelSelector: + description: A label query over a set of resources, + in this case pods. + properties: + matchExpressions: + description: matchExpressions is a list + of label selector requirements. The requirements + are ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key + that the selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + namespaceSelector: + description: |- + A label query over the set of namespaces that the term applies to. + The term is applied to the union of the namespaces selected by this field + and the ones listed in the namespaces field. + null selector and null or empty namespaces list means "this pod's namespace". + An empty selector ({}) matches all namespaces. + properties: + matchExpressions: + description: matchExpressions is a list + of label selector requirements. The requirements + are ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key + that the selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + namespaces: + description: |- + namespaces specifies a static list of namespace names that the term applies to. + The term is applied to the union of the namespaces listed in this field + and the ones selected by namespaceSelector. + null or empty namespaces list and null namespaceSelector means "this pod's namespace". + items: + type: string + type: array + topologyKey: + description: |- + This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching + the labelSelector in the specified namespaces, where co-located is defined as running on a node + whose value of the label with key topologyKey matches that of any node on which any of the + selected pods is running. + Empty topologyKey is not allowed. + type: string + required: + - topologyKey + type: object + weight: + description: |- + weight associated with matching the corresponding podAffinityTerm, + in the range 1-100. + format: int32 + type: integer + required: + - podAffinityTerm + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + description: |- + If the anti-affinity requirements specified by this field are not met at + scheduling time, the pod will not be scheduled onto the node. + If the anti-affinity requirements specified by this field cease to be met + at some point during pod execution (e.g. due to a pod label update), the + system may or may not try to eventually evict the pod from its node. + When there are multiple elements, the lists of nodes corresponding to each + podAffinityTerm are intersected, i.e. all terms must be satisfied. + items: + description: |- + Defines a set of pods (namely those matching the labelSelector + relative to the given namespace(s)) that this pod should be + co-located (affinity) or not co-located (anti-affinity) with, + where co-located is defined as running on a node whose value of + the label with key matches that of any node on which + a pod of the set of pods is running + properties: + labelSelector: + description: A label query over a set of resources, + in this case pods. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + namespaceSelector: + description: |- + A label query over the set of namespaces that the term applies to. + The term is applied to the union of the namespaces selected by this field + and the ones listed in the namespaces field. + null selector and null or empty namespaces list means "this pod's namespace". + An empty selector ({}) matches all namespaces. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + namespaces: + description: |- + namespaces specifies a static list of namespace names that the term applies to. + The term is applied to the union of the namespaces listed in this field + and the ones selected by namespaceSelector. + null or empty namespaces list and null namespaceSelector means "this pod's namespace". + items: + type: string + type: array + topologyKey: + description: |- + This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching + the labelSelector in the specified namespaces, where co-located is defined as running on a node + whose value of the label with key topologyKey matches that of any node on which any of the + selected pods is running. + Empty topologyKey is not allowed. + type: string + required: + - topologyKey + type: object + type: array + type: object + type: object + annotations: + additionalProperties: + type: string + description: annotation for pods. user can config monitor annotation + for collect to monitor system. + type: object + args: + description: |- + Arguments to the entrypoint. + If this is not provided, it will use $(FE_SERVICE_NAME) for all components. + Variable references $(VAR_NAME) are expanded using the container's environment. If a variable + cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced + to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will + produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless + of whether the variable exists or not. Cannot be updated. + More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell + items: + type: string + type: array + capabilities: + description: |- + refer to https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-capabilities-for-a-container + grant certain privileges to a process without granting all the privileges of the root user + properties: + add: + description: Added capabilities + items: + description: Capability represent POSIX capabilities type + type: string + type: array + drop: + description: Removed capabilities + items: + description: Capability represent POSIX capabilities type + type: string + type: array + type: object + claims: + description: |- + Claims lists the names of resources, defined in spec.resourceClaims, + that are used by this container. + + + This is an alpha field and requires enabling the + DynamicResourceAllocation feature gate. + + + This field is immutable. + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: |- + Name must match the name of one entry in pod.spec.resourceClaims of + the Pod where this field is used. It makes that resource available + inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + command: + description: "Entrypoint array. Not executed within a shell.\nIf + this is not provided, it will use default entrypoint for different + components:\n\t1. For FE, it will use /opt/starrocks/fe_entrypoint.sh + as the entrypoint.\n 2. For BE, it will use /opt/starrocks/be_entrypoint.sh + as the entrypoint.\n 3. For CN, it will use /opt/starrocks/cn_entrypoint.sh + as the entrypoint.\nMore info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell" + items: + type: string + type: array + configMapInfo: + description: the reference for configMap which store the config + info to start starrocks. e.g. be.conf, fe.conf, cn.conf. + properties: + configMapName: + description: the config info for start progress. + type: string + resolveKey: + description: the config response key in configmap. + type: string + type: object + configMaps: + description: the reference for configMap which allow users to + mount any files to container. + items: + description: |- + MountInfo + The reason why we do not support defaultMode is that we use hash.HashObject to + calculate the actual volume name. This volume name is used in pod template of statefulset, + and if this MountInfo type has been changed, the volume name will be changed too, and + that will make pods restart. + The default mode is 0644, and in order to support to set permission information for a configMap + or secret, we add should specify the subPath and specify a command or args in the container. + And It will be set 0755. + properties: + mountPath: + description: |- + Path within the container at which the volume should be mounted. Must + not contain ':'. + type: string + name: + description: |- + This must match the Name of a ConfigMap or Secret in the same namespace, and + the length of name must not more than 50 characters. + type: string + subPath: + description: |- + SubPath within the volume from which the container's volume should be mounted. + Defaults to "" (volume's root). + type: string + type: object + type: array + feEnvVars: + description: feEnvVars is a slice of environment variables that + are added to the pods, the default is empty. + items: + description: EnvVar represents an environment variable present + in a Container. + properties: + name: + description: Name of the environment variable. Must be a + C_IDENTIFIER. + type: string + value: + description: |- + Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in the container and + any service environment variables. If a variable cannot be resolved, + the reference in the input string will be unchanged. Double $$ are reduced + to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. + "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". + Escaped references will never be expanded, regardless of whether the variable + exists or not. + Defaults to "". + type: string + valueFrom: + description: Source for the environment variable's value. + Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + optional: + description: Specify whether the ConfigMap or its + key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: |- + Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, + spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the + specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: |- + Selects a resource of the container: only resources limits and requests + (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the + exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the pod's + namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + optional: + description: Specify whether the Secret or its key + must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + hostAliases: + description: |- + HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts + file if specified. This is only valid for non-hostNetwork pods. + items: + description: |- + HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the + pod's hosts file. + properties: + hostnames: + description: Hostnames for the above IP address. + items: + type: string + type: array + ip: + description: IP address of the host file entry. + type: string + type: object + type: array + image: + description: Image for a starrocks deployment. + type: string + imagePullPolicy: + description: |- + Image pull policy. + One of Always, Never, IfNotPresent. + Defaults to IfNotPresent for compatibility. + More info: https://kubernetes.io/docs/concepts/containers/images#updating-images + type: string + imagePullSecrets: + description: |- + ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the + images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for + them to use. + More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod + items: + description: |- + LocalObjectReference contains enough information to let you locate the + referenced object inside the same namespace. + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + type: object + x-kubernetes-map-type: atomic + type: array + initContainers: + description: |- + InitContainers is an optional list of containers that are run in the same pod as the starrocks component. + You can use this field to launch helper containers that run before the main container starts. + See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to configure a container. + items: + description: A single application container that you want to + run within a pod. + properties: + args: + description: |- + Arguments to the entrypoint. + The container image's CMD is used if this is not provided. + Variable references $(VAR_NAME) are expanded using the container's environment. If a variable + cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced + to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will + produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless + of whether the variable exists or not. Cannot be updated. + More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell + items: + type: string + type: array + command: + description: |- + Entrypoint array. Not executed within a shell. + The container image's ENTRYPOINT is used if this is not provided. + Variable references $(VAR_NAME) are expanded using the container's environment. If a variable + cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced + to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will + produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless + of whether the variable exists or not. Cannot be updated. + More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell + items: + type: string + type: array + env: + description: |- + List of environment variables to set in the container. + Cannot be updated. + items: + description: EnvVar represents an environment variable + present in a Container. + properties: + name: + description: Name of the environment variable. Must + be a C_IDENTIFIER. + type: string + value: + description: |- + Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in the container and + any service environment variables. If a variable cannot be resolved, + the reference in the input string will be unchanged. Double $$ are reduced + to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. + "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". + Escaped references will never be expanded, regardless of whether the variable + exists or not. + Defaults to "". + type: string + valueFrom: + description: Source for the environment variable's + value. Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + optional: + description: Specify whether the ConfigMap + or its key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: |- + Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, + spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in + the specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: |- + Selects a resource of the container: only resources limits and requests + (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. + properties: + containerName: + description: 'Container name: required for + volumes, optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of + the exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the + pod's namespace + properties: + key: + description: The key of the secret to select + from. Must be a valid secret key. + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + optional: + description: Specify whether the Secret or + its key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + description: |- + List of sources to populate environment variables in the container. + The keys defined within a source must be a C_IDENTIFIER. All invalid keys + will be reported as an event when the container is starting. When a key exists in multiple + sources, the value associated with the last source will take precedence. + Values defined by an Env with a duplicate key will take precedence. + Cannot be updated. + items: + description: EnvFromSource represents the source of a + set of ConfigMaps + properties: + configMapRef: + description: The ConfigMap to select from + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + optional: + description: Specify whether the ConfigMap must + be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + description: An optional identifier to prepend to + each key in the ConfigMap. Must be a C_IDENTIFIER. + type: string + secretRef: + description: The Secret to select from + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + optional: + description: Specify whether the Secret must be + defined + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + description: |- + Container image name. + More info: https://kubernetes.io/docs/concepts/containers/images + This field is optional to allow higher level config management to default or override + container images in workload controllers like Deployments and StatefulSets. + type: string + imagePullPolicy: + description: |- + 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 + type: string + lifecycle: + description: |- + Actions that the management system should take in response to container lifecycle events. + Cannot be updated. + properties: + postStart: + description: |- + PostStart is called immediately after a container is created. If the handler fails, + the container is terminated and restarted according to its restart policy. + Other management of the container blocks until the hook completes. + More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request + to perform. + properties: + host: + description: |- + Host name to connect to, defaults to the pod IP. You probably want to set + "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom + header to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Name or number of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: |- + Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: |- + Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept + for the backward compatibility. There are no validation of this field and + lifecycle hooks will fail in runtime when tcp handler is specified. + properties: + host: + description: 'Optional: Host name to connect + to, defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Number or name of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: |- + PreStop is called immediately before a container is terminated due to an + API request or management event such as liveness/startup probe failure, + preemption, resource contention, etc. The handler is not called if the + container crashes or exits. The Pod's termination grace period countdown begins before the + PreStop hook is executed. Regardless of the outcome of the handler, the + container will eventually terminate within the Pod's termination grace + period (unless delayed by finalizers). Other management of the container blocks until the hook completes + or until the termination grace period is reached. + More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request + to perform. + properties: + host: + description: |- + Host name to connect to, defaults to the pod IP. You probably want to set + "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom + header to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Name or number of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: |- + Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: |- + Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept + for the backward compatibility. There are no validation of this field and + lifecycle hooks will fail in runtime when tcp handler is specified. + properties: + host: + description: 'Optional: Host name to connect + to, defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Number or name of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + description: |- + Periodic probe of container liveness. + Container will be restarted if the probe fails. + Cannot be updated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: |- + Minimum consecutive failures for the probe to be considered failed after having succeeded. + Defaults to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: |- + GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe feature gate. + properties: + port: + description: Port number of the gRPC service. Number + must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: |- + Service is the name of the service to place in the gRPC HealthCheckRequest + (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + + + If this is not specified, the default behavior is defined by gRPC. + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: |- + Host name to connect to, defaults to the pod IP. You probably want to set + "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Name or number of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: |- + Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: |- + Number of seconds after the container has started before liveness probes are initiated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + format: int32 + type: integer + periodSeconds: + description: |- + How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: |- + Minimum consecutive successes for the probe to be considered successful after having failed. + Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving + a TCP port. + properties: + host: + description: 'Optional: Host name to connect to, + defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Number or name of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: |- + Optional duration in seconds the pod needs to terminate gracefully upon probe failure. + The grace period is the duration in seconds after the processes running in the pod are sent + a termination signal and the time when the processes are forcibly halted with a kill signal. + Set this value longer than the expected cleanup time for your process. + If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this + value overrides the value provided by the pod spec. + Value must be non-negative integer. The value zero indicates stop immediately via + the kill signal (no opportunity to shut down). + This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. + Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: |- + Number of seconds after which the probe times out. + Defaults to 1 second. Minimum value is 1. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + format: int32 + type: integer + type: object + name: + description: |- + Name of the container specified as a DNS_LABEL. + Each container in a pod must have a unique name (DNS_LABEL). + Cannot be updated. + type: string + ports: + description: |- + List of ports to expose from the container. Not specifying a port here + DOES NOT prevent that port from being exposed. Any port which is + listening on the default "0.0.0.0" address inside a container will be + accessible from the network. + Modifying this array with strategic merge patch may corrupt the data. + For more information See https://github.com/kubernetes/kubernetes/issues/108255. + Cannot be updated. + items: + description: ContainerPort represents a network port in + a single container. + properties: + containerPort: + description: |- + Number of port to expose on the pod's IP address. + This must be a valid port number, 0 < x < 65536. + format: int32 + type: integer + hostIP: + description: What host IP to bind the external port + to. + type: string + hostPort: + description: |- + Number of port to expose on the host. + If specified, this must be a valid port number, 0 < x < 65536. + If HostNetwork is specified, this must match ContainerPort. + Most containers do not need this. + format: int32 + type: integer + name: + description: |- + If specified, this must be an IANA_SVC_NAME and unique within the pod. Each + named port in a pod must have a unique name. Name for the port that can be + referred to by services. + type: string + protocol: + default: TCP + description: |- + Protocol for port. Must be UDP, TCP, or SCTP. + Defaults to "TCP". + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + description: |- + Periodic probe of container service readiness. + Container will be removed from service endpoints if the probe fails. + Cannot be updated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: |- + Minimum consecutive failures for the probe to be considered failed after having succeeded. + Defaults to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: |- + GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe feature gate. + properties: + port: + description: Port number of the gRPC service. Number + must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: |- + Service is the name of the service to place in the gRPC HealthCheckRequest + (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + + + If this is not specified, the default behavior is defined by gRPC. + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: |- + Host name to connect to, defaults to the pod IP. You probably want to set + "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Name or number of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: |- + Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: |- + Number of seconds after the container has started before liveness probes are initiated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + format: int32 + type: integer + periodSeconds: + description: |- + How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: |- + Minimum consecutive successes for the probe to be considered successful after having failed. + Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving + a TCP port. + properties: + host: + description: 'Optional: Host name to connect to, + defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Number or name of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: |- + Optional duration in seconds the pod needs to terminate gracefully upon probe failure. + The grace period is the duration in seconds after the processes running in the pod are sent + a termination signal and the time when the processes are forcibly halted with a kill signal. + Set this value longer than the expected cleanup time for your process. + If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this + value overrides the value provided by the pod spec. + Value must be non-negative integer. The value zero indicates stop immediately via + the kill signal (no opportunity to shut down). + This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. + Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: |- + Number of seconds after which the probe times out. + Defaults to 1 second. Minimum value is 1. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + format: int32 + type: integer + type: object + resources: + description: |- + Compute Resources required by this container. + Cannot be updated. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + properties: + claims: + description: |- + Claims lists the names of resources, defined in spec.resourceClaims, + that are used by this container. + + + This is an alpha field and requires enabling the + DynamicResourceAllocation feature gate. + + + This field is immutable. + items: + description: ResourceClaim references one entry in + PodSpec.ResourceClaims. + properties: + name: + description: |- + Name must match the name of one entry in pod.spec.resourceClaims of + the Pod where this field is used. It makes that resource available + inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: |- + Limits describes the maximum amount of compute resources allowed. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: |- + Requests describes the minimum amount of compute resources required. + If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, + otherwise to an implementation-defined value. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + type: object + type: object + securityContext: + description: |- + SecurityContext defines the security options the container should be run with. + If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. + More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ + properties: + allowPrivilegeEscalation: + description: |- + AllowPrivilegeEscalation controls whether a process can gain more + privileges than its parent process. This bool directly controls if + the no_new_privs flag will be set on the container process. + AllowPrivilegeEscalation is true always when the container is: + 1) run as Privileged + 2) has CAP_SYS_ADMIN + Note that this field cannot be set when spec.os.name is windows. + type: boolean + capabilities: + description: |- + The capabilities to add/drop when running containers. + Defaults to the default set of capabilities granted by the container runtime. + Note that this field cannot be set when spec.os.name is windows. + properties: + add: + description: Added capabilities + items: + description: Capability represent POSIX capabilities + type + type: string + type: array + drop: + description: Removed capabilities + items: + description: Capability represent POSIX capabilities + type + type: string + type: array + type: object + privileged: + description: |- + Run container in privileged mode. + Processes in privileged containers are essentially equivalent to root on the host. + Defaults to false. + Note that this field cannot be set when spec.os.name is windows. + type: boolean + procMount: + description: |- + procMount denotes the type of proc mount to use for the containers. + The default is DefaultProcMount which uses the container runtime defaults for + readonly paths and masked paths. + This requires the ProcMountType feature flag to be enabled. + Note that this field cannot be set when spec.os.name is windows. + type: string + readOnlyRootFilesystem: + description: |- + Whether this container has a read-only root filesystem. + Default is false. + Note that this field cannot be set when spec.os.name is windows. + type: boolean + runAsGroup: + description: |- + The GID to run the entrypoint of the container process. + Uses runtime default if unset. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + runAsNonRoot: + description: |- + Indicates that the container must run as a non-root user. + If true, the Kubelet will validate the image at runtime to ensure that it + does not run as UID 0 (root) and fail to start the container if it does. + If unset or false, no such validation will be performed. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: boolean + runAsUser: + description: |- + The UID to run the entrypoint of the container process. + Defaults to user specified in image metadata if unspecified. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + seLinuxOptions: + description: |- + The SELinux context to be applied to the container. + If unspecified, the container runtime will allocate a random SELinux context for each + container. May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is windows. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: |- + The seccomp options to use by this container. If seccomp options are + provided at both the pod & container level, the container options + override the pod options. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile defined in a file on the node should be used. + The profile must be preconfigured on the node to work. + Must be a descending path, relative to the kubelet's configured seccomp profile location. + Must only be set if type is "Localhost". + type: string + type: + description: |- + type indicates which kind of seccomp profile will be applied. + Valid options are: + + + Localhost - a profile defined in a file on the node should be used. + RuntimeDefault - the container runtime default profile should be used. + Unconfined - no profile should be applied. + type: string + required: + - type + type: object + windowsOptions: + description: |- + The Windows specific settings applied to all containers. + If unspecified, the options from the PodSecurityContext will be used. + If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is linux. + properties: + gmsaCredentialSpec: + description: |- + GMSACredentialSpec is where the GMSA admission webhook + (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the + GMSA credential spec named by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name + of the GMSA credential spec to use. + type: string + hostProcess: + description: |- + HostProcess determines if a container should be run as a 'Host Process' container. + This field is alpha-level and will only be honored by components that enable the + WindowsHostProcessContainers feature flag. Setting this field without the feature + flag will result in errors when validating the Pod. All of a Pod's containers must + have the same effective HostProcess value (it is not allowed to have a mix of HostProcess + containers and non-HostProcess containers). In addition, if HostProcess is true + then HostNetwork must also be set to true. + type: boolean + runAsUserName: + description: |- + The UserName in Windows to run the entrypoint of the container process. + Defaults to the user specified in image metadata if unspecified. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: string + type: object + type: object + startupProbe: + description: |- + StartupProbe indicates that the Pod has successfully initialized. + If specified, no other probes are executed until this completes successfully. + If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. + This can be used to provide different probe parameters at the beginning of a Pod's lifecycle, + when it might take a long time to load data or warm a cache, than during steady-state operation. + This cannot be updated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: |- + Minimum consecutive failures for the probe to be considered failed after having succeeded. + Defaults to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: |- + GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe feature gate. + properties: + port: + description: Port number of the gRPC service. Number + must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: |- + Service is the name of the service to place in the gRPC HealthCheckRequest + (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + + + If this is not specified, the default behavior is defined by gRPC. + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: |- + Host name to connect to, defaults to the pod IP. You probably want to set + "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Name or number of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: |- + Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: |- + Number of seconds after the container has started before liveness probes are initiated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + format: int32 + type: integer + periodSeconds: + description: |- + How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: |- + Minimum consecutive successes for the probe to be considered successful after having failed. + Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving + a TCP port. + properties: + host: + description: 'Optional: Host name to connect to, + defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Number or name of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: |- + Optional duration in seconds the pod needs to terminate gracefully upon probe failure. + The grace period is the duration in seconds after the processes running in the pod are sent + a termination signal and the time when the processes are forcibly halted with a kill signal. + Set this value longer than the expected cleanup time for your process. + If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this + value overrides the value provided by the pod spec. + Value must be non-negative integer. The value zero indicates stop immediately via + the kill signal (no opportunity to shut down). + This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. + Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: |- + Number of seconds after which the probe times out. + Defaults to 1 second. Minimum value is 1. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + format: int32 + type: integer + type: object + stdin: + description: |- + Whether this container should allocate a buffer for stdin in the container runtime. If this + is not set, reads from stdin in the container will always result in EOF. + Default is false. + type: boolean + stdinOnce: + description: |- + Whether the container runtime should close the stdin channel after it has been opened by + a single attach. When stdin is true the stdin stream will remain open across multiple attach + sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the + first client attaches to stdin, and then remains open and accepts data until the client disconnects, + at which time stdin is closed and remains closed until the container is restarted. If this + flag is false, a container processes that reads from stdin will never receive an EOF. + Default is false + type: boolean + terminationMessagePath: + description: |- + Optional: Path at which the file to which the container's termination message + will be written is mounted into the container's filesystem. + Message written is intended to be brief final status, such as an assertion failure message. + Will be truncated by the node if greater than 4096 bytes. The total message length across + all containers will be limited to 12kb. + Defaults to /dev/termination-log. + Cannot be updated. + type: string + terminationMessagePolicy: + description: |- + Indicate how the termination message should be populated. File will use the contents of + terminationMessagePath to populate the container status message on both success and failure. + FallbackToLogsOnError will use the last chunk of container log output if the termination + message file is empty and the container exited with an error. + The log output is limited to 2048 bytes or 80 lines, whichever is smaller. + Defaults to File. + Cannot be updated. + type: string + tty: + description: |- + Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. + Default is false. + type: boolean + volumeDevices: + description: volumeDevices is the list of block devices + to be used by the container. + items: + description: volumeDevice describes a mapping of a raw + block device within a container. + properties: + devicePath: + description: devicePath is the path inside of the + container that the device will be mapped to. + type: string + name: + description: name must match the name of a persistentVolumeClaim + in the pod + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + description: |- + Pod volumes to mount into the container's filesystem. + Cannot be updated. + items: + description: VolumeMount describes a mounting of a Volume + within a container. + properties: + mountPath: + description: |- + Path within the container at which the volume should be mounted. Must + not contain ':'. + type: string + mountPropagation: + description: |- + mountPropagation determines how mounts are propagated from the host + to container and the other way around. + When not set, MountPropagationNone is used. + This field is beta in 1.10. + type: string + name: + description: This must match the Name of a Volume. + type: string + readOnly: + description: |- + Mounted read-only if true, read-write otherwise (false or unspecified). + Defaults to false. + type: boolean + subPath: + description: |- + Path within the volume from which the container's volume should be mounted. + Defaults to "" (volume's root). + type: string + subPathExpr: + description: |- + Expanded path within the volume from which the container's volume should be mounted. + Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. + Defaults to "" (volume's root). + SubPathExpr and SubPath are mutually exclusive. + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + description: |- + Container's working directory. + If not specified, the container runtime's default will be used, which + might be configured in the container image. + Cannot be updated. + type: string + required: + - name + type: object + type: array + lifecycle: + description: |- + Lifecycle describes actions that the management system should take in response to container lifecycle events. + By default, Operator will add corresponding preStop hooks for different components. For example, the preStop + script for the FE Component is /opt/starrocks/fe_prestop.sh, for the BE Component is /opt/starrocks/be_prestop.sh, + and for the CN Component is /opt/starrocks/cn_prestop.sh. + properties: + postStart: + description: |- + PostStart is called immediately after a container is created. If the handler fails, + the container is terminated and restarted according to its restart policy. + Other management of the container blocks until the hook completes. + More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: |- + Host name to connect to, defaults to the pod IP. You probably want to set + "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Name or number of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: |- + Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: |- + Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept + for the backward compatibility. There are no validation of this field and + lifecycle hooks will fail in runtime when tcp handler is specified. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Number or name of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: |- + PreStop is called immediately before a container is terminated due to an + API request or management event such as liveness/startup probe failure, + preemption, resource contention, etc. The handler is not called if the + container crashes or exits. The Pod's termination grace period countdown begins before the + PreStop hook is executed. Regardless of the outcome of the handler, the + container will eventually terminate within the Pod's termination grace + period (unless delayed by finalizers). Other management of the container blocks until the hook completes + or until the termination grace period is reached. + More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: |- + Host name to connect to, defaults to the pod IP. You probably want to set + "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Name or number of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: |- + Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: |- + Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept + for the backward compatibility. There are no validation of this field and + lifecycle hooks will fail in runtime when tcp handler is specified. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Number or name of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: |- + Limits describes the maximum amount of compute resources allowed. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + type: object + livenessProbeFailureSeconds: + description: |- + LivenessProbeFailureSeconds defines the total failure seconds of liveness Probe. + Default failureThreshold is 3 and the periodSeconds is 5, this means the liveness + will fail if the pod can't respond in 15 seconds. Your LivenessProbeFailureSeconds is + the total time of seconds before the container restart. If LivenessProbeFailureSeconds + can't be divided by defaultPeriodSeconds, the failureThreshold will be rounded up. + Note: you can set it to 0 to disable the liveness probe. + format: int32 + type: integer + minReadySeconds: + description: |- + MinReadySeconds specifies the minimum number of seconds for which a newly created pod should be ready + without any of its container crashing, for it to be considered available. + Defaults to 0 (pod will be considered available as soon as it is ready). + format: int32 + type: integer + nodeSelector: + additionalProperties: + type: string + description: (Optional) If specified, the pod's nodeSelector,displayName="Map + of nodeSelectors to match when scheduling pods on nodes" + type: object + persistentVolumeClaimRetentionPolicy: + description: |- + PersistentVolumeClaimRetentionPolicy specifies the retention policy for PersistentVolumeClaims associated with the component. + The WhenDeleted field is supported for all components, and it determines whether to delete PVCs when the StatefulSet is deleted. + The WhenScaled field is only supported for the CN component. + properties: + whenDeleted: + description: |- + WhenDeleted specifies what happens to PVCs created from StatefulSet + VolumeClaimTemplates when the StatefulSet is deleted. The default policy + of `Retain` causes PVCs to not be affected by StatefulSet deletion. The + `Delete` policy causes those PVCs to be deleted. + type: string + whenScaled: + description: |- + WhenScaled specifies what happens to PVCs created from StatefulSet + VolumeClaimTemplates when the StatefulSet is scaled down. The default + policy of `Retain` causes PVCs to not be affected by a scaledown. The + `Delete` policy causes the associated PVCs for any excess pods above + the replica count to be deleted. + type: string + type: object + podLabels: + additionalProperties: + type: string + description: the pod labels for user select or classify pods. + type: object + podManagementPolicy: + description: |- + podManagementPolicy controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down. + The default policy is Parallel which is not the same as statefulset's default policy which maybe a not a good choice + to use a different default value. + type: string + readOnlyRootFilesystem: + description: "Whether this container has a read-only root filesystem.\nDefault + is false.\nNote that:\n\t1. This field cannot be set when spec.os.name + is windows.\n\t2. The FE/BE/CN container should support read-only + root filesystem. The newest version of FE/BE/CN is 3.3.6,\n + \ and does not support read-only root filesystem" + type: boolean + readinessProbeFailureSeconds: + description: |- + ReadinessProbeFailureSeconds defines the total failure seconds of readiness Probe. + Default failureThreshold is 3 and the periodSeconds is 5, this means the readiness + will fail if the pod can't respond in 15 seconds. Your ReadinessProbeFailureSeconds is + the total time of seconds before pods becomes not ready. If ReadinessProbeFailureSeconds + can't be divided by defaultPeriodSeconds, the failureThreshold will be rounded up. + Note: you can set it to 0 to disable the readiness probe. + format: int32 + type: integer + replicas: + default: 1 + description: |- + Replicas is the number of desired Pods. + When HPA policy is enabled with a fixed replica count in StarRocksCnSpec: every time + the starrockscluster CR is applied, the replica count of the StatefulSet + object in K8S will be reset to the value specified by the 'Replicas' + field, erasing the value previously set by HPA. + format: int32 + minimum: 0 + type: integer + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: |- + Requests describes the minimum amount of compute resources required. + If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, + otherwise to an implementation-defined value. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + type: object + runAsNonRoot: + description: |- + RunAsNonRoot is used to determine whether to run starrocks as a normal user. + If RunAsNonRoot is true, operator will set RunAsUser and RunAsGroup to 1000 in securityContext. + default: nil + type: boolean + schedulerName: + description: SchedulerName is the name of the kubernetes scheduler + that will be used to schedule the pods. + type: string + secrets: + description: the reference for secrets. + items: + description: |- + MountInfo + The reason why we do not support defaultMode is that we use hash.HashObject to + calculate the actual volume name. This volume name is used in pod template of statefulset, + and if this MountInfo type has been changed, the volume name will be changed too, and + that will make pods restart. + The default mode is 0644, and in order to support to set permission information for a configMap + or secret, we add should specify the subPath and specify a command or args in the container. + And It will be set 0755. + properties: + mountPath: + description: |- + Path within the container at which the volume should be mounted. Must + not contain ':'. + type: string + name: + description: |- + This must match the Name of a ConfigMap or Secret in the same namespace, and + the length of name must not more than 50 characters. + type: string + subPath: + description: |- + SubPath within the volume from which the container's volume should be mounted. + Defaults to "" (volume's root). + type: string + type: object + type: array + service: + description: Service defines the template for the associated Kubernetes + Service object. + properties: + annotations: + additionalProperties: + type: string + description: |- + Annotations' store Kubernetes Service annotations. These will be added to the external service + only (not internal). + type: object + labels: + additionalProperties: + type: string + description: |- + Labels store Kubernetes Service labels. These will be added to the external service only (not + internal). StarRocks may add its own default labels. + type: object + loadBalancerIP: + description: |- + Only applies to Service Type: LoadBalancer. + This feature depends on whether the underlying cloud-provider supports specifying + the loadBalancerIP when a load balancer is created. + This field will be ignored if the cloud-provider does not support the feature. + This field was under-specified and its meaning varies across implementations, + and it cannot support dual-stack. + As of Kubernetes v1.24, users are encouraged to use implementation-specific annotations when available. + This field may be removed in a future API version. + type: string + loadBalancerSourceRanges: + description: |- + If specified and supported by the platform, this will restrict traffic through the cloud-provider + load-balancer will be restricted to the specified client IPs. This field will be ignored if the + cloud-provider does not support the feature. + More info: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/ + items: + type: string + type: array + ports: + description: |- + Ports are the ports that are exposed by this service. + You can override the default port information by specifying the same StarRocksServicePort.Name in the ports list. + e.g. if you want to use a dedicated node port, you can just specify the StarRocksServicePort.Name and + StarRocksServicePort.NodePort field. + items: + description: |- + StarRocksServicePort defines the port that will be exposed by this service. + To assign a specific port or nodePort to a service, you should specify them by the corresponding name or + containerPort in the service configuration. If both containerPort and name are specified, containerPort takes precedence. + properties: + containerPort: + description: |- + ContainerPort of the service port. + For fe, port name can be http, query, rpc, edit-log, and their default container port is 8030, 9030, 9020, 9010. + For be, port name can be webserver, heartbeat, brpc, be, and their default container port is 8040, 9050, 8060, 9060. + For cn, port name can be webserver, heartbeat, brpc, thrift, and their default container port is 8040, 9050, 8060, 9060. + For fe proxy, port name can be http-port, and its default container port is 8080. + format: int32 + type: integer + name: + description: |- + Name of this port within the service. + For fe, port name can be http, query, rpc, edit-log, and their default container port is 8030, 9030, 9020, 9010. + For be, port name can be webserver, heartbeat, brpc, be, and their default container port is 8040, 9050, 8060, 9060. + For cn, port name can be webserver, heartbeat, brpc, thrift, and their default container port is 8040, 9050, 8060, 9060. + For fe proxy, port name can be http-port, and its default container port is 8080. + type: string + nodePort: + description: |- + NodePort is used to specify the port on each node on which the service is exposed. + The range of valid ports is 30000-32767 + format: int32 + type: integer + port: + description: Port that will be exposed by this service. + format: int32 + type: integer + type: object + type: array + type: + description: |- + type of service,the possible value for the service type are : ClusterIP, NodePort, LoadBalancer,ExternalName. + More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: string + type: object + serviceAccount: + description: serviceAccount for access cloud service. + type: string + shareProcessNamespace: + description: |- + Share a single process namespace between all of the containers in a pod. + When this is set containers will be able to view and signal processes from other containers + in the same pod, and the first process in each container will not be assigned PID 1. + Optional: Default to false. + type: boolean + sidecars: + description: |- + Sidecars is an optional list of containers that are run in the same pod as the starrocks component. + You can use this field to launch helper containers that provide additional functionality to the main container. + See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to configure a container. + items: + description: A single application container that you want to + run within a pod. + properties: + args: + description: |- + Arguments to the entrypoint. + The container image's CMD is used if this is not provided. + Variable references $(VAR_NAME) are expanded using the container's environment. If a variable + cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced + to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will + produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless + of whether the variable exists or not. Cannot be updated. + More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell + items: + type: string + type: array + command: + description: |- + Entrypoint array. Not executed within a shell. + The container image's ENTRYPOINT is used if this is not provided. + Variable references $(VAR_NAME) are expanded using the container's environment. If a variable + cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced + to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will + produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless + of whether the variable exists or not. Cannot be updated. + More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell + items: + type: string + type: array + env: + description: |- + List of environment variables to set in the container. + Cannot be updated. + items: + description: EnvVar represents an environment variable + present in a Container. + properties: + name: + description: Name of the environment variable. Must + be a C_IDENTIFIER. + type: string + value: + description: |- + Variable references $(VAR_NAME) are expanded + using the previously defined environment variables in the container and + any service environment variables. If a variable cannot be resolved, + the reference in the input string will be unchanged. Double $$ are reduced + to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. + "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". + Escaped references will never be expanded, regardless of whether the variable + exists or not. + Defaults to "". + type: string + valueFrom: + description: Source for the environment variable's + value. Cannot be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + optional: + description: Specify whether the ConfigMap + or its key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + description: |- + Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, + spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. + properties: + apiVersion: + description: Version of the schema the FieldPath + is written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in + the specified API version. + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + description: |- + Selects a resource of the container: only resources limits and requests + (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. + properties: + containerName: + description: 'Container name: required for + volumes, optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of + the exposed resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + description: Selects a key of a secret in the + pod's namespace + properties: + key: + description: The key of the secret to select + from. Must be a valid secret key. + type: string + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + optional: + description: Specify whether the Secret or + its key must be defined + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + description: |- + List of sources to populate environment variables in the container. + The keys defined within a source must be a C_IDENTIFIER. All invalid keys + will be reported as an event when the container is starting. When a key exists in multiple + sources, the value associated with the last source will take precedence. + Values defined by an Env with a duplicate key will take precedence. + Cannot be updated. + items: + description: EnvFromSource represents the source of a + set of ConfigMaps + properties: + configMapRef: + description: The ConfigMap to select from + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + optional: + description: Specify whether the ConfigMap must + be defined + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + description: An optional identifier to prepend to + each key in the ConfigMap. Must be a C_IDENTIFIER. + type: string + secretRef: + description: The Secret to select from + properties: + name: + description: |- + Name of the referent. + More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? + type: string + optional: + description: Specify whether the Secret must be + defined + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + description: |- + Container image name. + More info: https://kubernetes.io/docs/concepts/containers/images + This field is optional to allow higher level config management to default or override + container images in workload controllers like Deployments and StatefulSets. + type: string + imagePullPolicy: + description: |- + 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 + type: string + lifecycle: + description: |- + Actions that the management system should take in response to container lifecycle events. + Cannot be updated. + properties: + postStart: + description: |- + PostStart is called immediately after a container is created. If the handler fails, + the container is terminated and restarted according to its restart policy. + Other management of the container blocks until the hook completes. + More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request + to perform. + properties: + host: + description: |- + Host name to connect to, defaults to the pod IP. You probably want to set + "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom + header to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Name or number of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: |- + Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: |- + Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept + for the backward compatibility. There are no validation of this field and + lifecycle hooks will fail in runtime when tcp handler is specified. + properties: + host: + description: 'Optional: Host name to connect + to, defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Number or name of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + description: |- + PreStop is called immediately before a container is terminated due to an + API request or management event such as liveness/startup probe failure, + preemption, resource contention, etc. The handler is not called if the + container crashes or exits. The Pod's termination grace period countdown begins before the + PreStop hook is executed. Regardless of the outcome of the handler, the + container will eventually terminate within the Pod's termination grace + period (unless delayed by finalizers). Other management of the container blocks until the hook completes + or until the termination grace period is reached. + More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + httpGet: + description: HTTPGet specifies the http request + to perform. + properties: + host: + description: |- + Host name to connect to, defaults to the pod IP. You probably want to set + "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom + header to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Name or number of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: |- + Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + tcpSocket: + description: |- + Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept + for the backward compatibility. There are no validation of this field and + lifecycle hooks will fail in runtime when tcp handler is specified. + properties: + host: + description: 'Optional: Host name to connect + to, defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Number or name of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + description: |- + Periodic probe of container liveness. + Container will be restarted if the probe fails. + Cannot be updated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: |- + Minimum consecutive failures for the probe to be considered failed after having succeeded. + Defaults to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: |- + GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe feature gate. + properties: + port: + description: Port number of the gRPC service. Number + must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: |- + Service is the name of the service to place in the gRPC HealthCheckRequest + (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + + + If this is not specified, the default behavior is defined by gRPC. + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: |- + Host name to connect to, defaults to the pod IP. You probably want to set + "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Name or number of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: |- + Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: |- + Number of seconds after the container has started before liveness probes are initiated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + format: int32 + type: integer + periodSeconds: + description: |- + How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: |- + Minimum consecutive successes for the probe to be considered successful after having failed. + Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving + a TCP port. + properties: + host: + description: 'Optional: Host name to connect to, + defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Number or name of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: |- + Optional duration in seconds the pod needs to terminate gracefully upon probe failure. + The grace period is the duration in seconds after the processes running in the pod are sent + a termination signal and the time when the processes are forcibly halted with a kill signal. + Set this value longer than the expected cleanup time for your process. + If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this + value overrides the value provided by the pod spec. + Value must be non-negative integer. The value zero indicates stop immediately via + the kill signal (no opportunity to shut down). + This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. + Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: |- + Number of seconds after which the probe times out. + Defaults to 1 second. Minimum value is 1. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + format: int32 + type: integer + type: object + name: + description: |- + Name of the container specified as a DNS_LABEL. + Each container in a pod must have a unique name (DNS_LABEL). + Cannot be updated. + type: string + ports: + description: |- + List of ports to expose from the container. Not specifying a port here + DOES NOT prevent that port from being exposed. Any port which is + listening on the default "0.0.0.0" address inside a container will be + accessible from the network. + Modifying this array with strategic merge patch may corrupt the data. + For more information See https://github.com/kubernetes/kubernetes/issues/108255. + Cannot be updated. + items: + description: ContainerPort represents a network port in + a single container. + properties: + containerPort: + description: |- + Number of port to expose on the pod's IP address. + This must be a valid port number, 0 < x < 65536. + format: int32 + type: integer + hostIP: + description: What host IP to bind the external port + to. + type: string + hostPort: + description: |- + Number of port to expose on the host. + If specified, this must be a valid port number, 0 < x < 65536. + If HostNetwork is specified, this must match ContainerPort. + Most containers do not need this. + format: int32 + type: integer + name: + description: |- + If specified, this must be an IANA_SVC_NAME and unique within the pod. Each + named port in a pod must have a unique name. Name for the port that can be + referred to by services. + type: string + protocol: + default: TCP + description: |- + Protocol for port. Must be UDP, TCP, or SCTP. + Defaults to "TCP". + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + description: |- + Periodic probe of container service readiness. + Container will be removed from service endpoints if the probe fails. + Cannot be updated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: |- + Minimum consecutive failures for the probe to be considered failed after having succeeded. + Defaults to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: |- + GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe feature gate. + properties: + port: + description: Port number of the gRPC service. Number + must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: |- + Service is the name of the service to place in the gRPC HealthCheckRequest + (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + + + If this is not specified, the default behavior is defined by gRPC. + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: |- + Host name to connect to, defaults to the pod IP. You probably want to set + "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Name or number of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: |- + Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: |- + Number of seconds after the container has started before liveness probes are initiated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + format: int32 + type: integer + periodSeconds: + description: |- + How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: |- + Minimum consecutive successes for the probe to be considered successful after having failed. + Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving + a TCP port. + properties: + host: + description: 'Optional: Host name to connect to, + defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Number or name of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: |- + Optional duration in seconds the pod needs to terminate gracefully upon probe failure. + The grace period is the duration in seconds after the processes running in the pod are sent + a termination signal and the time when the processes are forcibly halted with a kill signal. + Set this value longer than the expected cleanup time for your process. + If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this + value overrides the value provided by the pod spec. + Value must be non-negative integer. The value zero indicates stop immediately via + the kill signal (no opportunity to shut down). + This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. + Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: |- + Number of seconds after which the probe times out. + Defaults to 1 second. Minimum value is 1. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + format: int32 + type: integer + type: object + resources: + description: |- + Compute Resources required by this container. + Cannot be updated. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + properties: + claims: + description: |- + Claims lists the names of resources, defined in spec.resourceClaims, + that are used by this container. + + + This is an alpha field and requires enabling the + DynamicResourceAllocation feature gate. + + + This field is immutable. + items: + description: ResourceClaim references one entry in + PodSpec.ResourceClaims. + properties: + name: + description: |- + Name must match the name of one entry in pod.spec.resourceClaims of + the Pod where this field is used. It makes that resource available + inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: |- + Limits describes the maximum amount of compute resources allowed. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: |- + Requests describes the minimum amount of compute resources required. + If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, + otherwise to an implementation-defined value. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + type: object + type: object + securityContext: + description: |- + SecurityContext defines the security options the container should be run with. + If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. + More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ + properties: + allowPrivilegeEscalation: + description: |- + AllowPrivilegeEscalation controls whether a process can gain more + privileges than its parent process. This bool directly controls if + the no_new_privs flag will be set on the container process. + AllowPrivilegeEscalation is true always when the container is: + 1) run as Privileged + 2) has CAP_SYS_ADMIN + Note that this field cannot be set when spec.os.name is windows. + type: boolean + capabilities: + description: |- + The capabilities to add/drop when running containers. + Defaults to the default set of capabilities granted by the container runtime. + Note that this field cannot be set when spec.os.name is windows. + properties: + add: + description: Added capabilities + items: + description: Capability represent POSIX capabilities + type + type: string + type: array + drop: + description: Removed capabilities + items: + description: Capability represent POSIX capabilities + type + type: string + type: array + type: object + privileged: + description: |- + Run container in privileged mode. + Processes in privileged containers are essentially equivalent to root on the host. + Defaults to false. + Note that this field cannot be set when spec.os.name is windows. + type: boolean + procMount: + description: |- + procMount denotes the type of proc mount to use for the containers. + The default is DefaultProcMount which uses the container runtime defaults for + readonly paths and masked paths. + This requires the ProcMountType feature flag to be enabled. + Note that this field cannot be set when spec.os.name is windows. + type: string + readOnlyRootFilesystem: + description: |- + Whether this container has a read-only root filesystem. + Default is false. + Note that this field cannot be set when spec.os.name is windows. + type: boolean + runAsGroup: + description: |- + The GID to run the entrypoint of the container process. + Uses runtime default if unset. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + runAsNonRoot: + description: |- + Indicates that the container must run as a non-root user. + If true, the Kubelet will validate the image at runtime to ensure that it + does not run as UID 0 (root) and fail to start the container if it does. + If unset or false, no such validation will be performed. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: boolean + runAsUser: + description: |- + The UID to run the entrypoint of the container process. + Defaults to user specified in image metadata if unspecified. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is windows. + format: int64 + type: integer + seLinuxOptions: + description: |- + The SELinux context to be applied to the container. + If unspecified, the container runtime will allocate a random SELinux context for each + container. May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is windows. + properties: + level: + description: Level is SELinux level label that applies + to the container. + type: string + role: + description: Role is a SELinux role label that applies + to the container. + type: string + type: + description: Type is a SELinux type label that applies + to the container. + type: string + user: + description: User is a SELinux user label that applies + to the container. + type: string + type: object + seccompProfile: + description: |- + The seccomp options to use by this container. If seccomp options are + provided at both the pod & container level, the container options + override the pod options. + Note that this field cannot be set when spec.os.name is windows. + properties: + localhostProfile: + description: |- + localhostProfile indicates a profile defined in a file on the node should be used. + The profile must be preconfigured on the node to work. + Must be a descending path, relative to the kubelet's configured seccomp profile location. + Must only be set if type is "Localhost". + type: string + type: + description: |- + type indicates which kind of seccomp profile will be applied. + Valid options are: + + + Localhost - a profile defined in a file on the node should be used. + RuntimeDefault - the container runtime default profile should be used. + Unconfined - no profile should be applied. + type: string + required: + - type + type: object + windowsOptions: + description: |- + The Windows specific settings applied to all containers. + If unspecified, the options from the PodSecurityContext will be used. + If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. + Note that this field cannot be set when spec.os.name is linux. + properties: + gmsaCredentialSpec: + description: |- + GMSACredentialSpec is where the GMSA admission webhook + (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the + GMSA credential spec named by the GMSACredentialSpecName field. + type: string + gmsaCredentialSpecName: + description: GMSACredentialSpecName is the name + of the GMSA credential spec to use. + type: string + hostProcess: + description: |- + HostProcess determines if a container should be run as a 'Host Process' container. + This field is alpha-level and will only be honored by components that enable the + WindowsHostProcessContainers feature flag. Setting this field without the feature + flag will result in errors when validating the Pod. All of a Pod's containers must + have the same effective HostProcess value (it is not allowed to have a mix of HostProcess + containers and non-HostProcess containers). In addition, if HostProcess is true + then HostNetwork must also be set to true. + type: boolean + runAsUserName: + description: |- + The UserName in Windows to run the entrypoint of the container process. + Defaults to the user specified in image metadata if unspecified. + May also be set in PodSecurityContext. If set in both SecurityContext and + PodSecurityContext, the value specified in SecurityContext takes precedence. + type: string + type: object + type: object + startupProbe: + description: |- + StartupProbe indicates that the Pod has successfully initialized. + If specified, no other probes are executed until this completes successfully. + If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. + This can be used to provide different probe parameters at the beginning of a Pod's lifecycle, + when it might take a long time to load data or warm a cache, than during steady-state operation. + This cannot be updated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: |- + Command is the command line to execute inside the container, the working directory for the + command is root ('/') in the container's filesystem. The command is simply exec'd, it is + not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use + a shell, you need to explicitly call out to that shell. + Exit status of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: |- + Minimum consecutive failures for the probe to be considered failed after having succeeded. + Defaults to 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: |- + GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe feature gate. + properties: + port: + description: Port number of the gRPC service. Number + must be in the range 1 to 65535. + format: int32 + type: integer + service: + description: |- + Service is the name of the service to place in the gRPC HealthCheckRequest + (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + + + If this is not specified, the default behavior is defined by gRPC. + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: |- + Host name to connect to, defaults to the pod IP. You probably want to set + "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. + HTTP allows repeated headers. + items: + description: HTTPHeader describes a custom header + to be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Name or number of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: |- + Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: |- + Number of seconds after the container has started before liveness probes are initiated. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + format: int32 + type: integer + periodSeconds: + description: |- + How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: |- + Minimum consecutive successes for the probe to be considered successful after having failed. + Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving + a TCP port. + properties: + host: + description: 'Optional: Host name to connect to, + defaults to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: |- + Number or name of the port to access on the container. + Number must be in the range 1 to 65535. + Name must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: |- + Optional duration in seconds the pod needs to terminate gracefully upon probe failure. + The grace period is the duration in seconds after the processes running in the pod are sent + a termination signal and the time when the processes are forcibly halted with a kill signal. + Set this value longer than the expected cleanup time for your process. + If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this + value overrides the value provided by the pod spec. + Value must be non-negative integer. The value zero indicates stop immediately via + the kill signal (no opportunity to shut down). + This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. + Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: |- + Number of seconds after which the probe times out. + Defaults to 1 second. Minimum value is 1. + More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + format: int32 + type: integer + type: object + stdin: + description: |- + Whether this container should allocate a buffer for stdin in the container runtime. If this + is not set, reads from stdin in the container will always result in EOF. + Default is false. + type: boolean + stdinOnce: + description: |- + Whether the container runtime should close the stdin channel after it has been opened by + a single attach. When stdin is true the stdin stream will remain open across multiple attach + sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the + first client attaches to stdin, and then remains open and accepts data until the client disconnects, + at which time stdin is closed and remains closed until the container is restarted. If this + flag is false, a container processes that reads from stdin will never receive an EOF. + Default is false + type: boolean + terminationMessagePath: + description: |- + Optional: Path at which the file to which the container's termination message + will be written is mounted into the container's filesystem. + Message written is intended to be brief final status, such as an assertion failure message. + Will be truncated by the node if greater than 4096 bytes. The total message length across + all containers will be limited to 12kb. + Defaults to /dev/termination-log. + Cannot be updated. + type: string + terminationMessagePolicy: + description: |- + Indicate how the termination message should be populated. File will use the contents of + terminationMessagePath to populate the container status message on both success and failure. + FallbackToLogsOnError will use the last chunk of container log output if the termination + message file is empty and the container exited with an error. + The log output is limited to 2048 bytes or 80 lines, whichever is smaller. + Defaults to File. + Cannot be updated. + type: string + tty: + description: |- + Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. + Default is false. + type: boolean + volumeDevices: + description: volumeDevices is the list of block devices + to be used by the container. + items: + description: volumeDevice describes a mapping of a raw + block device within a container. + properties: + devicePath: + description: devicePath is the path inside of the + container that the device will be mapped to. + type: string + name: + description: name must match the name of a persistentVolumeClaim + in the pod + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + description: |- + Pod volumes to mount into the container's filesystem. + Cannot be updated. + items: + description: VolumeMount describes a mounting of a Volume + within a container. + properties: + mountPath: + description: |- + Path within the container at which the volume should be mounted. Must + not contain ':'. + type: string + mountPropagation: + description: |- + mountPropagation determines how mounts are propagated from the host + to container and the other way around. + When not set, MountPropagationNone is used. + This field is beta in 1.10. + type: string + name: + description: This must match the Name of a Volume. + type: string + readOnly: + description: |- + Mounted read-only if true, read-write otherwise (false or unspecified). + Defaults to false. + type: boolean + subPath: + description: |- + Path within the volume from which the container's volume should be mounted. + Defaults to "" (volume's root). + type: string + subPathExpr: + description: |- + Expanded path within the volume from which the container's volume should be mounted. + Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. + Defaults to "" (volume's root). + SubPathExpr and SubPath are mutually exclusive. + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + description: |- + Container's working directory. + If not specified, the container runtime's default will be used, which + might be configured in the container image. + Cannot be updated. + type: string + required: + - name + type: object + type: array + startupProbeFailureSeconds: + description: |- + StartupProbeFailureSeconds defines the total failure seconds of startup Probe. + Default failureThreshold is 60 and the periodSeconds is 5, this means the startup + will fail if the pod can't start in 300 seconds. Your StartupProbeFailureSeconds is + the total time of seconds before startupProbe give up and fail the container start. + If startupProbeFailureSeconds can't be divided by defaultPeriodSeconds, the failureThreshold + will be rounded up. + Note: you can set it to 0 to disable the startup probe. + format: int32 + type: integer + storageVolumes: + description: "StorageVolumes defines the additional storage for + FE meta or BE/CN storage.\n\n\nFor FE component\n\tIf the storage + volume name is fe-meta or the volume mount path is /opt/starrocks/fe/meta,\n\tthen + it will be recognized as storing the FE meta.\n\tIf the storage + volume name is fe-log or the volume mount path is /opt/starrocks/fe/log,\n\tthen + it will be recognized as storing the FE log.\n\n\nFor BE component\n\tIf + the storage volume name is be-storage(or be-data) or the volume + mount path is /opt/starrocks/be/storage,\n\tthen it will be + recognized as storing the BE data.\n\tIf the storage volume + name is be-log or the volume mount path is /opt/starrocks/be/log,\n\tthen + it will be recognized as storing the BE log.\n\n\nFor CN component\n\tIf + the storage volume name is cn-log or the volume mount path is + /opt/starrocks/cn/log,\n\tthen it will be recognized as storing + the cn log.\n\n\nIf operator can't find the above storage volume + names or the volume mount paths, it will create\ndefault storage + volumes by using emptyDir." + items: + description: StorageVolume defines additional PVC template for + StatefulSets and volumeMount for pods that mount this PVC. + properties: + hostPath: + description: |- + HostPath Represents a host path mapped into a pod. + If StorageClassName is hostPath, HostPath is required. + properties: + path: + description: |- + path of the directory on the host. + If the path is a symlink, it will follow the link to the real path. + More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath + type: string + type: + description: |- + type for HostPath Volume + Defaults to "" + More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath + type: string + required: + - path + type: object + mountPath: + description: MountPath specify the path of volume mount. + type: string + name: + description: name of a storage volume. + pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*' + type: string + storageClassName: + description: |- + storageClassName is the name of the StorageClass required by the claim. + If storageClassName is not set, the default StorageClass of kubernetes will be used. + there are some special storageClassName: emptyDir, hostPath. In this case, It will use emptyDir or hostPath, not PVC. + More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1 + type: string + storageSize: + description: |- + StorageSize is a valid memory size type based on powers-of-2, so 1Mi is 1024Ki. + Supported units:Mi, Gi, GiB, Ti, Ti, Pi, Ei, Ex: `512Mi`. + It will take effect only when storageClassName is real storage class, not emptyDir or hostPath. + pattern: (^0|([0-9]*l[.])?[0-9]+((M|G|T|E|P)i))$ + type: string + subPath: + description: |- + SubPath within the volume from which the container's volume should be mounted. + Defaults to "" (volume's root). + type: string + required: + - mountPath + - name + type: object + type: array + sysctls: + description: |- + Sysctls defines a list of namespaced sysctls for the podSecurityContext.sysctls + See https://kubernetes.io/docs/tasks/administer-cluster/sysctl-cluster/ for more details. + items: + description: Sysctl defines a kernel parameter to be set + properties: + name: + description: Name of a property to set + type: string + value: + description: Value of a property to set + type: string + required: + - name + - value + type: object + type: array + terminationGracePeriodSeconds: + description: |- + TerminationGracePeriodSeconds defines duration in seconds the pod needs to terminate gracefully. May be decreased in delete request. + Value must be non-negative integer. The value zero indicates stop immediately via + the kill signal (no opportunity to shut down). + If this value is nil, the default grace period will be used instead. + The grace period is the duration in seconds after the processes running in the pod are sent + a termination signal and the time when the processes are forcibly halted with a kill signal. + Set this value longer than the expected cleanup time for your process. + Defaults to 120 seconds. + format: int64 + type: integer + tolerations: + description: (Optional) Tolerations for scheduling pods onto some + dedicated nodes + items: + description: |- + The pod this Toleration is attached to tolerates any taint that matches + the triple using the matching operator . + properties: + effect: + description: |- + Effect indicates the taint effect to match. Empty means match all taint effects. + When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute. + type: string + key: + description: |- + Key is the taint key that the toleration applies to. Empty means match all taint keys. + If the key is empty, operator must be Exists; this combination means to match all values and all keys. + type: string + operator: + description: |- + Operator represents a key's relationship to the value. + Valid operators are Exists and Equal. Defaults to Equal. + Exists is equivalent to wildcard for value, so that a pod can + tolerate all taints of a particular category. + type: string + tolerationSeconds: + description: |- + TolerationSeconds represents the period of time the toleration (which must be + of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, + it is not set, which means tolerate the taint forever (do not evict). Zero and + negative values will be treated as 0 (evict immediately) by the system. + format: int64 + type: integer + value: + description: |- + Value is the taint value the toleration matches to. + If the operator is Exists, the value should be empty, otherwise just a regular string. + type: string + type: object + type: array + topologySpreadConstraints: + description: |- + (Optional) TopologySpreadConstraints for spreading pods across failure-domains + More info: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ + items: + description: TopologySpreadConstraint specifies how to spread + matching pods among the given topology. + properties: + labelSelector: + description: |- + LabelSelector is used to find matching pods. + Pods that match this label selector are counted to determine the number of pods + in their corresponding topology domain. + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: |- + A label selector requirement is a selector that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: |- + operator represents a key's relationship to a set of values. + Valid operators are In, NotIn, Exists and DoesNotExist. + type: string + values: + description: |- + values is an array of string values. If the operator is In or NotIn, + the values array must be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: |- + matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, whose key field is "key", the + operator is "In", and the values array contains only "value". The requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + matchLabelKeys: + description: |- + MatchLabelKeys is a set of pod label keys to select the pods over which + spreading will be calculated. The keys are used to lookup values from the + incoming pod labels, those key-value labels are ANDed with labelSelector + to select the group of existing pods over which spreading will be calculated + for the incoming pod. Keys that don't exist in the incoming pod labels will + be ignored. A null or empty list means only match against labelSelector. + items: + type: string + type: array + x-kubernetes-list-type: atomic + maxSkew: + description: |- + MaxSkew describes the degree to which pods may be unevenly distributed. + When `whenUnsatisfiable=DoNotSchedule`, it is the maximum permitted difference + between the number of matching pods in the target topology and the global minimum. + The global minimum is the minimum number of matching pods in an eligible domain + or zero if the number of eligible domains is less than MinDomains. + For example, in a 3-zone cluster, MaxSkew is set to 1, and pods with the same + labelSelector spread as 2/2/1: + In this case, the global minimum is 1. + | zone1 | zone2 | zone3 | + | P P | P P | P | + - if MaxSkew is 1, incoming pod can only be scheduled to zone3 to become 2/2/2; + scheduling it onto zone1(zone2) would make the ActualSkew(3-1) on zone1(zone2) + violate MaxSkew(1). + - if MaxSkew is 2, incoming pod can be scheduled onto any zone. + When `whenUnsatisfiable=ScheduleAnyway`, it is used to give higher precedence + to topologies that satisfy it. + It's a required field. Default value is 1 and 0 is not allowed. + format: int32 + type: integer + minDomains: + description: |- + MinDomains indicates a minimum number of eligible domains. + When the number of eligible domains with matching topology keys is less than minDomains, + Pod Topology Spread treats "global minimum" as 0, and then the calculation of Skew is performed. + And when the number of eligible domains with matching topology keys equals or greater than minDomains, + this value has no effect on scheduling. + As a result, when the number of eligible domains is less than minDomains, + scheduler won't schedule more than maxSkew Pods to those domains. + If value is nil, the constraint behaves as if MinDomains is equal to 1. + Valid values are integers greater than 0. + When value is not nil, WhenUnsatisfiable must be DoNotSchedule. + + + For example, in a 3-zone cluster, MaxSkew is set to 2, MinDomains is set to 5 and pods with the same + labelSelector spread as 2/2/2: + | zone1 | zone2 | zone3 | + | P P | P P | P P | + The number of domains is less than 5(MinDomains), so "global minimum" is treated as 0. + In this situation, new pod with the same labelSelector cannot be scheduled, + because computed skew will be 3(3 - 0) if new Pod is scheduled to any of the three zones, + it will violate MaxSkew. + + + This is a beta field and requires the MinDomainsInPodTopologySpread feature gate to be enabled (enabled by default). + format: int32 + type: integer + nodeAffinityPolicy: + description: |- + NodeAffinityPolicy indicates how we will treat Pod's nodeAffinity/nodeSelector + when calculating pod topology spread skew. Options are: + - Honor: only nodes matching nodeAffinity/nodeSelector are included in the calculations. + - Ignore: nodeAffinity/nodeSelector are ignored. All nodes are included in the calculations. + + + If this value is nil, the behavior is equivalent to the Honor policy. + This is a beta-level feature default enabled by the NodeInclusionPolicyInPodTopologySpread feature flag. + type: string + nodeTaintsPolicy: + description: |- + NodeTaintsPolicy indicates how we will treat node taints when calculating + pod topology spread skew. Options are: + - Honor: nodes without taints, along with tainted nodes for which the incoming pod + has a toleration, are included. + - Ignore: node taints are ignored. All nodes are included. + + If this value is nil, the behavior is equivalent to the Ignore policy. This is a beta-level feature default enabled by the NodeInclusionPolicyInPodTopologySpread feature flag. type: string @@ -15600,6 +20018,44 @@ spec: required: - phase type: object + starRocksFeObserverStatus: + description: Represents the status of fe observer. the status have + running, failed and creating pods. + properties: + creatingInstances: + description: CreatingInstances in creating pod names. + items: + type: string + type: array + failedInstances: + description: FailedInstances failed pod names. + items: + type: string + type: array + phase: + description: |- + Phase the value from all pods of component status. If component have one failed pod phase=failed, + also if fe have one creating pod phase=creating, also if component all running phase=running, others unknown. + type: string + reason: + description: Reason represents the reason of not running. + type: string + resourceNames: + description: ResourceNames the statefulset names of fe. + items: + type: string + type: array + runningInstances: + description: RunningInstances in running status pod names. + items: + type: string + type: array + serviceName: + description: the name of fe service exposed for user. + type: string + required: + - phase + type: object starRocksFeProxyStatus: description: Represents the status of fe proxy. the status have running, failed and creating pods. diff --git a/deploy/starrocks.com_starrocksclusters.yaml b/deploy/starrocks.com_starrocksclusters.yaml index 196cac8c2..16b4625d9 100644 --- a/deploy/starrocks.com_starrocksclusters.yaml +++ b/deploy/starrocks.com_starrocksclusters.yaml @@ -4496,6 +4496,2061 @@ spec: type: string type: object type: object + starRocksFeObserverSpec: + properties: + affinity: + properties: + nodeAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + preference: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + type: object + x-kubernetes-map-type: atomic + weight: + format: int32 + type: integer + required: + - preference + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + properties: + nodeSelectorTerms: + items: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + type: object + x-kubernetes-map-type: atomic + type: array + required: + - nodeSelectorTerms + type: object + x-kubernetes-map-type: atomic + type: object + podAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + namespaces: + items: + type: string + type: array + topologyKey: + type: string + required: + - topologyKey + type: object + weight: + format: int32 + type: integer + required: + - podAffinityTerm + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + namespaces: + items: + type: string + type: array + topologyKey: + type: string + required: + - topologyKey + type: object + type: array + type: object + podAntiAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + podAffinityTerm: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + namespaces: + items: + type: string + type: array + topologyKey: + type: string + required: + - topologyKey + type: object + weight: + format: int32 + type: integer + required: + - podAffinityTerm + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + namespaceSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + namespaces: + items: + type: string + type: array + topologyKey: + type: string + required: + - topologyKey + type: object + type: array + type: object + type: object + annotations: + additionalProperties: + type: string + type: object + args: + items: + type: string + type: array + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + command: + items: + type: string + type: array + configMapInfo: + properties: + configMapName: + type: string + resolveKey: + type: string + type: object + configMaps: + items: + properties: + mountPath: + type: string + name: + type: string + subPath: + type: string + type: object + type: array + feEnvVars: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + properties: + containerName: + type: string + divisor: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + hostAliases: + items: + properties: + hostnames: + items: + type: string + type: array + ip: + type: string + type: object + type: array + image: + type: string + imagePullPolicy: + type: string + imagePullSecrets: + items: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + type: array + initContainers: + items: + properties: + args: + items: + type: string + type: array + command: + items: + type: string + type: array + env: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + properties: + containerName: + type: string + divisor: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + items: + properties: + configMapRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + type: string + secretRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + type: string + imagePullPolicy: + type: string + lifecycle: + properties: + postStart: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + name: + type: string + ports: + items: + properties: + containerPort: + format: int32 + type: integer + hostIP: + type: string + hostPort: + format: int32 + type: integer + name: + type: string + protocol: + default: TCP + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + securityContext: + properties: + allowPrivilegeEscalation: + type: boolean + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: + type: string + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + required: + - type + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + type: object + type: object + startupProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + stdin: + type: boolean + stdinOnce: + type: boolean + terminationMessagePath: + type: string + terminationMessagePolicy: + type: string + tty: + type: boolean + volumeDevices: + items: + properties: + devicePath: + type: string + name: + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + items: + properties: + mountPath: + type: string + mountPropagation: + type: string + name: + type: string + readOnly: + type: boolean + subPath: + type: string + subPathExpr: + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + type: string + required: + - name + type: object + type: array + lifecycle: + properties: + postStart: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + livenessProbeFailureSeconds: + format: int32 + type: integer + minReadySeconds: + format: int32 + type: integer + nodeSelector: + additionalProperties: + type: string + type: object + persistentVolumeClaimRetentionPolicy: + properties: + whenDeleted: + type: string + whenScaled: + type: string + type: object + podLabels: + additionalProperties: + type: string + type: object + podManagementPolicy: + type: string + readOnlyRootFilesystem: + type: boolean + readinessProbeFailureSeconds: + format: int32 + type: integer + replicas: + default: 1 + format: int32 + minimum: 0 + type: integer + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + runAsNonRoot: + type: boolean + schedulerName: + type: string + secrets: + items: + properties: + mountPath: + type: string + name: + type: string + subPath: + type: string + type: object + type: array + service: + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + loadBalancerIP: + type: string + loadBalancerSourceRanges: + items: + type: string + type: array + ports: + items: + properties: + containerPort: + format: int32 + type: integer + name: + type: string + nodePort: + format: int32 + type: integer + port: + format: int32 + type: integer + type: object + type: array + type: + type: string + type: object + serviceAccount: + type: string + shareProcessNamespace: + type: boolean + sidecars: + items: + properties: + args: + items: + type: string + type: array + command: + items: + type: string + type: array + env: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + properties: + containerName: + type: string + divisor: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + items: + properties: + configMapRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + type: string + secretRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + type: string + imagePullPolicy: + type: string + lifecycle: + properties: + postStart: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + name: + type: string + ports: + items: + properties: + containerPort: + format: int32 + type: integer + hostIP: + type: string + hostPort: + format: int32 + type: integer + name: + type: string + protocol: + default: TCP + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + securityContext: + properties: + allowPrivilegeEscalation: + type: boolean + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: + type: string + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + required: + - type + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + type: object + type: object + startupProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + stdin: + type: boolean + stdinOnce: + type: boolean + terminationMessagePath: + type: string + terminationMessagePolicy: + type: string + tty: + type: boolean + volumeDevices: + items: + properties: + devicePath: + type: string + name: + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + items: + properties: + mountPath: + type: string + mountPropagation: + type: string + name: + type: string + readOnly: + type: boolean + subPath: + type: string + subPathExpr: + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + type: string + required: + - name + type: object + type: array + startupProbeFailureSeconds: + format: int32 + type: integer + storageVolumes: + items: + properties: + hostPath: + properties: + path: + type: string + type: + type: string + required: + - path + type: object + mountPath: + type: string + name: + pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*' + type: string + storageClassName: + type: string + storageSize: + pattern: (^0|([0-9]*l[.])?[0-9]+((M|G|T|E|P)i))$ + type: string + subPath: + type: string + required: + - mountPath + - name + type: object + type: array + sysctls: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + terminationGracePeriodSeconds: + format: int64 + type: integer + tolerations: + items: + properties: + effect: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array + topologySpreadConstraints: + items: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + matchLabelKeys: + items: + type: string + type: array + x-kubernetes-list-type: atomic + maxSkew: + format: int32 + type: integer + minDomains: + format: int32 + type: integer + nodeAffinityPolicy: + type: string + nodeTaintsPolicy: + type: string + topologyKey: + type: string + whenUnsatisfiable: + type: string + required: + - maxSkew + - topologyKey + - whenUnsatisfiable + type: object + type: array + updateStrategy: + properties: + rollingUpdate: + properties: + maxUnavailable: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + partition: + format: int32 + type: integer + type: object + type: + type: string + type: object + type: object starRocksFeProxySpec: properties: affinity: @@ -7329,6 +9384,33 @@ spec: required: - phase type: object + starRocksFeObserverStatus: + properties: + creatingInstances: + items: + type: string + type: array + failedInstances: + items: + type: string + type: array + phase: + type: string + reason: + type: string + resourceNames: + items: + type: string + type: array + runningInstances: + items: + type: string + type: array + serviceName: + type: string + required: + - phase + type: object starRocksFeProxyStatus: properties: creatingInstances: diff --git a/helm-charts/charts/kube-starrocks/charts/starrocks/templates/starrockscluster.yaml b/helm-charts/charts/kube-starrocks/charts/starrocks/templates/starrockscluster.yaml index 2f81ec735..f4fd33d3a 100644 --- a/helm-charts/charts/kube-starrocks/charts/starrocks/templates/starrockscluster.yaml +++ b/helm-charts/charts/kube-starrocks/charts/starrocks/templates/starrockscluster.yaml @@ -30,6 +30,9 @@ spec: - {{template "starrockscluster.entrypoint.mount.path" .}}/{{template "starrockscluster.entrypoint.script.name" .}} {{- end }} replicas: {{ .Values.starrocksFESpec.replicas }} + {{- if .Values.starrocksFESpec.observerNumber }} + observerNumber: {{ .Values.starrocksFESpec.observerNumber }} + {{- end }} imagePullPolicy: {{ .Values.starrocksFESpec.imagePullPolicy }} {{- if .Values.starrocksFESpec.maxUnavailablePods }} updateStrategy: @@ -284,6 +287,181 @@ spec: persistentVolumeClaimRetentionPolicy: {{- toYaml .Values.starrocksFESpec.persistentVolumeClaimRetentionPolicy | nindent 6 }} {{- end }} + {{- if .Values.starrocksFeObserverSpec.enabled }} + starRocksFeObserverSpec: + {{- if .Values.starrocksFeObserverSpec.initContainers }} + initContainers: + {{- toYaml .Values.starrocksFeObserverSpec.initContainers | nindent 6 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.shareProcessNamespace }} + shareProcessNamespace: {{ .Values.starrocksFeObserverSpec.shareProcessNamespace }} + {{- end }} + image: "{{ .Values.starrocksFeObserverSpec.image.repository }}:{{ default .Values.starrocksCluster.componentValues.image.tag .Values.starrocksFeObserverSpec.image.tag }}" + replicas: {{ .Values.starrocksFeObserverSpec.replicas }} + imagePullPolicy: {{ .Values.starrocksFeObserverSpec.imagePullPolicy }} + {{- if .Values.starrocksFeObserverSpec.resources }} + {{- toYaml .Values.starrocksFeObserverSpec.resources | nindent 4 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.service.type }} + service: + type: {{ .Values.starrocksFeObserverSpec.service.type }} + {{- if and (eq "LoadBalancer" .Values.starrocksFeObserverSpec.service.type) .Values.starrocksFeObserverSpec.service.loadbalancerIP }} + loadBalancerIP: {{ .Values.starrocksFeObserverSpec.service.loadbalancerIP }} + {{- end }} + {{- if and (eq "LoadBalancer" .Values.starrocksFeObserverSpec.service.type) .Values.starrocksFeObserverSpec.service.loadBalancerSourceRanges}} + loadBalancerSourceRanges: + {{- toYaml .Values.starrocksFeObserverSpec.service.loadBalancerSourceRanges | nindent 8 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.service.ports }} + ports: + {{- toYaml .Values.starrocksFeObserverSpec.service.ports | nindent 8 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.service.annotations }} + annotations: + {{- toYaml .Values.starrocksFeObserverSpec.service.annotations | nindent 8 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.service.labels }} + labels: + {{- toYaml .Values.starrocksFeObserverSpec.service.labels | nindent 8 }} + {{- end }} + {{- end }} + annotations: + app.starrocks.io/fe-config-hash: "{{template "starrockscluster.fe.config.hash" . }}" + {{- if .Values.starrocksFeObserverSpec.annotations }} + {{- toYaml .Values.starrocksFeObserverSpec.annotations | nindent 6 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.imagePullSecrets }} + imagePullSecrets: + {{- toYaml .Values.starrocksFeObserverSpec.imagePullSecrets | nindent 6 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.serviceAccount }} + serviceAccount: {{ .Values.starrocksFeObserverSpec.serviceAccount }} + {{- end }} + runAsNonRoot: {{ .Values.starrocksFeObserverSpec.runAsNonRoot }} + {{- if .Values.starrocksFeObserverSpec.readOnlyRootFilesystem }} + readOnlyRootFilesystem: {{ .Values.starrocksFeObserverSpec.readOnlyRootFilesystem }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.capabilities }} + capabilities: + {{- toYaml .Values.starrocksFeObserverSpec.capabilities | nindent 6 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.sysctls }} + sysctls: + {{- toYaml .Values.starrocksFeObserverSpec.sysctls | nindent 6 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.nodeSelector }} + nodeSelector: + {{- toYaml .Values.starrocksFeObserverSpec.nodeSelector | nindent 6 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.podLabels }} + podLabels: + {{- toYaml .Values.starrocksFeObserverSpec.podLabels | nindent 6 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.hostAliases }} + hostAliases: + {{- toYaml .Values.starrocksFeObserverSpec.hostAliases | nindent 6 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.schedulerName }} + schedulerName: {{ .Values.starrocksFeObserverSpec.schedulerName }} + {{- end }} + feEnvVars: + - name: TZ + value: {{ .Values.timeZone }} + {{- if .Values.starrocksFeObserverSpec.feEnvVars }} + {{- /* if it is a map, we use range to iterate to merge environment variables */}} + {{- if eq (kindOf .Values.starrocksFeObserverSpec.feEnvVars) "map" }} + {{- range $key, $value := .Values.starrocksFeObserverSpec.feEnvVars }} + - name: {{ $key }} + {{- if eq (kindOf $value) "string" }} + value: {{ $value | quote }} + {{- else }} + {{- toYaml $value | nindent 8 }} + {{- end }} + {{- end }} + {{- else }} + {{- /* the default kind is slice, we keep backward compatibility */}} + {{- toYaml .Values.starrocksFeObserverSpec.feEnvVars | nindent 6 }} + {{- end }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.affinity }} + affinity: + {{- toYaml .Values.starrocksFeObserverSpec.affinity | nindent 6 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.tolerations }} + tolerations: + {{- toYaml .Values.starrocksFeObserverSpec.tolerations | nindent 6 }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml .Values.starrocksFeObserverSpec.topologySpreadConstraints | nindent 6 }} + {{- end }} + terminationGracePeriodSeconds: {{ .Values.starrocksFeObserverSpec.terminationGracePeriodSeconds }} + {{- if .Values.starrocksFeObserverSpec.startupProbeFailureSeconds }} + startupProbeFailureSeconds: {{ .Values.starrocksFeObserverSpec.startupProbeFailureSeconds }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.livenessProbeFailureSeconds }} + livenessProbeFailureSeconds: {{ .Values.starrocksFeObserverSpec.livenessProbeFailureSeconds }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.readinessProbeFailureSeconds }} + readinessProbeFailureSeconds: {{ .Values.starrocksFeObserverSpec.readinessProbeFailureSeconds }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.lifecycle }} + lifecycle: + {{- toYaml .Values.starrocksFeObserverSpec.lifecycle | nindent 6 }} + {{- end }} + {{- if and .Values.starrocksFeObserverSpec.sidecarsMap .Values.starrocksFeObserverSpec.sidecars }} + {{ fail "starrocksFeObserverSpec.sidecarsMap and starrocksFeObserverSpec.sidecars cannot be set at the same time" }} + {{- end }} + {{- if or .Values.starrocksFeObserverSpec.sidecarsMap .Values.starrocksFeObserverSpec.sidecars }} + sidecars: + {{- if .Values.starrocksFeObserverSpec.sidecarsMap }} + {{- range $name, $spec := .Values.starrocksFeObserverSpec.sidecarsMap }} + - name: {{ $name }} + {{- toYaml $spec | nindent 8 }} + {{- end }} + {{- else if .Values.starrocksFeObserverSpec.sidecars }} + {{- toYaml .Values.starrocksFeObserverSpec.sidecars | nindent 6 }} + {{- end }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.secrets }} + secrets: + {{- range .Values.starrocksFeObserverSpec.secrets }} + - name: {{ .name }} + mountPath: {{ .mountPath }} + subPath: {{ .subPath }} + {{- end }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.configMaps }} + configMaps: + {{- range .Values.starrocksFeObserverSpec.configMaps }} + - name: {{ .name }} + mountPath: {{ .mountPath }} + subPath: {{ .subPath }} + {{- end }} + {{- end }} + configMapInfo: + configMapName: {{ template "starrockscluster.fe.configmap.name" . }} + resolveKey: fe.conf + {{- if or .Values.starrocksFeObserverSpec.emptyDirs .Values.starrocksFeObserverSpec.hostPaths }} + storageVolumes: + {{- if .Values.starrocksFeObserverSpec.emptyDirs }} + {{- range .Values.starrocksFeObserverSpec.emptyDirs }} + - name: {{ .name }} + mountPath: {{ .mountPath }} + storageClassName: "emptyDir" + {{- end }} + {{- end }} + {{- if .Values.starrocksFeObserverSpec.hostPaths }} + {{- range .Values.starrocksFeObserverSpec.hostPaths }} + - name: {{ .name }} + mountPath: {{ .mountPath }} + storageClassName: "hostPath" + hostPath: + {{- toYaml .hostPath | nindent 8 }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} {{- if .Values.starrocksCluster.enabledBe }} starRocksBeSpec: {{- if .Values.starrocksBeSpec.initContainers }} diff --git a/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml b/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml index 55729fa30..5fe7fb2ef 100644 --- a/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml @@ -516,6 +516,210 @@ starrocksFESpec: # in the same pod, and the first process in each container will not be assigned PID 1. shareProcessNamespace: +# spec to deploy fe observer. +starrocksFeObserverSpec: + # specify the FE observer deployment or not. + enabled: false + # number of replicas to deploy for a FE observer deployment. + replicas: 1 + image: + # image sliced by "repository:tag" + repository: starrocks/fe-ubuntu + tag: "" + imagePullPolicy: IfNotPresent + # add annotations for FE observer pods. + annotations: {} + # If runAsNonRoot is true, the container is run as a non-root user. + # The userId will be set to 1000, and the groupID will be set to 1000. + runAsNonRoot: false + # Whether this container has a read-only root filesystem. + readOnlyRootFilesystem: false + # add/drop capabilities for FE observer container. + capabilities: {} + # set sysctls for FE observer pod. + sysctls: [] + # specify the service name and port config and serviceType + service: + # the FE observer service type, only supported ClusterIP, NodePort, LoadBalancer + type: "ClusterIP" + # the loadBalancerIP for static ip config when the type=LoadBalancer and loadbalancerIp is not empty. + loadbalancerIP: "" + # add annotations for external FE observer service. + annotations: {} + # Add labels for external FE observer service. The operator may add its own default labels. + labels: {} + # Config the service port for FE observer service. + # To assign a specific port or nodePort to a service, you should specify them by the corresponding name or + # containerPort in the service configuration. If both containerPort and name are specified, containerPort takes precedence. + # For fe, port name can be http, query, rpc, edit-log, and their default container port is 8030, 9030, 9020, 9010. + ports: [] + # e.g., specify a dedicated node port for FE observer service by containerPort. + # - nodePort: 30030 # The range of valid ports is 30000-32767 + # containerPort: 8030 # The port exported on the container + # specifies the source IP ranges for the load balancer when the type=LoadBalancer. + loadBalancerSourceRanges: [] + # - 10.0.0.0/8 + # imagePullSecrets allows you to use secrets to pull images for pods. + imagePullSecrets: [] + # - name: "image-pull-secret" + # serviceAccount for FE observer access cloud service. + serviceAccount: "" + # If specified, the pod's nodeSelector,displayName="Map of nodeSelectors to match when scheduling pods on nodes" + # Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector + nodeSelector: {} + # kubernetes.io/arch: amd64 + # kubernetes.io/os: linux + # the pod labels for user select or classify pods. + podLabels: {} + # hostAliases allows adding entries to /etc/hosts inside the containers + hostAliases: [] + # - ip: "127.0.0.1" + # hostnames: + # - "example.com" + # schedulerName allows you to specify which scheduler will be used for your pods. + schedulerName: "" + # Additional FE observer container environment variables. + # See https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/ for how to define environment variables. + # Note: If you use slice to define environment variables, and if there are multiple values files, the values in the last values file will take effect. + # If you use a map to define environment variables, the values will be merged. + # You can only use one of the manners to define environment variables. + # To avoid the different types of feEnvVars, we do not define the default value of feEnvVars, e.g., feEnvVars: [] or feEnvVars: {}. + #feEnvVars: + # define environment variables by slice. + # E.g., static environment variable: + # - name: DEMO_GREETING + # value: "Hello from the environment" + # e.g., secret environment variable: + # - name: USERNAME + # valueFrom: + # secretKeyRef: + # name: mysecret + # key: username + # affinity for FE observer pod scheduling. + affinity: {} + # nodeAffinity: + # requiredDuringSchedulingIgnoredDuringExecution: + # nodeSelectorTerms: + # - matchFields: + # - key: metadata.name + # operator: In + # values: + # - target-host-name + # podAntiAffinity: + # requiredDuringSchedulingIgnoredDuringExecution: + # - labelSelector: + # matchExpressions: + # - key: app.kubernetes.io/component + # operator: In + # values: + # - fe-observer + # topologyKey: "kubernetes.io/hostname" + # Node tolerations for FE observer pod scheduling to nodes with taints + # Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + tolerations: [] + # - key: "key" + # operator: "Equal|Exists" + # value: "value" + # effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" + # topologySpreadConstraints for scheduling pods across failure-domains. + # Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ + topologySpreadConstraints: [] + # - maxSkew: 1 + # topologyKey: topology.kubernetes.io/zone + # whenUnsatisfiable: DoNotSchedule|ScheduleAnyway + # labelSelector: + # matchLabels: + # foo: bar + # resources for FE observer pod. + resources: + requests: + cpu: 4 + memory: 4Gi + # If you want to remove one resource limit, e.g., cpu, you can set it to cpu: "unlimited". + limits: + cpu: 8 + memory: 8Gi + # mount secrets if necessary. + # see https://kubernetes.io/docs/concepts/storage/volumes/#secret for more details. + secrets: [] + # e.g., mount my-secret to /etc/my-secret + # - name: my-secret + # mountPath: /etc/my-secret + # subPath: "" + # mount configmaps if necessary. + # see https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath for more details about subPath. + configMaps: [] + # e.g., mount my-configmap to /etc/my-configmap + # - name: my-configmap + # mountPath: /etc/my-configmap + # subPath: "" + # terminationGracePeriodSeconds defines duration in seconds the FE observer pod needs to terminate gracefully. + # the default value is 120 seconds + terminationGracePeriodSeconds: 120 + + # Please upgrade the CRD with v1.8.7 released version if you want to use the following configuration. + # including: startupProbeFailureSeconds, livenessProbeFailureSeconds, readinessProbeFailureSeconds + + # StartupProbeFailureSeconds defines the total failure seconds of a startup Probe. + # the default value is 300 seconds + # You can set it to "0" to disable the probe. + startupProbeFailureSeconds: + # LivenessProbeFailureSeconds defines the total failure seconds of a liveness Probe. + # the default value is 15 seconds + # You can set it to "0" to disable the probe. + livenessProbeFailureSeconds: + # ReadinessProbeFailureSeconds defines the total failure seconds of a readiness Probe. + # the default value is 15 seconds + # You can set it to "0" to disable the probe. + readinessProbeFailureSeconds: + # Lifecycle describes actions that the management system should take in response to container lifecycle events. + # By default, Operator will add corresponding preStop hooks for different components. You can set postStart hook. + lifecycle: {} + # postStart: + # exec: + # command: + # - /bin/sh + # - -c + # - echo "Hello, world!" + # Sidecars is an optional list of containers that are run in the same pod as the starrocks component. + # You can use this field to launch helper containers that provide additional functionality to the main container. + # See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to define sidecars. + sidecars: [] + # - name: sidecar-container + # image: busybox + # command: ['sh', '-c', 'echo "hello from the sidecar container" >/opt/starrocks/fe/meta/sidecar-data.txt && sleep 3600'] + # sidecarsMap is an optional map of containers that are run in the same pod as the starrocks component. + # The reason for using sidecarsMap please refer to https://github.com/StarRocks/starrocks-kubernetes-operator/issues/618 + # sidecarsMap has higher priority than sidecars, and the key of sidecarsMap is the name of the sidecar container. + sidecarsMap: {} + # sidecar-container: + # image: busybox + # command: ['sh', '-c', 'echo "hello from the sidecar container" >/opt/starrocks/fe/meta/sidecar-data.txt && sleep 3600'] + # initContainers is an optional list of containers that are run in the same pod as the starrocks component. + # You can use this to launch helper containers that run before the main container starts. + # See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to configure a container. + initContainers: [] + # - name: init-container + # image: busybox + # command: ['sh', '-c', 'echo "hello from the init container" >/opt/starrocks/fe/meta/init-data.txt'] + # Share a single process namespace between all the containers in a pod. + # When this is set, containers will be able to view and signal processes from other containers + # in the same pod, and the first process in each container will not be assigned PID 1. + shareProcessNamespace: + # Note: will create emptyDir volume for FE observer, PVC is not supported. + emptyDirs: [] + # e.g., mount an emptyDir volume to /tmp + # - name: tmp-data + # mountPath: /tmp + # mount host paths if necessary. + # Note: This should be used with caution. + hostPaths: [] + # - name: host-data + # mountPath: /var/lib/starrocks + # hostPath: + # path: /data/starrocks + # type: DirectoryOrCreate + # spec for compute node, compute node provide compute function. starrocksCnSpec: # Number of replicas to deploy for the CN component. diff --git a/helm-charts/charts/kube-starrocks/values.yaml b/helm-charts/charts/kube-starrocks/values.yaml index d0b349510..0af34ec3f 100644 --- a/helm-charts/charts/kube-starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/values.yaml @@ -632,6 +632,210 @@ starrocks: # in the same pod, and the first process in each container will not be assigned PID 1. shareProcessNamespace: + # spec to deploy fe observer. + starrocksFeObserverSpec: + # specify the FE observer deployment or not. + enabled: false + # number of replicas to deploy for a FE observer deployment. + replicas: 1 + image: + # image sliced by "repository:tag" + repository: starrocks/fe-ubuntu + tag: "" + imagePullPolicy: IfNotPresent + # add annotations for FE observer pods. + annotations: {} + # If runAsNonRoot is true, the container is run as a non-root user. + # The userId will be set to 1000, and the groupID will be set to 1000. + runAsNonRoot: false + # Whether this container has a read-only root filesystem. + readOnlyRootFilesystem: false + # add/drop capabilities for FE observer container. + capabilities: {} + # set sysctls for FE observer pod. + sysctls: [] + # specify the service name and port config and serviceType + service: + # the FE observer service type, only supported ClusterIP, NodePort, LoadBalancer + type: "ClusterIP" + # the loadBalancerIP for static ip config when the type=LoadBalancer and loadbalancerIp is not empty. + loadbalancerIP: "" + # add annotations for external FE observer service. + annotations: {} + # Add labels for external FE observer service. The operator may add its own default labels. + labels: {} + # Config the service port for FE observer service. + # To assign a specific port or nodePort to a service, you should specify them by the corresponding name or + # containerPort in the service configuration. If both containerPort and name are specified, containerPort takes precedence. + # For fe, port name can be http, query, rpc, edit-log, and their default container port is 8030, 9030, 9020, 9010. + ports: [] + # e.g., specify a dedicated node port for FE observer service by containerPort. + # - nodePort: 30030 # The range of valid ports is 30000-32767 + # containerPort: 8030 # The port exported on the container + # specifies the source IP ranges for the load balancer when the type=LoadBalancer. + loadBalancerSourceRanges: [] + # - 10.0.0.0/8 + # imagePullSecrets allows you to use secrets to pull images for pods. + imagePullSecrets: [] + # - name: "image-pull-secret" + # serviceAccount for FE observer access cloud service. + serviceAccount: "" + # If specified, the pod's nodeSelector,displayName="Map of nodeSelectors to match when scheduling pods on nodes" + # Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector + nodeSelector: {} + # kubernetes.io/arch: amd64 + # kubernetes.io/os: linux + # the pod labels for user select or classify pods. + podLabels: {} + # hostAliases allows adding entries to /etc/hosts inside the containers + hostAliases: [] + # - ip: "127.0.0.1" + # hostnames: + # - "example.com" + # schedulerName allows you to specify which scheduler will be used for your pods. + schedulerName: "" + # Additional FE observer container environment variables. + # See https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/ for how to define environment variables. + # Note: If you use slice to define environment variables, and if there are multiple values files, the values in the last values file will take effect. + # If you use a map to define environment variables, the values will be merged. + # You can only use one of the manners to define environment variables. + # To avoid the different types of feEnvVars, we do not define the default value of feEnvVars, e.g., feEnvVars: [] or feEnvVars: {}. + #feEnvVars: + # define environment variables by slice. + # E.g., static environment variable: + # - name: DEMO_GREETING + # value: "Hello from the environment" + # e.g., secret environment variable: + # - name: USERNAME + # valueFrom: + # secretKeyRef: + # name: mysecret + # key: username + # affinity for FE observer pod scheduling. + affinity: {} + # nodeAffinity: + # requiredDuringSchedulingIgnoredDuringExecution: + # nodeSelectorTerms: + # - matchFields: + # - key: metadata.name + # operator: In + # values: + # - target-host-name + # podAntiAffinity: + # requiredDuringSchedulingIgnoredDuringExecution: + # - labelSelector: + # matchExpressions: + # - key: app.kubernetes.io/component + # operator: In + # values: + # - fe-observer + # topologyKey: "kubernetes.io/hostname" + # Node tolerations for FE observer pod scheduling to nodes with taints + # Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + tolerations: [] + # - key: "key" + # operator: "Equal|Exists" + # value: "value" + # effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" + # topologySpreadConstraints for scheduling pods across failure-domains. + # Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ + topologySpreadConstraints: [] + # - maxSkew: 1 + # topologyKey: topology.kubernetes.io/zone + # whenUnsatisfiable: DoNotSchedule|ScheduleAnyway + # labelSelector: + # matchLabels: + # foo: bar + # resources for FE observer pod. + resources: + requests: + cpu: 4 + memory: 4Gi + # If you want to remove one resource limit, e.g., cpu, you can set it to cpu: "unlimited". + limits: + cpu: 8 + memory: 8Gi + # mount secrets if necessary. + # see https://kubernetes.io/docs/concepts/storage/volumes/#secret for more details. + secrets: [] + # e.g., mount my-secret to /etc/my-secret + # - name: my-secret + # mountPath: /etc/my-secret + # subPath: "" + # mount configmaps if necessary. + # see https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath for more details about subPath. + configMaps: [] + # e.g., mount my-configmap to /etc/my-configmap + # - name: my-configmap + # mountPath: /etc/my-configmap + # subPath: "" + # terminationGracePeriodSeconds defines duration in seconds the FE observer pod needs to terminate gracefully. + # the default value is 120 seconds + terminationGracePeriodSeconds: 120 + + # Please upgrade the CRD with v1.8.7 released version if you want to use the following configuration. + # including: startupProbeFailureSeconds, livenessProbeFailureSeconds, readinessProbeFailureSeconds + + # StartupProbeFailureSeconds defines the total failure seconds of a startup Probe. + # the default value is 300 seconds + # You can set it to "0" to disable the probe. + startupProbeFailureSeconds: + # LivenessProbeFailureSeconds defines the total failure seconds of a liveness Probe. + # the default value is 15 seconds + # You can set it to "0" to disable the probe. + livenessProbeFailureSeconds: + # ReadinessProbeFailureSeconds defines the total failure seconds of a readiness Probe. + # the default value is 15 seconds + # You can set it to "0" to disable the probe. + readinessProbeFailureSeconds: + # Lifecycle describes actions that the management system should take in response to container lifecycle events. + # By default, Operator will add corresponding preStop hooks for different components. You can set postStart hook. + lifecycle: {} + # postStart: + # exec: + # command: + # - /bin/sh + # - -c + # - echo "Hello, world!" + # Sidecars is an optional list of containers that are run in the same pod as the starrocks component. + # You can use this field to launch helper containers that provide additional functionality to the main container. + # See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to define sidecars. + sidecars: [] + # - name: sidecar-container + # image: busybox + # command: ['sh', '-c', 'echo "hello from the sidecar container" >/opt/starrocks/fe/meta/sidecar-data.txt && sleep 3600'] + # sidecarsMap is an optional map of containers that are run in the same pod as the starrocks component. + # The reason for using sidecarsMap please refer to https://github.com/StarRocks/starrocks-kubernetes-operator/issues/618 + # sidecarsMap has higher priority than sidecars, and the key of sidecarsMap is the name of the sidecar container. + sidecarsMap: {} + # sidecar-container: + # image: busybox + # command: ['sh', '-c', 'echo "hello from the sidecar container" >/opt/starrocks/fe/meta/sidecar-data.txt && sleep 3600'] + # initContainers is an optional list of containers that are run in the same pod as the starrocks component. + # You can use this to launch helper containers that run before the main container starts. + # See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to configure a container. + initContainers: [] + # - name: init-container + # image: busybox + # command: ['sh', '-c', 'echo "hello from the init container" >/opt/starrocks/fe/meta/init-data.txt'] + # Share a single process namespace between all the containers in a pod. + # When this is set, containers will be able to view and signal processes from other containers + # in the same pod, and the first process in each container will not be assigned PID 1. + shareProcessNamespace: + # Note: will create emptyDir volume for FE observer, PVC is not supported. + emptyDirs: [] + # e.g., mount an emptyDir volume to /tmp + # - name: tmp-data + # mountPath: /tmp + # mount host paths if necessary. + # Note: This should be used with caution. + hostPaths: [] + # - name: host-data + # mountPath: /var/lib/starrocks + # hostPath: + # path: /data/starrocks + # type: DirectoryOrCreate + # spec for compute node, compute node provide compute function. starrocksCnSpec: # Number of replicas to deploy for the CN component. diff --git a/pkg/apis/starrocks/v1/zz_generated.deepcopy.go b/pkg/apis/starrocks/v1/zz_generated.deepcopy.go index 5d7f40093..cf1f67119 100644 --- a/pkg/apis/starrocks/v1/zz_generated.deepcopy.go +++ b/pkg/apis/starrocks/v1/zz_generated.deepcopy.go @@ -549,6 +549,45 @@ func (in *StarRocksComponentStatus) DeepCopy() *StarRocksComponentStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StarRocksFeObserverSpec) DeepCopyInto(out *StarRocksFeObserverSpec) { + *out = *in + in.StarRocksComponentSpec.DeepCopyInto(&out.StarRocksComponentSpec) + if in.FeEnvVars != nil { + in, out := &in.FeEnvVars, &out.FeEnvVars + *out = make([]corev1.EnvVar, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StarRocksFeObserverSpec. +func (in *StarRocksFeObserverSpec) DeepCopy() *StarRocksFeObserverSpec { + if in == nil { + return nil + } + out := new(StarRocksFeObserverSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StarRocksFeObserverStatus) DeepCopyInto(out *StarRocksFeObserverStatus) { + *out = *in + in.StarRocksComponentStatus.DeepCopyInto(&out.StarRocksComponentStatus) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StarRocksFeObserverStatus. +func (in *StarRocksFeObserverStatus) DeepCopy() *StarRocksFeObserverStatus { + if in == nil { + return nil + } + out := new(StarRocksFeObserverStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StarRocksFeProxySpec) DeepCopyInto(out *StarRocksFeProxySpec) { *out = *in @@ -609,29 +648,6 @@ func (in *StarRocksFeSpec) DeepCopy() *StarRocksFeSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StarRocksFeObserverSpec) DeepCopyInto(out *StarRocksFeObserverSpec) { - *out = *in - in.StarRocksComponentSpec.DeepCopyInto(&out.StarRocksComponentSpec) - if in.FeEnvVars != nil { - in, out := &in.FeEnvVars, &out.FeEnvVars - *out = make([]corev1.EnvVar, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StarRocksFeObserverSpec. -func (in *StarRocksFeObserverSpec) DeepCopy() *StarRocksFeObserverSpec { - if in == nil { - return nil - } - out := new(StarRocksFeObserverSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StarRocksFeStatus) DeepCopyInto(out *StarRocksFeStatus) { *out = *in @@ -648,22 +664,6 @@ func (in *StarRocksFeStatus) DeepCopy() *StarRocksFeStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StarRocksFeObserverStatus) DeepCopyInto(out *StarRocksFeObserverStatus) { - *out = *in - in.StarRocksComponentStatus.DeepCopyInto(&out.StarRocksComponentStatus) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StarRocksFeObserverStatus. -func (in *StarRocksFeObserverStatus) DeepCopy() *StarRocksFeObserverStatus { - if in == nil { - return nil - } - out := new(StarRocksFeObserverStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StarRocksLoadSpec) DeepCopyInto(out *StarRocksLoadSpec) { *out = *in diff --git a/pkg/subcontrollers/feobserver/feobserver_controller.go b/pkg/subcontrollers/feobserver/feobserver_controller.go index c6d1b9d34..13329d4ca 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller.go @@ -20,7 +20,6 @@ import ( "context" "fmt" - "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/deployment" "github.com/go-logr/logr" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -35,6 +34,7 @@ import ( rutils "github.com/StarRocks/starrocks-kubernetes-operator/pkg/common/resource_utils" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/load" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/deployment" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/object" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/pod" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/service" diff --git a/pkg/subcontrollers/feobserver/feobserver_controller_test.go b/pkg/subcontrollers/feobserver/feobserver_controller_test.go new file mode 100644 index 000000000..ca64ab8c5 --- /dev/null +++ b/pkg/subcontrollers/feobserver/feobserver_controller_test.go @@ -0,0 +1,332 @@ +/* +Copyright 2021-present, StarRocks Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package feobserver_test + +import ( + "context" + "os" + "reflect" + "testing" + "time" + + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/fe" + "github.com/stretchr/testify/require" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" + + srapi "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1" + rutils "github.com/StarRocks/starrocks-kubernetes-operator/pkg/common/resource_utils" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/fake" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/load" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/service" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/feobserver" +) + +func TestMain(m *testing.M) { + srapi.Register() + os.Exit(m.Run()) +} + +func TestFeObserver_ClearCluster(t *testing.T) { + now := metav1.NewTime(time.Now()) + src := &srapi.StarRocksCluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + Namespace: "default", + DeletionTimestamp: &now, + }, + Spec: srapi.StarRocksClusterSpec{}, + Status: srapi.StarRocksClusterStatus{ + StarRocksFeObserverStatus: &srapi.StarRocksFeObserverStatus{ + StarRocksComponentStatus: srapi.StarRocksComponentStatus{ + ResourceNames: []string{"test-fe-observer"}, + ServiceName: "test-fe-observer-access", + }, + }, + }, + } + + deploy := appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: load.Name(src.Name, src.Spec.StarRocksFeObserverSpec), + Namespace: "default", + }, + } + + svc := corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: service.ExternalServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), + Namespace: "default", + }, + } + + ssvc := corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: service.SearchServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), + Namespace: "default", + }, + } + + fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src, &deploy, &svc, &ssvc), fake.GetEventRecorderFor(nil)) + err := fc.ClearCluster(context.Background(), src) + require.NoError(t, err) + + var ed appsv1.Deployment + err = fc.Client.Get(context.Background(), types.NamespacedName{Name: deploy.Name, Namespace: "default"}, &ed) + require.True(t, err == nil || apierrors.IsNotFound(err)) + var esvc corev1.Service + err = fc.Client.Get(context.Background(), types.NamespacedName{Name: svc.Name, Namespace: "default"}, &esvc) + require.True(t, err == nil || apierrors.IsNotFound(err)) + var essvc corev1.Service + err = fc.Client.Get(context.Background(), types.NamespacedName{Name: ssvc.Name, Namespace: "default"}, &essvc) + require.True(t, err == nil || apierrors.IsNotFound(err)) +} + +func TestFeObserver_SyncCluster(t *testing.T) { + src := &srapi.StarRocksCluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + Namespace: "default", + }, + Spec: srapi.StarRocksClusterSpec{ + StarRocksFeSpec: &srapi.StarRocksFeSpec{ + StarRocksComponentSpec: srapi.StarRocksComponentSpec{ + StarRocksLoadSpec: srapi.StarRocksLoadSpec{ + Image: "starrocks.com/cn:2.40", + }, + }, + }, + StarRocksFeObserverSpec: &srapi.StarRocksFeObserverSpec{ + StarRocksComponentSpec: srapi.StarRocksComponentSpec{ + StarRocksLoadSpec: srapi.StarRocksLoadSpec{ + Replicas: rutils.GetInt32Pointer(1), + Image: "starrocks.com/cn:2.40", + ResourceRequirements: corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceCPU: *resource.NewQuantity(4, resource.DecimalSI), + corev1.ResourceMemory: resource.MustParse("16G"), + }, + }, + }, + }, + }, + }, + } + + fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src), fake.GetEventRecorderFor(nil)) + err := fc.SyncCluster(context.Background(), src) + require.NoError(t, err) + err = fc.UpdateClusterStatus(context.Background(), src) + require.NoError(t, err) + + status := src.Status.StarRocksFeObserverStatus + require.NotNil(t, status) + require.Equal(t, srapi.ComponentReconciling, status.Phase) + require.Equal(t, service.ExternalServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), status.ServiceName) + + var deploy appsv1.Deployment + require.NoError(t, fc.Client.Get(context.Background(), + types.NamespacedName{Name: load.Name(src.Name, src.Spec.StarRocksFeObserverSpec), Namespace: "default"}, &deploy)) + var asvc corev1.Service + require.NoError(t, fc.Client.Get(context.Background(), + types.NamespacedName{Name: service.ExternalServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), Namespace: "default"}, &asvc)) + var rsvc corev1.Service + require.NoError(t, fc.Client.Get(context.Background(), + types.NamespacedName{Name: service.SearchServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), Namespace: "default"}, &rsvc)) + + require.Equal(t, asvc.Spec.Selector, deploy.Spec.Selector.MatchLabels) +} + +func TestFeObserver_Ready(t *testing.T) { + type args struct { + ctx context.Context + k8sClient client.Client + clusterNamespace string + clusterName string + } + tests := []struct { + name string + args args + want bool + }{ + { + name: "test fe is not ready", + args: args{ + ctx: context.Background(), + k8sClient: fake.NewFakeClient(srapi.Scheme, &corev1.Endpoints{ + TypeMeta: metav1.TypeMeta{ + Kind: "Endpoints", + APIVersion: corev1.SchemeGroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "kube-starrocks-fe-service", + Namespace: "default", + }, + }), + clusterNamespace: "default", + clusterName: "kube-starrocks", + }, + want: false, + }, + { + name: "test fe is ready", + args: args{ + ctx: context.Background(), + k8sClient: fake.NewFakeClient(srapi.Scheme, &corev1.Endpoints{ + TypeMeta: metav1.TypeMeta{ + Kind: "Endpoints", + APIVersion: corev1.SchemeGroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "kube-starrocks-fe-service", + Namespace: "default", + }, + Subsets: []corev1.EndpointSubset{ + { + Addresses: []corev1.EndpointAddress{ + { + IP: "127.0.0.1", + }, + }, + }, + }, + }), + clusterNamespace: "default", + clusterName: "kube-starrocks", + }, + want: true, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := fe.CheckFEReady(tt.args.ctx, tt.args.k8sClient, tt.args.clusterNamespace, tt.args.clusterName); got != tt.want { + t.Errorf("CheckFEReady() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestGetFEObserverConfig(t *testing.T) { + type args struct { + ctx context.Context + observerSpec *srapi.StarRocksFeObserverSpec + namespace string + } + type fields struct { + k8sClient client.Client + } + tests := []struct { + name string + fields fields + args args + want map[string]interface{} + wantErr bool + }{ + { + name: "get config from ConfigMapInfo", + fields: fields{ + k8sClient: fake.NewFakeClient(srapi.Scheme, &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: "feobserver-config", + Namespace: "default", + }, + Data: map[string]string{ + "fe.conf": "aa = bb", + }, + }), + }, + args: args{ + ctx: context.Background(), + observerSpec: &srapi.StarRocksFeObserverSpec{ + StarRocksComponentSpec: srapi.StarRocksComponentSpec{ + StarRocksLoadSpec: srapi.StarRocksLoadSpec{ + ConfigMapInfo: srapi.ConfigMapInfo{ + ConfigMapName: "feobserver-config", + ResolveKey: "fe.conf", + }, + }, + }, + }, + namespace: "default", + }, + want: map[string]interface{}{ + "aa": "bb", + }, + }, + { + name: "get config from configMaps with matching subpath", + fields: fields{ + k8sClient: fake.NewFakeClient(srapi.Scheme, &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: "feobserver-config", + Namespace: "default", + }, + Data: map[string]string{ + "fe.conf": "cc = dd", + }, + }), + }, + args: args{ + ctx: context.Background(), + observerSpec: &srapi.StarRocksFeObserverSpec{ + StarRocksComponentSpec: srapi.StarRocksComponentSpec{ + ConfigMaps: []srapi.ConfigMapReference{ + { + Name: "feobserver-config", + MountPath: "/opt/starrocks/fe/conf/fe.conf", + SubPath: "fe.conf", + }, + }, + }, + }, + namespace: "default", + }, + want: map[string]interface{}{ + "cc": "dd", + }, + }, + { + name: "get empty config", + fields: fields{ + k8sClient: fake.NewFakeClient(srapi.Scheme), + }, + args: args{ + ctx: context.Background(), + observerSpec: &srapi.StarRocksFeObserverSpec{}, + namespace: "default", + }, + want: map[string]interface{}{}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := feobserver.GetFEObserverConfig(tt.args.ctx, tt.fields.k8sClient, tt.args.observerSpec, tt.args.namespace) + if (err != nil) != tt.wantErr { + t.Errorf("GetFEObserverConfig() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetFEObserverConfig() got = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/pkg/subcontrollers/feobserver/feobserver_pod.go b/pkg/subcontrollers/feobserver/feobserver_pod.go index a85830d2e..835d0da42 100644 --- a/pkg/subcontrollers/feobserver/feobserver_pod.go +++ b/pkg/subcontrollers/feobserver/feobserver_pod.go @@ -35,7 +35,8 @@ const ( ) // buildPodTemplate construct the podTemplate for deploy fe observer. -func (fc *FeObserverController) buildPodTemplate(src *srapi.StarRocksCluster, config map[string]interface{}) (*corev1.PodTemplateSpec, error) { +func (fc *FeObserverController) buildPodTemplate(src *srapi.StarRocksCluster, + config map[string]interface{}) (*corev1.PodTemplateSpec, error) { metaName := src.Name + "-" + srapi.DEFAULT_FE_OBSERVER observerSpec := src.Spec.StarRocksFeObserverSpec From a8c455b6ecc38a0afd5bce78069dd0a35fc8397b Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Mon, 12 Jan 2026 16:53:18 +0800 Subject: [PATCH 05/22] fix Signed-off-by: zhaohehuhu --- config/crd/bases/starrocks.com_starrocksclusters.yaml | 3 --- deploy/starrocks.com_starrocksclusters.yaml | 3 --- .../charts/starrocks/templates/starrockscluster.yaml | 3 --- .../kube-starrocks/charts/starrocks/values.yaml | 1 - helm-charts/charts/kube-starrocks/values.yaml | 1 - pkg/apis/starrocks/v1/labels.go | 2 +- pkg/apis/starrocks/v1/starrockscluster_types.go | 11 ----------- pkg/apis/starrocks/v1/zz_generated.deepcopy.go | 5 ----- pkg/k8sutils/templates/pod/spec.go | 11 +++++------ pkg/k8sutils/templates/pod/spec_test.go | 5 ----- .../feobserver/feobserver_controller_test.go | 2 +- 11 files changed, 7 insertions(+), 40 deletions(-) diff --git a/config/crd/bases/starrocks.com_starrocksclusters.yaml b/config/crd/bases/starrocks.com_starrocksclusters.yaml index e8ce6dc69..66a67511d 100644 --- a/config/crd/bases/starrocks.com_starrocksclusters.yaml +++ b/config/crd/bases/starrocks.com_starrocksclusters.yaml @@ -18019,9 +18019,6 @@ spec: description: (Optional) If specified, the pod's nodeSelector,displayName="Map of nodeSelectors to match when scheduling pods on nodes" type: object - observerNumber: - format: int32 - type: integer persistentVolumeClaimRetentionPolicy: description: |- PersistentVolumeClaimRetentionPolicy specifies the retention policy for PersistentVolumeClaims associated with the component. diff --git a/deploy/starrocks.com_starrocksclusters.yaml b/deploy/starrocks.com_starrocksclusters.yaml index 16b4625d9..5b5dd41d8 100644 --- a/deploy/starrocks.com_starrocksclusters.yaml +++ b/deploy/starrocks.com_starrocksclusters.yaml @@ -8468,9 +8468,6 @@ spec: additionalProperties: type: string type: object - observerNumber: - format: int32 - type: integer persistentVolumeClaimRetentionPolicy: properties: whenDeleted: diff --git a/helm-charts/charts/kube-starrocks/charts/starrocks/templates/starrockscluster.yaml b/helm-charts/charts/kube-starrocks/charts/starrocks/templates/starrockscluster.yaml index f4fd33d3a..44133f0da 100644 --- a/helm-charts/charts/kube-starrocks/charts/starrocks/templates/starrockscluster.yaml +++ b/helm-charts/charts/kube-starrocks/charts/starrocks/templates/starrockscluster.yaml @@ -30,9 +30,6 @@ spec: - {{template "starrockscluster.entrypoint.mount.path" .}}/{{template "starrockscluster.entrypoint.script.name" .}} {{- end }} replicas: {{ .Values.starrocksFESpec.replicas }} - {{- if .Values.starrocksFESpec.observerNumber }} - observerNumber: {{ .Values.starrocksFESpec.observerNumber }} - {{- end }} imagePullPolicy: {{ .Values.starrocksFESpec.imagePullPolicy }} {{- if .Values.starrocksFESpec.maxUnavailablePods }} updateStrategy: diff --git a/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml b/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml index 5fe7fb2ef..ac50ab452 100644 --- a/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml @@ -196,7 +196,6 @@ starrocksFESpec: # number of replicas to deploy for a FE statefulset. replicas: 1 # the number of observer for FE. - # observerNumber: 0 image: # image sliced by "repository:tag" repository: starrocks/fe-ubuntu diff --git a/helm-charts/charts/kube-starrocks/values.yaml b/helm-charts/charts/kube-starrocks/values.yaml index 0af34ec3f..a9ebf66bd 100644 --- a/helm-charts/charts/kube-starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/values.yaml @@ -312,7 +312,6 @@ starrocks: # number of replicas to deploy for a FE statefulset. replicas: 1 # the number of observer for FE. - # observerNumber: 0 image: # image sliced by "repository:tag" repository: starrocks/fe-ubuntu diff --git a/pkg/apis/starrocks/v1/labels.go b/pkg/apis/starrocks/v1/labels.go index 6ed097d4c..8a414b00a 100644 --- a/pkg/apis/starrocks/v1/labels.go +++ b/pkg/apis/starrocks/v1/labels.go @@ -41,5 +41,5 @@ const ( const ( COMPONENT_NAME = "COMPONENT_NAME" FE_SERVICE_NAME = "FE_SERVICE_NAME" - OBSERVER_NUMBER = "OBSERVER_NUMBER" + IS_FE_OBSERVER = "IS_FE_OBSERVER" ) diff --git a/pkg/apis/starrocks/v1/starrockscluster_types.go b/pkg/apis/starrocks/v1/starrockscluster_types.go index e1edab64d..4f34df10a 100644 --- a/pkg/apis/starrocks/v1/starrockscluster_types.go +++ b/pkg/apis/starrocks/v1/starrockscluster_types.go @@ -156,9 +156,6 @@ type StarRocksClusterStatus struct { // StarRocksFeSpec defines the desired state of fe. type StarRocksFeSpec struct { StarRocksComponentSpec `json:",inline"` - - ObserverNumber *int32 `json:"observerNumber,omitempty"` - // +optional // feEnvVars is a slice of environment variables that are added to the pods, the default is empty. FeEnvVars []corev1.EnvVar `json:"feEnvVars,omitempty"` @@ -274,14 +271,6 @@ func (spec *StarRocksFeProxySpec) GetReplicas() *int32 { return spec.StarRocksLoadSpec.GetReplicas() } -func (spec *StarRocksFeSpec) GetObserverNumber() *int32 { - var DefaultObserverNumber int32 = 0 - if spec.ObserverNumber != nil { - return spec.ObserverNumber - } - return &DefaultObserverNumber -} - // GetHostAliases // fe proxy does not have field HostAliases, the reason why implementing this method is // that StarRocksFeProxySpec needs to implement SpecInterface interface diff --git a/pkg/apis/starrocks/v1/zz_generated.deepcopy.go b/pkg/apis/starrocks/v1/zz_generated.deepcopy.go index cf1f67119..3d9d310c3 100644 --- a/pkg/apis/starrocks/v1/zz_generated.deepcopy.go +++ b/pkg/apis/starrocks/v1/zz_generated.deepcopy.go @@ -624,11 +624,6 @@ func (in *StarRocksFeProxyStatus) DeepCopy() *StarRocksFeProxyStatus { func (in *StarRocksFeSpec) DeepCopyInto(out *StarRocksFeSpec) { *out = *in in.StarRocksComponentSpec.DeepCopyInto(&out.StarRocksComponentSpec) - if in.ObserverNumber != nil { - in, out := &in.ObserverNumber, &out.ObserverNumber - *out = new(int32) - **out = **in - } if in.FeEnvVars != nil { in, out := &in.FeEnvVars, &out.FeEnvVars *out = make([]corev1.EnvVar, len(*in)) diff --git a/pkg/k8sutils/templates/pod/spec.go b/pkg/k8sutils/templates/pod/spec.go index 027230035..43963f8fc 100644 --- a/pkg/k8sutils/templates/pod/spec.go +++ b/pkg/k8sutils/templates/pod/spec.go @@ -145,9 +145,8 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, addEnv(envVar) } - switch s := spec.(type) { + switch spec.(type) { case *v1.StarRocksFeSpec: - observerNumber := s.GetObserverNumber() for _, envVar := range []corev1.EnvVar{ { Name: v1.COMPONENT_NAME, @@ -157,10 +156,6 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, Name: v1.FE_SERVICE_NAME, Value: feExternalServiceName + "." + namespace, }, - { - Name: v1.OBSERVER_NUMBER, - Value: strconv.FormatInt(int64(*observerNumber), 10), - }, } { addEnv(envVar) } @@ -174,6 +169,10 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, Name: v1.FE_SERVICE_NAME, Value: feExternalServiceName + "." + namespace, }, + { + Name: v1.IS_FE_OBSERVER, + Value: "true", + }, } { addEnv(envVar) } diff --git a/pkg/k8sutils/templates/pod/spec_test.go b/pkg/k8sutils/templates/pod/spec_test.go index b96a4e994..674bab65d 100644 --- a/pkg/k8sutils/templates/pod/spec_test.go +++ b/pkg/k8sutils/templates/pod/spec_test.go @@ -18,7 +18,6 @@ import ( "fmt" "os" "reflect" - "strconv" "testing" corev1 "k8s.io/api/core/v1" @@ -238,10 +237,6 @@ func TestEnvs(t *testing.T) { Name: v1.FE_SERVICE_NAME, Value: service.ExternalServiceName("test", &v1.StarRocksFeSpec{}) + "." + "ns", }, - { - Name: v1.OBSERVER_NUMBER, - Value: strconv.FormatInt(int64(0), 10), - }, }...), unsupportedEnvs: "", }, diff --git a/pkg/subcontrollers/feobserver/feobserver_controller_test.go b/pkg/subcontrollers/feobserver/feobserver_controller_test.go index ca64ab8c5..d37764451 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller_test.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller_test.go @@ -23,7 +23,6 @@ import ( "testing" "time" - "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/fe" "github.com/stretchr/testify/require" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -38,6 +37,7 @@ import ( "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/fake" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/load" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/service" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/fe" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/feobserver" ) From b88dec422c91b9c064bb3a4bb78717d6f5c5a17d Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Tue, 13 Jan 2026 10:58:49 +0800 Subject: [PATCH 06/22] fix Signed-off-by: zhaohehuhu --- helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml | 1 - helm-charts/charts/kube-starrocks/values.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml b/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml index ac50ab452..66dc7742a 100644 --- a/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml @@ -195,7 +195,6 @@ starrocksCluster: starrocksFESpec: # number of replicas to deploy for a FE statefulset. replicas: 1 - # the number of observer for FE. image: # image sliced by "repository:tag" repository: starrocks/fe-ubuntu diff --git a/helm-charts/charts/kube-starrocks/values.yaml b/helm-charts/charts/kube-starrocks/values.yaml index a9ebf66bd..d19232594 100644 --- a/helm-charts/charts/kube-starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/values.yaml @@ -311,7 +311,6 @@ starrocks: starrocksFESpec: # number of replicas to deploy for a FE statefulset. replicas: 1 - # the number of observer for FE. image: # image sliced by "repository:tag" repository: starrocks/fe-ubuntu From 01afa73741644c1d66fe64f955292caedd188ef2 Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Fri, 27 Feb 2026 16:32:59 +0800 Subject: [PATCH 07/22] fix service Signed-off-by: zhaohehuhu --- pkg/common/resource_utils/service.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/common/resource_utils/service.go b/pkg/common/resource_utils/service.go index 1f17a7806..5cb1764bc 100644 --- a/pkg/common/resource_utils/service.go +++ b/pkg/common/resource_utils/service.go @@ -89,6 +89,8 @@ func BuildExternalService(object object.StarRocksObject, spec srapi.SpecInterfac switch spec.(type) { case *srapi.StarRocksFeSpec: srPorts = getFeServicePorts(config, starRocksService) + case *srapi.StarRocksFeObserverSpec: + srPorts = getFeServicePorts(config, starRocksService) case *srapi.StarRocksBeSpec: srPorts = getBeServicePorts(config, starRocksService) case *srapi.StarRocksCnSpec: From 59a4bc496630844ae7c9d70e5fa3cbfbc1ab240d Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Mon, 2 Mar 2026 14:05:54 +0800 Subject: [PATCH 08/22] refactor from deployment to statefulSet Signed-off-by: zhaohehuhu --- pkg/apis/starrocks/v1/labels.go | 7 ++--- pkg/k8sutils/templates/pod/spec.go | 2 +- .../feobserver/feobserver_controller.go | 26 +++++++++---------- .../feobserver/feobserver_controller_test.go | 14 +++++----- .../feobserver/feobserver_pod.go | 6 ++++- 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/pkg/apis/starrocks/v1/labels.go b/pkg/apis/starrocks/v1/labels.go index 8a414b00a..2ebfc353f 100644 --- a/pkg/apis/starrocks/v1/labels.go +++ b/pkg/apis/starrocks/v1/labels.go @@ -39,7 +39,8 @@ const ( // the env of container const ( - COMPONENT_NAME = "COMPONENT_NAME" - FE_SERVICE_NAME = "FE_SERVICE_NAME" - IS_FE_OBSERVER = "IS_FE_OBSERVER" + COMPONENT_NAME = "COMPONENT_NAME" + FE_SERVICE_NAME = "FE_SERVICE_NAME" + FE_OBSERVER_NAME = "FE_OBSERVER_NAME" + IS_FE_OBSERVER = "IS_FE_OBSERVER" ) diff --git a/pkg/k8sutils/templates/pod/spec.go b/pkg/k8sutils/templates/pod/spec.go index 43963f8fc..3e5d0d92c 100644 --- a/pkg/k8sutils/templates/pod/spec.go +++ b/pkg/k8sutils/templates/pod/spec.go @@ -166,7 +166,7 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, Value: v1.DEFAULT_FE_OBSERVER, }, { - Name: v1.FE_SERVICE_NAME, + Name: v1.FE_OBSERVER_NAME, Value: feExternalServiceName + "." + namespace, }, { diff --git a/pkg/subcontrollers/feobserver/feobserver_controller.go b/pkg/subcontrollers/feobserver/feobserver_controller.go index 13329d4ca..c4136e4f4 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller.go @@ -34,10 +34,10 @@ import ( rutils "github.com/StarRocks/starrocks-kubernetes-operator/pkg/common/resource_utils" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/load" - "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/deployment" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/object" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/pod" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/service" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/statefulset" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers" ) @@ -59,7 +59,7 @@ func (fc *FeObserverController) GetControllerName() string { return "feObserverController" } -// SyncCluster starRocksCluster spec to fe observer deployment and service. +// SyncCluster starRocksCluster spec to fe observer statefulset and service. func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.StarRocksCluster) error { logger := logr.FromContextOrDiscard(ctx).WithName(fc.GetControllerName()).WithValues(log.ActionKey, log.ActionSyncCluster) ctx = logr.NewContext(ctx, logger) @@ -112,10 +112,10 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star logger.Error(err, "build pod template failed") return err } - expectDeployment := deployment.MakeDeployment(src, observerSpec, *podTemplateSpec) - err = k8sutils.ApplyDeployment(ctx, fc.Client, expectDeployment) + expectSts := statefulset.MakeStatefulset(object, observerSpec, podTemplateSpec) + err = k8sutils.ApplyStatefulSet(ctx, fc.Client, &expectSts, false, rutils.StatefulSetDeepEqual) if err != nil { - logger.Error(err, "fe observer deployment failed", "StarRocksCluster", src) + logger.Error(err, "fe observer statefulset failed", "StarRocksCluster", src) return err } @@ -153,16 +153,16 @@ func (fc *FeObserverController) UpdateClusterStatus(_ context.Context, src *srap src.Status.StarRocksFeObserverStatus = fs fs.ServiceName = service.ExternalServiceName(src.Name, observerSpec) - deploymentName := load.Name(src.Name, observerSpec) - fs.ResourceNames = rutils.MergeSlices(fs.ResourceNames, []string{deploymentName}) + statefulSetName := load.Name(src.Name, observerSpec) + fs.ResourceNames = rutils.MergeSlices(fs.ResourceNames, []string{statefulSetName}) if err := subcontrollers.UpdateStatus(&fs.StarRocksComponentStatus, fc.Client, - src.Namespace, deploymentName, pod.Labels(src.Name, observerSpec), subcontrollers.DeploymentLoadType); err != nil { + src.Namespace, statefulSetName, pod.Labels(src.Name, observerSpec), subcontrollers.StatefulSetLoadType); err != nil { return err } - var deploy appsv1.Deployment - if err := fc.Client.Get(context.Background(), types.NamespacedName{Namespace: src.Namespace, Name: deploymentName}, &deploy); err != nil { + var st appsv1.StatefulSet + if err := fc.Client.Get(context.Background(), types.NamespacedName{Namespace: src.Namespace, Name: statefulSetName}, &st); err != nil { return err } @@ -183,9 +183,9 @@ func (fc *FeObserverController) ClearCluster(ctx context.Context, src *srapi.Sta } observerSpec := src.Spec.StarRocksFeObserverSpec - deploymentName := load.Name(src.Name, observerSpec) - if err := k8sutils.DeleteDeployment(ctx, fc.Client, src.Namespace, deploymentName); err != nil && !apierrors.IsNotFound(err) { - logger.Error(err, "delete deployment failed", "deploymentName", deploymentName) + statefulSetName := load.Name(src.Name, observerSpec) + if err := k8sutils.DeleteStatefulset(ctx, fc.Client, src.Namespace, statefulSetName); err != nil && !apierrors.IsNotFound(err) { + logger.Error(err, "delete statefulset failed", "statefulSetName", statefulSetName) return err } diff --git a/pkg/subcontrollers/feobserver/feobserver_controller_test.go b/pkg/subcontrollers/feobserver/feobserver_controller_test.go index d37764451..c430a765b 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller_test.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller_test.go @@ -65,7 +65,7 @@ func TestFeObserver_ClearCluster(t *testing.T) { }, } - deploy := appsv1.Deployment{ + sts := appsv1.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ Name: load.Name(src.Name, src.Spec.StarRocksFeObserverSpec), Namespace: "default", @@ -86,12 +86,12 @@ func TestFeObserver_ClearCluster(t *testing.T) { }, } - fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src, &deploy, &svc, &ssvc), fake.GetEventRecorderFor(nil)) + fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src, &sts, &svc, &ssvc), fake.GetEventRecorderFor(nil)) err := fc.ClearCluster(context.Background(), src) require.NoError(t, err) - var ed appsv1.Deployment - err = fc.Client.Get(context.Background(), types.NamespacedName{Name: deploy.Name, Namespace: "default"}, &ed) + var est appsv1.StatefulSet + err = fc.Client.Get(context.Background(), types.NamespacedName{Name: sts.Name, Namespace: "default"}, &est) require.True(t, err == nil || apierrors.IsNotFound(err)) var esvc corev1.Service err = fc.Client.Get(context.Background(), types.NamespacedName{Name: svc.Name, Namespace: "default"}, &esvc) @@ -143,9 +143,9 @@ func TestFeObserver_SyncCluster(t *testing.T) { require.Equal(t, srapi.ComponentReconciling, status.Phase) require.Equal(t, service.ExternalServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), status.ServiceName) - var deploy appsv1.Deployment + var sts appsv1.StatefulSet require.NoError(t, fc.Client.Get(context.Background(), - types.NamespacedName{Name: load.Name(src.Name, src.Spec.StarRocksFeObserverSpec), Namespace: "default"}, &deploy)) + types.NamespacedName{Name: load.Name(src.Name, src.Spec.StarRocksFeObserverSpec), Namespace: "default"}, &sts)) var asvc corev1.Service require.NoError(t, fc.Client.Get(context.Background(), types.NamespacedName{Name: service.ExternalServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), Namespace: "default"}, &asvc)) @@ -153,7 +153,7 @@ func TestFeObserver_SyncCluster(t *testing.T) { require.NoError(t, fc.Client.Get(context.Background(), types.NamespacedName{Name: service.SearchServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), Namespace: "default"}, &rsvc)) - require.Equal(t, asvc.Spec.Selector, deploy.Spec.Selector.MatchLabels) + require.Equal(t, asvc.Spec.Selector, sts.Spec.Selector.MatchLabels) } func TestFeObserver_Ready(t *testing.T) { diff --git a/pkg/subcontrollers/feobserver/feobserver_pod.go b/pkg/subcontrollers/feobserver/feobserver_pod.go index 835d0da42..e790b647f 100644 --- a/pkg/subcontrollers/feobserver/feobserver_pod.go +++ b/pkg/subcontrollers/feobserver/feobserver_pod.go @@ -57,8 +57,12 @@ func (fc *FeObserverController) buildPodTemplate(src *srapi.StarRocksCluster, return nil, err } - feServiceName := service.ExternalServiceName(src.Name, src.Spec.StarRocksFeSpec) + feServiceName := service.ExternalServiceName(src.Name, src.Spec.StarRocksFeObserverSpec) envs := pod.Envs(observerSpec, config, feServiceName, src.Namespace, observerSpec.FeEnvVars) + envs = append(envs, corev1.EnvVar{ + Name: srapi.FE_SERVICE_NAME, + Value: service.ExternalServiceName(src.Name, src.Spec.StarRocksFeSpec), + }) httpPort := rutils.GetPort(config, rutils.HTTP_PORT) feObserverContainer := corev1.Container{ Name: srapi.DEFAULT_FE_OBSERVER, From 983f255c336795bc8b18f5d0711698654ba2e732 Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Tue, 7 Apr 2026 15:06:46 +0800 Subject: [PATCH 09/22] refactor Signed-off-by: zhaohehuhu --- .../starrocks.com_starrocksclusters.yaml | 4434 +---------------- deploy/starrocks.com_starrocksclusters.yaml | 2065 +------- .../starrocks/templates/starrockscluster.yaml | 178 +- .../charts/starrocks/values.yaml | 211 +- helm-charts/charts/kube-starrocks/values.yaml | 211 +- .../starrocks/v1/starrockscluster_types.go | 175 +- .../starrocks/v1/zz_generated.deepcopy.go | 17 +- pkg/k8sutils/templates/pod/spec.go | 2 +- pkg/k8sutils/templates/statefulset/spec.go | 7 + .../feobserver/feobserver_config.go | 4 +- .../feobserver/feobserver_controller.go | 103 +- .../feobserver/feobserver_controller_test.go | 96 +- .../feobserver/feobserver_pod.go | 19 +- 13 files changed, 362 insertions(+), 7160 deletions(-) diff --git a/config/crd/bases/starrocks.com_starrocksclusters.yaml b/config/crd/bases/starrocks.com_starrocksclusters.yaml index 66a67511d..c60987647 100644 --- a/config/crd/bases/starrocks.com_starrocksclusters.yaml +++ b/config/crd/bases/starrocks.com_starrocksclusters.yaml @@ -9450,4424 +9450,6 @@ spec: - Ignore: node taints are ignored. All nodes are included. - If this value is nil, the behavior is equivalent to the Ignore policy. - This is a beta-level feature default enabled by the NodeInclusionPolicyInPodTopologySpread feature flag. - type: string - topologyKey: - description: |- - TopologyKey is the key of node labels. Nodes that have a label with this key - and identical values are considered to be in the same topology. - We consider each as a "bucket", and try to put balanced number - of pods into each bucket. - We define a domain as a particular instance of a topology. - Also, we define an eligible domain as a domain whose nodes meet the requirements of - nodeAffinityPolicy and nodeTaintsPolicy. - e.g. If TopologyKey is "kubernetes.io/hostname", each Node is a domain of that topology. - And, if TopologyKey is "topology.kubernetes.io/zone", each zone is a domain of that topology. - It's a required field. - type: string - whenUnsatisfiable: - description: |- - WhenUnsatisfiable indicates how to deal with a pod if it doesn't satisfy - the spread constraint. - - DoNotSchedule (default) tells the scheduler not to schedule it. - - ScheduleAnyway tells the scheduler to schedule the pod in any location, - but giving higher precedence to topologies that would help reduce the - skew. - A constraint is considered "Unsatisfiable" for an incoming pod - if and only if every possible node assignment for that pod would violate - "MaxSkew" on some topology. - For example, in a 3-zone cluster, MaxSkew is set to 1, and pods with the same - labelSelector spread as 3/1/1: - | zone1 | zone2 | zone3 | - | P P P | P | P | - If WhenUnsatisfiable is set to DoNotSchedule, incoming pod can only be scheduled - to zone2(zone3) to become 3/2/1(3/1/2) as ActualSkew(2-1) on zone2(zone3) satisfies - MaxSkew(1). In other words, the cluster can still be imbalanced, but scheduler - won't make it *more* imbalanced. - It's a required field. - type: string - required: - - maxSkew - - topologyKey - - whenUnsatisfiable - type: object - type: array - updateStrategy: - description: |- - StarRocksCluster use StatefulSet to deploy FE/BE/CN components. - UpdateStrategy indicates the StatefulSetUpdateStrategy that will be - employed to update Pods in the StatefulSet when a revision is made to - Template. See https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#rolling-updates for more details. - Note: The maxUnavailable field is in Alpha stage and it is honored only by API servers that are running with the - MaxUnavailableStatefulSet feature gate enabled. - properties: - rollingUpdate: - description: RollingUpdate is used to communicate parameters - when Type is RollingUpdateStatefulSetStrategyType. - properties: - maxUnavailable: - anyOf: - - type: integer - - type: string - description: |- - The maximum number of pods that can be unavailable during the update. - Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). - Absolute number is calculated from percentage by rounding up. This can not be 0. - Defaults to 1. This field is alpha-level and is only honored by servers that enable the - MaxUnavailableStatefulSet feature. The field applies to all pods in the range 0 to - Replicas-1. That means if there is any unavailable pod in the range 0 to Replicas-1, it - will be counted towards MaxUnavailable. - x-kubernetes-int-or-string: true - partition: - description: |- - Partition indicates the ordinal at which the StatefulSet should be partitioned - for updates. During a rolling update, all pods from ordinal Replicas-1 to - Partition are updated. All pods from ordinal Partition-1 to 0 remain untouched. - This is helpful in being able to do a canary based deployment. The default value is 0. - format: int32 - type: integer - type: object - type: - description: |- - Type indicates the type of the StatefulSetUpdateStrategy. - Default is RollingUpdate. - type: string - type: object - type: object - starRocksFeObserverSpec: - description: StarRocksFeObserverSpec define fe observer configuration - for start fe observer service. - properties: - affinity: - description: If specified, the pod's scheduling constraints. - properties: - nodeAffinity: - description: Describes node affinity scheduling rules for - the pod. - properties: - preferredDuringSchedulingIgnoredDuringExecution: - description: |- - The scheduler will prefer to schedule pods to nodes that satisfy - the affinity expressions specified by this field, but it may choose - a node that violates one or more of the expressions. The node that is - most preferred is the one with the greatest sum of weights, i.e. - for each node that meets all of the scheduling requirements (resource - request, requiredDuringScheduling affinity expressions, etc.), - compute a sum by iterating through the elements of this field and adding - "weight" to the sum if the node matches the corresponding matchExpressions; the - node(s) with the highest sum are the most preferred. - items: - description: |- - An empty preferred scheduling term matches all objects with implicit weight 0 - (i.e. it's a no-op). A null preferred scheduling term matches no objects (i.e. is also a no-op). - properties: - preference: - description: A node selector term, associated with - the corresponding weight. - properties: - matchExpressions: - description: A list of node selector requirements - by node's labels. - items: - description: |- - A node selector requirement is a selector that contains values, a key, and an operator - that relates the key and values. - properties: - key: - description: The label key that the selector - applies to. - type: string - operator: - description: |- - Represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. - type: string - values: - description: |- - An array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. If the operator is Gt or Lt, the values - array must have a single element, which will be interpreted as an integer. - This array is replaced during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchFields: - description: A list of node selector requirements - by node's fields. - items: - description: |- - A node selector requirement is a selector that contains values, a key, and an operator - that relates the key and values. - properties: - key: - description: The label key that the selector - applies to. - type: string - operator: - description: |- - Represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. - type: string - values: - description: |- - An array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. If the operator is Gt or Lt, the values - array must have a single element, which will be interpreted as an integer. - This array is replaced during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - type: object - x-kubernetes-map-type: atomic - weight: - description: Weight associated with matching the - corresponding nodeSelectorTerm, in the range 1-100. - format: int32 - type: integer - required: - - preference - - weight - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - description: |- - If the affinity requirements specified by this field are not met at - scheduling time, the pod will not be scheduled onto the node. - If the affinity requirements specified by this field cease to be met - at some point during pod execution (e.g. due to an update), the system - may or may not try to eventually evict the pod from its node. - properties: - nodeSelectorTerms: - description: Required. A list of node selector terms. - The terms are ORed. - items: - description: |- - A null or empty node selector term matches no objects. The requirements of - them are ANDed. - The TopologySelectorTerm type implements a subset of the NodeSelectorTerm. - properties: - matchExpressions: - description: A list of node selector requirements - by node's labels. - items: - description: |- - A node selector requirement is a selector that contains values, a key, and an operator - that relates the key and values. - properties: - key: - description: The label key that the selector - applies to. - type: string - operator: - description: |- - Represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. - type: string - values: - description: |- - An array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. If the operator is Gt or Lt, the values - array must have a single element, which will be interpreted as an integer. - This array is replaced during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchFields: - description: A list of node selector requirements - by node's fields. - items: - description: |- - A node selector requirement is a selector that contains values, a key, and an operator - that relates the key and values. - properties: - key: - description: The label key that the selector - applies to. - type: string - operator: - description: |- - Represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists, DoesNotExist. Gt, and Lt. - type: string - values: - description: |- - An array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. If the operator is Gt or Lt, the values - array must have a single element, which will be interpreted as an integer. - This array is replaced during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - type: object - x-kubernetes-map-type: atomic - type: array - required: - - nodeSelectorTerms - type: object - x-kubernetes-map-type: atomic - type: object - podAffinity: - description: Describes pod affinity scheduling rules (e.g. - co-locate this pod in the same node, zone, etc. as some - other pod(s)). - properties: - preferredDuringSchedulingIgnoredDuringExecution: - description: |- - The scheduler will prefer to schedule pods to nodes that satisfy - the affinity expressions specified by this field, but it may choose - a node that violates one or more of the expressions. The node that is - most preferred is the one with the greatest sum of weights, i.e. - for each node that meets all of the scheduling requirements (resource - request, requiredDuringScheduling affinity expressions, etc.), - compute a sum by iterating through the elements of this field and adding - "weight" to the sum if the node has pods which matches the corresponding podAffinityTerm; the - node(s) with the highest sum are the most preferred. - items: - description: The weights of all of the matched WeightedPodAffinityTerm - fields are added per-node to find the most preferred - node(s) - properties: - podAffinityTerm: - description: Required. A pod affinity term, associated - with the corresponding weight. - properties: - labelSelector: - description: A label query over a set of resources, - in this case pods. - properties: - matchExpressions: - description: matchExpressions is a list - of label selector requirements. The requirements - are ANDed. - items: - description: |- - A label selector requirement is a selector that contains values, a key, and an operator that - relates the key and values. - properties: - key: - description: key is the label key - that the selector applies to. - type: string - operator: - description: |- - operator represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: |- - values is an array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: |- - matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - map is equivalent to an element of matchExpressions, whose key field is "key", the - operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - namespaceSelector: - description: |- - A label query over the set of namespaces that the term applies to. - The term is applied to the union of the namespaces selected by this field - and the ones listed in the namespaces field. - null selector and null or empty namespaces list means "this pod's namespace". - An empty selector ({}) matches all namespaces. - properties: - matchExpressions: - description: matchExpressions is a list - of label selector requirements. The requirements - are ANDed. - items: - description: |- - A label selector requirement is a selector that contains values, a key, and an operator that - relates the key and values. - properties: - key: - description: key is the label key - that the selector applies to. - type: string - operator: - description: |- - operator represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: |- - values is an array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: |- - matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - map is equivalent to an element of matchExpressions, whose key field is "key", the - operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - namespaces: - description: |- - namespaces specifies a static list of namespace names that the term applies to. - The term is applied to the union of the namespaces listed in this field - and the ones selected by namespaceSelector. - null or empty namespaces list and null namespaceSelector means "this pod's namespace". - items: - type: string - type: array - topologyKey: - description: |- - This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching - the labelSelector in the specified namespaces, where co-located is defined as running on a node - whose value of the label with key topologyKey matches that of any node on which any of the - selected pods is running. - Empty topologyKey is not allowed. - type: string - required: - - topologyKey - type: object - weight: - description: |- - weight associated with matching the corresponding podAffinityTerm, - in the range 1-100. - format: int32 - type: integer - required: - - podAffinityTerm - - weight - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - description: |- - If the affinity requirements specified by this field are not met at - scheduling time, the pod will not be scheduled onto the node. - If the affinity requirements specified by this field cease to be met - at some point during pod execution (e.g. due to a pod label update), the - system may or may not try to eventually evict the pod from its node. - When there are multiple elements, the lists of nodes corresponding to each - podAffinityTerm are intersected, i.e. all terms must be satisfied. - items: - description: |- - Defines a set of pods (namely those matching the labelSelector - relative to the given namespace(s)) that this pod should be - co-located (affinity) or not co-located (anti-affinity) with, - where co-located is defined as running on a node whose value of - the label with key matches that of any node on which - a pod of the set of pods is running - properties: - labelSelector: - description: A label query over a set of resources, - in this case pods. - properties: - matchExpressions: - description: matchExpressions is a list of label - selector requirements. The requirements are - ANDed. - items: - description: |- - A label selector requirement is a selector that contains values, a key, and an operator that - relates the key and values. - properties: - key: - description: key is the label key that - the selector applies to. - type: string - operator: - description: |- - operator represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: |- - values is an array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: |- - matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - map is equivalent to an element of matchExpressions, whose key field is "key", the - operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - namespaceSelector: - description: |- - A label query over the set of namespaces that the term applies to. - The term is applied to the union of the namespaces selected by this field - and the ones listed in the namespaces field. - null selector and null or empty namespaces list means "this pod's namespace". - An empty selector ({}) matches all namespaces. - properties: - matchExpressions: - description: matchExpressions is a list of label - selector requirements. The requirements are - ANDed. - items: - description: |- - A label selector requirement is a selector that contains values, a key, and an operator that - relates the key and values. - properties: - key: - description: key is the label key that - the selector applies to. - type: string - operator: - description: |- - operator represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: |- - values is an array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: |- - matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - map is equivalent to an element of matchExpressions, whose key field is "key", the - operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - namespaces: - description: |- - namespaces specifies a static list of namespace names that the term applies to. - The term is applied to the union of the namespaces listed in this field - and the ones selected by namespaceSelector. - null or empty namespaces list and null namespaceSelector means "this pod's namespace". - items: - type: string - type: array - topologyKey: - description: |- - This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching - the labelSelector in the specified namespaces, where co-located is defined as running on a node - whose value of the label with key topologyKey matches that of any node on which any of the - selected pods is running. - Empty topologyKey is not allowed. - type: string - required: - - topologyKey - type: object - type: array - type: object - podAntiAffinity: - description: Describes pod anti-affinity scheduling rules - (e.g. avoid putting this pod in the same node, zone, etc. - as some other pod(s)). - properties: - preferredDuringSchedulingIgnoredDuringExecution: - description: |- - The scheduler will prefer to schedule pods to nodes that satisfy - the anti-affinity expressions specified by this field, but it may choose - a node that violates one or more of the expressions. The node that is - most preferred is the one with the greatest sum of weights, i.e. - for each node that meets all of the scheduling requirements (resource - request, requiredDuringScheduling anti-affinity expressions, etc.), - compute a sum by iterating through the elements of this field and adding - "weight" to the sum if the node has pods which matches the corresponding podAffinityTerm; the - node(s) with the highest sum are the most preferred. - items: - description: The weights of all of the matched WeightedPodAffinityTerm - fields are added per-node to find the most preferred - node(s) - properties: - podAffinityTerm: - description: Required. A pod affinity term, associated - with the corresponding weight. - properties: - labelSelector: - description: A label query over a set of resources, - in this case pods. - properties: - matchExpressions: - description: matchExpressions is a list - of label selector requirements. The requirements - are ANDed. - items: - description: |- - A label selector requirement is a selector that contains values, a key, and an operator that - relates the key and values. - properties: - key: - description: key is the label key - that the selector applies to. - type: string - operator: - description: |- - operator represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: |- - values is an array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: |- - matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - map is equivalent to an element of matchExpressions, whose key field is "key", the - operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - namespaceSelector: - description: |- - A label query over the set of namespaces that the term applies to. - The term is applied to the union of the namespaces selected by this field - and the ones listed in the namespaces field. - null selector and null or empty namespaces list means "this pod's namespace". - An empty selector ({}) matches all namespaces. - properties: - matchExpressions: - description: matchExpressions is a list - of label selector requirements. The requirements - are ANDed. - items: - description: |- - A label selector requirement is a selector that contains values, a key, and an operator that - relates the key and values. - properties: - key: - description: key is the label key - that the selector applies to. - type: string - operator: - description: |- - operator represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: |- - values is an array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: |- - matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - map is equivalent to an element of matchExpressions, whose key field is "key", the - operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - namespaces: - description: |- - namespaces specifies a static list of namespace names that the term applies to. - The term is applied to the union of the namespaces listed in this field - and the ones selected by namespaceSelector. - null or empty namespaces list and null namespaceSelector means "this pod's namespace". - items: - type: string - type: array - topologyKey: - description: |- - This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching - the labelSelector in the specified namespaces, where co-located is defined as running on a node - whose value of the label with key topologyKey matches that of any node on which any of the - selected pods is running. - Empty topologyKey is not allowed. - type: string - required: - - topologyKey - type: object - weight: - description: |- - weight associated with matching the corresponding podAffinityTerm, - in the range 1-100. - format: int32 - type: integer - required: - - podAffinityTerm - - weight - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - description: |- - If the anti-affinity requirements specified by this field are not met at - scheduling time, the pod will not be scheduled onto the node. - If the anti-affinity requirements specified by this field cease to be met - at some point during pod execution (e.g. due to a pod label update), the - system may or may not try to eventually evict the pod from its node. - When there are multiple elements, the lists of nodes corresponding to each - podAffinityTerm are intersected, i.e. all terms must be satisfied. - items: - description: |- - Defines a set of pods (namely those matching the labelSelector - relative to the given namespace(s)) that this pod should be - co-located (affinity) or not co-located (anti-affinity) with, - where co-located is defined as running on a node whose value of - the label with key matches that of any node on which - a pod of the set of pods is running - properties: - labelSelector: - description: A label query over a set of resources, - in this case pods. - properties: - matchExpressions: - description: matchExpressions is a list of label - selector requirements. The requirements are - ANDed. - items: - description: |- - A label selector requirement is a selector that contains values, a key, and an operator that - relates the key and values. - properties: - key: - description: key is the label key that - the selector applies to. - type: string - operator: - description: |- - operator represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: |- - values is an array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: |- - matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - map is equivalent to an element of matchExpressions, whose key field is "key", the - operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - namespaceSelector: - description: |- - A label query over the set of namespaces that the term applies to. - The term is applied to the union of the namespaces selected by this field - and the ones listed in the namespaces field. - null selector and null or empty namespaces list means "this pod's namespace". - An empty selector ({}) matches all namespaces. - properties: - matchExpressions: - description: matchExpressions is a list of label - selector requirements. The requirements are - ANDed. - items: - description: |- - A label selector requirement is a selector that contains values, a key, and an operator that - relates the key and values. - properties: - key: - description: key is the label key that - the selector applies to. - type: string - operator: - description: |- - operator represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: |- - values is an array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: |- - matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - map is equivalent to an element of matchExpressions, whose key field is "key", the - operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - namespaces: - description: |- - namespaces specifies a static list of namespace names that the term applies to. - The term is applied to the union of the namespaces listed in this field - and the ones selected by namespaceSelector. - null or empty namespaces list and null namespaceSelector means "this pod's namespace". - items: - type: string - type: array - topologyKey: - description: |- - This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching - the labelSelector in the specified namespaces, where co-located is defined as running on a node - whose value of the label with key topologyKey matches that of any node on which any of the - selected pods is running. - Empty topologyKey is not allowed. - type: string - required: - - topologyKey - type: object - type: array - type: object - type: object - annotations: - additionalProperties: - type: string - description: annotation for pods. user can config monitor annotation - for collect to monitor system. - type: object - args: - description: |- - Arguments to the entrypoint. - If this is not provided, it will use $(FE_SERVICE_NAME) for all components. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - capabilities: - description: |- - refer to https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-capabilities-for-a-container - grant certain privileges to a process without granting all the privileges of the root user - properties: - add: - description: Added capabilities - items: - description: Capability represent POSIX capabilities type - type: string - type: array - drop: - description: Removed capabilities - items: - description: Capability represent POSIX capabilities type - type: string - type: array - type: object - claims: - description: |- - Claims lists the names of resources, defined in spec.resourceClaims, - that are used by this container. - - - This is an alpha field and requires enabling the - DynamicResourceAllocation feature gate. - - - This field is immutable. - items: - description: ResourceClaim references one entry in PodSpec.ResourceClaims. - properties: - name: - description: |- - Name must match the name of one entry in pod.spec.resourceClaims of - the Pod where this field is used. It makes that resource available - inside a container. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - command: - description: "Entrypoint array. Not executed within a shell.\nIf - this is not provided, it will use default entrypoint for different - components:\n\t1. For FE, it will use /opt/starrocks/fe_entrypoint.sh - as the entrypoint.\n 2. For BE, it will use /opt/starrocks/be_entrypoint.sh - as the entrypoint.\n 3. For CN, it will use /opt/starrocks/cn_entrypoint.sh - as the entrypoint.\nMore info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell" - items: - type: string - type: array - configMapInfo: - description: the reference for configMap which store the config - info to start starrocks. e.g. be.conf, fe.conf, cn.conf. - properties: - configMapName: - description: the config info for start progress. - type: string - resolveKey: - description: the config response key in configmap. - type: string - type: object - configMaps: - description: the reference for configMap which allow users to - mount any files to container. - items: - description: |- - MountInfo - The reason why we do not support defaultMode is that we use hash.HashObject to - calculate the actual volume name. This volume name is used in pod template of statefulset, - and if this MountInfo type has been changed, the volume name will be changed too, and - that will make pods restart. - The default mode is 0644, and in order to support to set permission information for a configMap - or secret, we add should specify the subPath and specify a command or args in the container. - And It will be set 0755. - properties: - mountPath: - description: |- - Path within the container at which the volume should be mounted. Must - not contain ':'. - type: string - name: - description: |- - This must match the Name of a ConfigMap or Secret in the same namespace, and - the length of name must not more than 50 characters. - type: string - subPath: - description: |- - SubPath within the volume from which the container's volume should be mounted. - Defaults to "" (volume's root). - type: string - type: object - type: array - feEnvVars: - description: feEnvVars is a slice of environment variables that - are added to the pods, the default is empty. - items: - description: EnvVar represents an environment variable present - in a Container. - properties: - name: - description: Name of the environment variable. Must be a - C_IDENTIFIER. - type: string - value: - description: |- - Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in the container and - any service environment variables. If a variable cannot be resolved, - the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether the variable - exists or not. - Defaults to "". - type: string - valueFrom: - description: Source for the environment variable's value. - Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap or its - key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: |- - Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, - spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. - properties: - apiVersion: - description: Version of the schema the FieldPath - is written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in the - specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: |- - Selects a resource of the container: only resources limits and requests - (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. - properties: - containerName: - description: 'Container name: required for volumes, - optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format of the - exposed resources, defaults to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in the pod's - namespace - properties: - key: - description: The key of the secret to select from. Must - be a valid secret key. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret or its key - must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - hostAliases: - description: |- - HostAliases is an optional list of hosts and IPs that will be injected into the pod's hosts - file if specified. This is only valid for non-hostNetwork pods. - items: - description: |- - HostAlias holds the mapping between IP and hostnames that will be injected as an entry in the - pod's hosts file. - properties: - hostnames: - description: Hostnames for the above IP address. - items: - type: string - type: array - ip: - description: IP address of the host file entry. - type: string - type: object - type: array - image: - description: Image for a starrocks deployment. - type: string - imagePullPolicy: - description: |- - Image pull policy. - One of Always, Never, IfNotPresent. - Defaults to IfNotPresent for compatibility. - More info: https://kubernetes.io/docs/concepts/containers/images#updating-images - type: string - imagePullSecrets: - description: |- - ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the - images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for - them to use. - More info: https://kubernetes.io/docs/concepts/containers/images#specifying-imagepullsecrets-on-a-pod - items: - description: |- - LocalObjectReference contains enough information to let you locate the - referenced object inside the same namespace. - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - type: object - x-kubernetes-map-type: atomic - type: array - initContainers: - description: |- - InitContainers is an optional list of containers that are run in the same pod as the starrocks component. - You can use this field to launch helper containers that run before the main container starts. - See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to configure a container. - items: - description: A single application container that you want to - run within a pod. - properties: - args: - description: |- - Arguments to the entrypoint. - The container image's CMD is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - command: - description: |- - Entrypoint array. Not executed within a shell. - The container image's ENTRYPOINT is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - env: - description: |- - List of environment variables to set in the container. - Cannot be updated. - items: - description: EnvVar represents an environment variable - present in a Container. - properties: - name: - description: Name of the environment variable. Must - be a C_IDENTIFIER. - type: string - value: - description: |- - Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in the container and - any service environment variables. If a variable cannot be resolved, - the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether the variable - exists or not. - Defaults to "". - type: string - valueFrom: - description: Source for the environment variable's - value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: |- - Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, - spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. - properties: - apiVersion: - description: Version of the schema the FieldPath - is written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in - the specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: |- - Selects a resource of the container: only resources limits and requests - (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. - properties: - containerName: - description: 'Container name: required for - volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format of - the exposed resources, defaults to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in the - pod's namespace - properties: - key: - description: The key of the secret to select - from. Must be a valid secret key. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret or - its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - envFrom: - description: |- - List of sources to populate environment variables in the container. - The keys defined within a source must be a C_IDENTIFIER. All invalid keys - will be reported as an event when the container is starting. When a key exists in multiple - sources, the value associated with the last source will take precedence. - Values defined by an Env with a duplicate key will take precedence. - Cannot be updated. - items: - description: EnvFromSource represents the source of a - set of ConfigMaps - properties: - configMapRef: - description: The ConfigMap to select from - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap must - be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - prefix: - description: An optional identifier to prepend to - each key in the ConfigMap. Must be a C_IDENTIFIER. - type: string - secretRef: - description: The Secret to select from - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret must be - defined - type: boolean - type: object - x-kubernetes-map-type: atomic - type: object - type: array - image: - description: |- - Container image name. - More info: https://kubernetes.io/docs/concepts/containers/images - This field is optional to allow higher level config management to default or override - container images in workload controllers like Deployments and StatefulSets. - type: string - imagePullPolicy: - description: |- - 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 - type: string - lifecycle: - description: |- - Actions that the management system should take in response to container lifecycle events. - Cannot be updated. - properties: - postStart: - description: |- - PostStart is called immediately after a container is created. If the handler fails, - the container is terminated and restarted according to its restart policy. - Other management of the container blocks until the hook completes. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - preStop: - description: |- - PreStop is called immediately before a container is terminated due to an - API request or management event such as liveness/startup probe failure, - preemption, resource contention, etc. The handler is not called if the - container crashes or exits. The Pod's termination grace period countdown begins before the - PreStop hook is executed. Regardless of the outcome of the handler, the - container will eventually terminate within the Pod's termination grace - period (unless delayed by finalizers). Other management of the container blocks until the hook completes - or until the termination grace period is reached. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - type: object - livenessProbe: - description: |- - Periodic probe of container liveness. - Container will be restarted if the probe fails. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: |- - GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe feature gate. - properties: - port: - description: Port number of the gRPC service. Number - must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom header - to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect to, - defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - name: - description: |- - Name of the container specified as a DNS_LABEL. - Each container in a pod must have a unique name (DNS_LABEL). - Cannot be updated. - type: string - ports: - description: |- - List of ports to expose from the container. Not specifying a port here - DOES NOT prevent that port from being exposed. Any port which is - listening on the default "0.0.0.0" address inside a container will be - accessible from the network. - Modifying this array with strategic merge patch may corrupt the data. - For more information See https://github.com/kubernetes/kubernetes/issues/108255. - Cannot be updated. - items: - description: ContainerPort represents a network port in - a single container. - properties: - containerPort: - description: |- - Number of port to expose on the pod's IP address. - This must be a valid port number, 0 < x < 65536. - format: int32 - type: integer - hostIP: - description: What host IP to bind the external port - to. - type: string - hostPort: - description: |- - Number of port to expose on the host. - If specified, this must be a valid port number, 0 < x < 65536. - If HostNetwork is specified, this must match ContainerPort. - Most containers do not need this. - format: int32 - type: integer - name: - description: |- - If specified, this must be an IANA_SVC_NAME and unique within the pod. Each - named port in a pod must have a unique name. Name for the port that can be - referred to by services. - type: string - protocol: - default: TCP - description: |- - Protocol for port. Must be UDP, TCP, or SCTP. - Defaults to "TCP". - type: string - required: - - containerPort - type: object - type: array - x-kubernetes-list-map-keys: - - containerPort - - protocol - x-kubernetes-list-type: map - readinessProbe: - description: |- - Periodic probe of container service readiness. - Container will be removed from service endpoints if the probe fails. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: |- - GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe feature gate. - properties: - port: - description: Port number of the gRPC service. Number - must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom header - to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect to, - defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - resources: - description: |- - Compute Resources required by this container. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - properties: - claims: - description: |- - Claims lists the names of resources, defined in spec.resourceClaims, - that are used by this container. - - - This is an alpha field and requires enabling the - DynamicResourceAllocation feature gate. - - - This field is immutable. - items: - description: ResourceClaim references one entry in - PodSpec.ResourceClaims. - properties: - name: - description: |- - Name must match the name of one entry in pod.spec.resourceClaims of - the Pod where this field is used. It makes that resource available - inside a container. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Limits describes the maximum amount of compute resources allowed. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Requests describes the minimum amount of compute resources required. - If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, - otherwise to an implementation-defined value. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - type: object - securityContext: - description: |- - SecurityContext defines the security options the container should be run with. - If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. - More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ - properties: - allowPrivilegeEscalation: - description: |- - AllowPrivilegeEscalation controls whether a process can gain more - privileges than its parent process. This bool directly controls if - the no_new_privs flag will be set on the container process. - AllowPrivilegeEscalation is true always when the container is: - 1) run as Privileged - 2) has CAP_SYS_ADMIN - Note that this field cannot be set when spec.os.name is windows. - type: boolean - capabilities: - description: |- - The capabilities to add/drop when running containers. - Defaults to the default set of capabilities granted by the container runtime. - Note that this field cannot be set when spec.os.name is windows. - properties: - add: - description: Added capabilities - items: - description: Capability represent POSIX capabilities - type - type: string - type: array - drop: - description: Removed capabilities - items: - description: Capability represent POSIX capabilities - type - type: string - type: array - type: object - privileged: - description: |- - Run container in privileged mode. - Processes in privileged containers are essentially equivalent to root on the host. - Defaults to false. - Note that this field cannot be set when spec.os.name is windows. - type: boolean - procMount: - description: |- - procMount denotes the type of proc mount to use for the containers. - The default is DefaultProcMount which uses the container runtime defaults for - readonly paths and masked paths. - This requires the ProcMountType feature flag to be enabled. - Note that this field cannot be set when spec.os.name is windows. - type: string - readOnlyRootFilesystem: - description: |- - Whether this container has a read-only root filesystem. - Default is false. - Note that this field cannot be set when spec.os.name is windows. - type: boolean - runAsGroup: - description: |- - The GID to run the entrypoint of the container process. - Uses runtime default if unset. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - runAsNonRoot: - description: |- - Indicates that the container must run as a non-root user. - If true, the Kubelet will validate the image at runtime to ensure that it - does not run as UID 0 (root) and fail to start the container if it does. - If unset or false, no such validation will be performed. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - type: boolean - runAsUser: - description: |- - The UID to run the entrypoint of the container process. - Defaults to user specified in image metadata if unspecified. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - seLinuxOptions: - description: |- - The SELinux context to be applied to the container. - If unspecified, the container runtime will allocate a random SELinux context for each - container. May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - properties: - level: - description: Level is SELinux level label that applies - to the container. - type: string - role: - description: Role is a SELinux role label that applies - to the container. - type: string - type: - description: Type is a SELinux type label that applies - to the container. - type: string - user: - description: User is a SELinux user label that applies - to the container. - type: string - type: object - seccompProfile: - description: |- - The seccomp options to use by this container. If seccomp options are - provided at both the pod & container level, the container options - override the pod options. - Note that this field cannot be set when spec.os.name is windows. - properties: - localhostProfile: - description: |- - localhostProfile indicates a profile defined in a file on the node should be used. - The profile must be preconfigured on the node to work. - Must be a descending path, relative to the kubelet's configured seccomp profile location. - Must only be set if type is "Localhost". - type: string - type: - description: |- - type indicates which kind of seccomp profile will be applied. - Valid options are: - - - Localhost - a profile defined in a file on the node should be used. - RuntimeDefault - the container runtime default profile should be used. - Unconfined - no profile should be applied. - type: string - required: - - type - type: object - windowsOptions: - description: |- - The Windows specific settings applied to all containers. - If unspecified, the options from the PodSecurityContext will be used. - If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is linux. - properties: - gmsaCredentialSpec: - description: |- - GMSACredentialSpec is where the GMSA admission webhook - (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the - GMSA credential spec named by the GMSACredentialSpecName field. - type: string - gmsaCredentialSpecName: - description: GMSACredentialSpecName is the name - of the GMSA credential spec to use. - type: string - hostProcess: - description: |- - HostProcess determines if a container should be run as a 'Host Process' container. - This field is alpha-level and will only be honored by components that enable the - WindowsHostProcessContainers feature flag. Setting this field without the feature - flag will result in errors when validating the Pod. All of a Pod's containers must - have the same effective HostProcess value (it is not allowed to have a mix of HostProcess - containers and non-HostProcess containers). In addition, if HostProcess is true - then HostNetwork must also be set to true. - type: boolean - runAsUserName: - description: |- - The UserName in Windows to run the entrypoint of the container process. - Defaults to the user specified in image metadata if unspecified. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - type: string - type: object - type: object - startupProbe: - description: |- - StartupProbe indicates that the Pod has successfully initialized. - If specified, no other probes are executed until this completes successfully. - If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. - This can be used to provide different probe parameters at the beginning of a Pod's lifecycle, - when it might take a long time to load data or warm a cache, than during steady-state operation. - This cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: |- - GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe feature gate. - properties: - port: - description: Port number of the gRPC service. Number - must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom header - to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect to, - defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - stdin: - description: |- - Whether this container should allocate a buffer for stdin in the container runtime. If this - is not set, reads from stdin in the container will always result in EOF. - Default is false. - type: boolean - stdinOnce: - description: |- - Whether the container runtime should close the stdin channel after it has been opened by - a single attach. When stdin is true the stdin stream will remain open across multiple attach - sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the - first client attaches to stdin, and then remains open and accepts data until the client disconnects, - at which time stdin is closed and remains closed until the container is restarted. If this - flag is false, a container processes that reads from stdin will never receive an EOF. - Default is false - type: boolean - terminationMessagePath: - description: |- - Optional: Path at which the file to which the container's termination message - will be written is mounted into the container's filesystem. - Message written is intended to be brief final status, such as an assertion failure message. - Will be truncated by the node if greater than 4096 bytes. The total message length across - all containers will be limited to 12kb. - Defaults to /dev/termination-log. - Cannot be updated. - type: string - terminationMessagePolicy: - description: |- - Indicate how the termination message should be populated. File will use the contents of - terminationMessagePath to populate the container status message on both success and failure. - FallbackToLogsOnError will use the last chunk of container log output if the termination - message file is empty and the container exited with an error. - The log output is limited to 2048 bytes or 80 lines, whichever is smaller. - Defaults to File. - Cannot be updated. - type: string - tty: - description: |- - Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. - Default is false. - type: boolean - volumeDevices: - description: volumeDevices is the list of block devices - to be used by the container. - items: - description: volumeDevice describes a mapping of a raw - block device within a container. - properties: - devicePath: - description: devicePath is the path inside of the - container that the device will be mapped to. - type: string - name: - description: name must match the name of a persistentVolumeClaim - in the pod - type: string - required: - - devicePath - - name - type: object - type: array - volumeMounts: - description: |- - Pod volumes to mount into the container's filesystem. - Cannot be updated. - items: - description: VolumeMount describes a mounting of a Volume - within a container. - properties: - mountPath: - description: |- - Path within the container at which the volume should be mounted. Must - not contain ':'. - type: string - mountPropagation: - description: |- - mountPropagation determines how mounts are propagated from the host - to container and the other way around. - When not set, MountPropagationNone is used. - This field is beta in 1.10. - type: string - name: - description: This must match the Name of a Volume. - type: string - readOnly: - description: |- - Mounted read-only if true, read-write otherwise (false or unspecified). - Defaults to false. - type: boolean - subPath: - description: |- - Path within the volume from which the container's volume should be mounted. - Defaults to "" (volume's root). - type: string - subPathExpr: - description: |- - Expanded path within the volume from which the container's volume should be mounted. - Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. - Defaults to "" (volume's root). - SubPathExpr and SubPath are mutually exclusive. - type: string - required: - - mountPath - - name - type: object - type: array - workingDir: - description: |- - Container's working directory. - If not specified, the container runtime's default will be used, which - might be configured in the container image. - Cannot be updated. - type: string - required: - - name - type: object - type: array - lifecycle: - description: |- - Lifecycle describes actions that the management system should take in response to container lifecycle events. - By default, Operator will add corresponding preStop hooks for different components. For example, the preStop - script for the FE Component is /opt/starrocks/fe_prestop.sh, for the BE Component is /opt/starrocks/be_prestop.sh, - and for the CN Component is /opt/starrocks/cn_prestop.sh. - properties: - postStart: - description: |- - PostStart is called immediately after a container is created. If the handler fails, - the container is terminated and restarted according to its restart policy. - Other management of the container blocks until the hook completes. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom header - to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect to, defaults - to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - preStop: - description: |- - PreStop is called immediately before a container is terminated due to an - API request or management event such as liveness/startup probe failure, - preemption, resource contention, etc. The handler is not called if the - container crashes or exits. The Pod's termination grace period countdown begins before the - PreStop hook is executed. Regardless of the outcome of the handler, the - container will eventually terminate within the Pod's termination grace - period (unless delayed by finalizers). Other management of the container blocks until the hook completes - or until the termination grace period is reached. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom header - to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect to, defaults - to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - type: object - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Limits describes the maximum amount of compute resources allowed. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - livenessProbeFailureSeconds: - description: |- - LivenessProbeFailureSeconds defines the total failure seconds of liveness Probe. - Default failureThreshold is 3 and the periodSeconds is 5, this means the liveness - will fail if the pod can't respond in 15 seconds. Your LivenessProbeFailureSeconds is - the total time of seconds before the container restart. If LivenessProbeFailureSeconds - can't be divided by defaultPeriodSeconds, the failureThreshold will be rounded up. - Note: you can set it to 0 to disable the liveness probe. - format: int32 - type: integer - minReadySeconds: - description: |- - MinReadySeconds specifies the minimum number of seconds for which a newly created pod should be ready - without any of its container crashing, for it to be considered available. - Defaults to 0 (pod will be considered available as soon as it is ready). - format: int32 - type: integer - nodeSelector: - additionalProperties: - type: string - description: (Optional) If specified, the pod's nodeSelector,displayName="Map - of nodeSelectors to match when scheduling pods on nodes" - type: object - persistentVolumeClaimRetentionPolicy: - description: |- - PersistentVolumeClaimRetentionPolicy specifies the retention policy for PersistentVolumeClaims associated with the component. - The WhenDeleted field is supported for all components, and it determines whether to delete PVCs when the StatefulSet is deleted. - The WhenScaled field is only supported for the CN component. - properties: - whenDeleted: - description: |- - WhenDeleted specifies what happens to PVCs created from StatefulSet - VolumeClaimTemplates when the StatefulSet is deleted. The default policy - of `Retain` causes PVCs to not be affected by StatefulSet deletion. The - `Delete` policy causes those PVCs to be deleted. - type: string - whenScaled: - description: |- - WhenScaled specifies what happens to PVCs created from StatefulSet - VolumeClaimTemplates when the StatefulSet is scaled down. The default - policy of `Retain` causes PVCs to not be affected by a scaledown. The - `Delete` policy causes the associated PVCs for any excess pods above - the replica count to be deleted. - type: string - type: object - podLabels: - additionalProperties: - type: string - description: the pod labels for user select or classify pods. - type: object - podManagementPolicy: - description: |- - podManagementPolicy controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down. - The default policy is Parallel which is not the same as statefulset's default policy which maybe a not a good choice - to use a different default value. - type: string - readOnlyRootFilesystem: - description: "Whether this container has a read-only root filesystem.\nDefault - is false.\nNote that:\n\t1. This field cannot be set when spec.os.name - is windows.\n\t2. The FE/BE/CN container should support read-only - root filesystem. The newest version of FE/BE/CN is 3.3.6,\n - \ and does not support read-only root filesystem" - type: boolean - readinessProbeFailureSeconds: - description: |- - ReadinessProbeFailureSeconds defines the total failure seconds of readiness Probe. - Default failureThreshold is 3 and the periodSeconds is 5, this means the readiness - will fail if the pod can't respond in 15 seconds. Your ReadinessProbeFailureSeconds is - the total time of seconds before pods becomes not ready. If ReadinessProbeFailureSeconds - can't be divided by defaultPeriodSeconds, the failureThreshold will be rounded up. - Note: you can set it to 0 to disable the readiness probe. - format: int32 - type: integer - replicas: - default: 1 - description: |- - Replicas is the number of desired Pods. - When HPA policy is enabled with a fixed replica count in StarRocksCnSpec: every time - the starrockscluster CR is applied, the replica count of the StatefulSet - object in K8S will be reset to the value specified by the 'Replicas' - field, erasing the value previously set by HPA. - format: int32 - minimum: 0 - type: integer - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Requests describes the minimum amount of compute resources required. - If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, - otherwise to an implementation-defined value. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - runAsNonRoot: - description: |- - RunAsNonRoot is used to determine whether to run starrocks as a normal user. - If RunAsNonRoot is true, operator will set RunAsUser and RunAsGroup to 1000 in securityContext. - default: nil - type: boolean - schedulerName: - description: SchedulerName is the name of the kubernetes scheduler - that will be used to schedule the pods. - type: string - secrets: - description: the reference for secrets. - items: - description: |- - MountInfo - The reason why we do not support defaultMode is that we use hash.HashObject to - calculate the actual volume name. This volume name is used in pod template of statefulset, - and if this MountInfo type has been changed, the volume name will be changed too, and - that will make pods restart. - The default mode is 0644, and in order to support to set permission information for a configMap - or secret, we add should specify the subPath and specify a command or args in the container. - And It will be set 0755. - properties: - mountPath: - description: |- - Path within the container at which the volume should be mounted. Must - not contain ':'. - type: string - name: - description: |- - This must match the Name of a ConfigMap or Secret in the same namespace, and - the length of name must not more than 50 characters. - type: string - subPath: - description: |- - SubPath within the volume from which the container's volume should be mounted. - Defaults to "" (volume's root). - type: string - type: object - type: array - service: - description: Service defines the template for the associated Kubernetes - Service object. - properties: - annotations: - additionalProperties: - type: string - description: |- - Annotations' store Kubernetes Service annotations. These will be added to the external service - only (not internal). - type: object - labels: - additionalProperties: - type: string - description: |- - Labels store Kubernetes Service labels. These will be added to the external service only (not - internal). StarRocks may add its own default labels. - type: object - loadBalancerIP: - description: |- - Only applies to Service Type: LoadBalancer. - This feature depends on whether the underlying cloud-provider supports specifying - the loadBalancerIP when a load balancer is created. - This field will be ignored if the cloud-provider does not support the feature. - This field was under-specified and its meaning varies across implementations, - and it cannot support dual-stack. - As of Kubernetes v1.24, users are encouraged to use implementation-specific annotations when available. - This field may be removed in a future API version. - type: string - loadBalancerSourceRanges: - description: |- - If specified and supported by the platform, this will restrict traffic through the cloud-provider - load-balancer will be restricted to the specified client IPs. This field will be ignored if the - cloud-provider does not support the feature. - More info: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/ - items: - type: string - type: array - ports: - description: |- - Ports are the ports that are exposed by this service. - You can override the default port information by specifying the same StarRocksServicePort.Name in the ports list. - e.g. if you want to use a dedicated node port, you can just specify the StarRocksServicePort.Name and - StarRocksServicePort.NodePort field. - items: - description: |- - StarRocksServicePort defines the port that will be exposed by this service. - To assign a specific port or nodePort to a service, you should specify them by the corresponding name or - containerPort in the service configuration. If both containerPort and name are specified, containerPort takes precedence. - properties: - containerPort: - description: |- - ContainerPort of the service port. - For fe, port name can be http, query, rpc, edit-log, and their default container port is 8030, 9030, 9020, 9010. - For be, port name can be webserver, heartbeat, brpc, be, and their default container port is 8040, 9050, 8060, 9060. - For cn, port name can be webserver, heartbeat, brpc, thrift, and their default container port is 8040, 9050, 8060, 9060. - For fe proxy, port name can be http-port, and its default container port is 8080. - format: int32 - type: integer - name: - description: |- - Name of this port within the service. - For fe, port name can be http, query, rpc, edit-log, and their default container port is 8030, 9030, 9020, 9010. - For be, port name can be webserver, heartbeat, brpc, be, and their default container port is 8040, 9050, 8060, 9060. - For cn, port name can be webserver, heartbeat, brpc, thrift, and their default container port is 8040, 9050, 8060, 9060. - For fe proxy, port name can be http-port, and its default container port is 8080. - type: string - nodePort: - description: |- - NodePort is used to specify the port on each node on which the service is exposed. - The range of valid ports is 30000-32767 - format: int32 - type: integer - port: - description: Port that will be exposed by this service. - format: int32 - type: integer - type: object - type: array - type: - description: |- - type of service,the possible value for the service type are : ClusterIP, NodePort, LoadBalancer,ExternalName. - More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types - type: string - type: object - serviceAccount: - description: serviceAccount for access cloud service. - type: string - shareProcessNamespace: - description: |- - Share a single process namespace between all of the containers in a pod. - When this is set containers will be able to view and signal processes from other containers - in the same pod, and the first process in each container will not be assigned PID 1. - Optional: Default to false. - type: boolean - sidecars: - description: |- - Sidecars is an optional list of containers that are run in the same pod as the starrocks component. - You can use this field to launch helper containers that provide additional functionality to the main container. - See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to configure a container. - items: - description: A single application container that you want to - run within a pod. - properties: - args: - description: |- - Arguments to the entrypoint. - The container image's CMD is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - command: - description: |- - Entrypoint array. Not executed within a shell. - The container image's ENTRYPOINT is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - of whether the variable exists or not. Cannot be updated. - More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - items: - type: string - type: array - env: - description: |- - List of environment variables to set in the container. - Cannot be updated. - items: - description: EnvVar represents an environment variable - present in a Container. - properties: - name: - description: Name of the environment variable. Must - be a C_IDENTIFIER. - type: string - value: - description: |- - Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in the container and - any service environment variables. If a variable cannot be resolved, - the reference in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether the variable - exists or not. - Defaults to "". - type: string - valueFrom: - description: Source for the environment variable's - value. Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap - or its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: |- - Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['']`, `metadata.annotations['']`, - spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs. - properties: - apiVersion: - description: Version of the schema the FieldPath - is written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in - the specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: |- - Selects a resource of the container: only resources limits and requests - (limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported. - properties: - containerName: - description: 'Container name: required for - volumes, optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format of - the exposed resources, defaults to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in the - pod's namespace - properties: - key: - description: The key of the secret to select - from. Must be a valid secret key. - type: string - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret or - its key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - envFrom: - description: |- - List of sources to populate environment variables in the container. - The keys defined within a source must be a C_IDENTIFIER. All invalid keys - will be reported as an event when the container is starting. When a key exists in multiple - sources, the value associated with the last source will take precedence. - Values defined by an Env with a duplicate key will take precedence. - Cannot be updated. - items: - description: EnvFromSource represents the source of a - set of ConfigMaps - properties: - configMapRef: - description: The ConfigMap to select from - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the ConfigMap must - be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - prefix: - description: An optional identifier to prepend to - each key in the ConfigMap. Must be a C_IDENTIFIER. - type: string - secretRef: - description: The Secret to select from - properties: - name: - description: |- - Name of the referent. - More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid? - type: string - optional: - description: Specify whether the Secret must be - defined - type: boolean - type: object - x-kubernetes-map-type: atomic - type: object - type: array - image: - description: |- - Container image name. - More info: https://kubernetes.io/docs/concepts/containers/images - This field is optional to allow higher level config management to default or override - container images in workload controllers like Deployments and StatefulSets. - type: string - imagePullPolicy: - description: |- - 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 - type: string - lifecycle: - description: |- - Actions that the management system should take in response to container lifecycle events. - Cannot be updated. - properties: - postStart: - description: |- - PostStart is called immediately after a container is created. If the handler fails, - the container is terminated and restarted according to its restart policy. - Other management of the container blocks until the hook completes. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - preStop: - description: |- - PreStop is called immediately before a container is terminated due to an - API request or management event such as liveness/startup probe failure, - preemption, resource contention, etc. The handler is not called if the - container crashes or exits. The Pod's termination grace period countdown begins before the - PreStop hook is executed. Regardless of the outcome of the handler, the - container will eventually terminate within the Pod's termination grace - period (unless delayed by finalizers). Other management of the container blocks until the hook completes - or until the termination grace period is reached. - More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request - to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom - header to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: |- - Deprecated. TCPSocket is NOT supported as a LifecycleHandler and kept - for the backward compatibility. There are no validation of this field and - lifecycle hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect - to, defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - type: object - livenessProbe: - description: |- - Periodic probe of container liveness. - Container will be restarted if the probe fails. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: |- - GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe feature gate. - properties: - port: - description: Port number of the gRPC service. Number - must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom header - to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect to, - defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - name: - description: |- - Name of the container specified as a DNS_LABEL. - Each container in a pod must have a unique name (DNS_LABEL). - Cannot be updated. - type: string - ports: - description: |- - List of ports to expose from the container. Not specifying a port here - DOES NOT prevent that port from being exposed. Any port which is - listening on the default "0.0.0.0" address inside a container will be - accessible from the network. - Modifying this array with strategic merge patch may corrupt the data. - For more information See https://github.com/kubernetes/kubernetes/issues/108255. - Cannot be updated. - items: - description: ContainerPort represents a network port in - a single container. - properties: - containerPort: - description: |- - Number of port to expose on the pod's IP address. - This must be a valid port number, 0 < x < 65536. - format: int32 - type: integer - hostIP: - description: What host IP to bind the external port - to. - type: string - hostPort: - description: |- - Number of port to expose on the host. - If specified, this must be a valid port number, 0 < x < 65536. - If HostNetwork is specified, this must match ContainerPort. - Most containers do not need this. - format: int32 - type: integer - name: - description: |- - If specified, this must be an IANA_SVC_NAME and unique within the pod. Each - named port in a pod must have a unique name. Name for the port that can be - referred to by services. - type: string - protocol: - default: TCP - description: |- - Protocol for port. Must be UDP, TCP, or SCTP. - Defaults to "TCP". - type: string - required: - - containerPort - type: object - type: array - x-kubernetes-list-map-keys: - - containerPort - - protocol - x-kubernetes-list-type: map - readinessProbe: - description: |- - Periodic probe of container service readiness. - Container will be removed from service endpoints if the probe fails. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: |- - GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe feature gate. - properties: - port: - description: Port number of the gRPC service. Number - must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom header - to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect to, - defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - resources: - description: |- - Compute Resources required by this container. - Cannot be updated. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - properties: - claims: - description: |- - Claims lists the names of resources, defined in spec.resourceClaims, - that are used by this container. - - - This is an alpha field and requires enabling the - DynamicResourceAllocation feature gate. - - - This field is immutable. - items: - description: ResourceClaim references one entry in - PodSpec.ResourceClaims. - properties: - name: - description: |- - Name must match the name of one entry in pod.spec.resourceClaims of - the Pod where this field is used. It makes that resource available - inside a container. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Limits describes the maximum amount of compute resources allowed. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: |- - Requests describes the minimum amount of compute resources required. - If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, - otherwise to an implementation-defined value. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object - type: object - securityContext: - description: |- - SecurityContext defines the security options the container should be run with. - If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. - More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ - properties: - allowPrivilegeEscalation: - description: |- - AllowPrivilegeEscalation controls whether a process can gain more - privileges than its parent process. This bool directly controls if - the no_new_privs flag will be set on the container process. - AllowPrivilegeEscalation is true always when the container is: - 1) run as Privileged - 2) has CAP_SYS_ADMIN - Note that this field cannot be set when spec.os.name is windows. - type: boolean - capabilities: - description: |- - The capabilities to add/drop when running containers. - Defaults to the default set of capabilities granted by the container runtime. - Note that this field cannot be set when spec.os.name is windows. - properties: - add: - description: Added capabilities - items: - description: Capability represent POSIX capabilities - type - type: string - type: array - drop: - description: Removed capabilities - items: - description: Capability represent POSIX capabilities - type - type: string - type: array - type: object - privileged: - description: |- - Run container in privileged mode. - Processes in privileged containers are essentially equivalent to root on the host. - Defaults to false. - Note that this field cannot be set when spec.os.name is windows. - type: boolean - procMount: - description: |- - procMount denotes the type of proc mount to use for the containers. - The default is DefaultProcMount which uses the container runtime defaults for - readonly paths and masked paths. - This requires the ProcMountType feature flag to be enabled. - Note that this field cannot be set when spec.os.name is windows. - type: string - readOnlyRootFilesystem: - description: |- - Whether this container has a read-only root filesystem. - Default is false. - Note that this field cannot be set when spec.os.name is windows. - type: boolean - runAsGroup: - description: |- - The GID to run the entrypoint of the container process. - Uses runtime default if unset. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - runAsNonRoot: - description: |- - Indicates that the container must run as a non-root user. - If true, the Kubelet will validate the image at runtime to ensure that it - does not run as UID 0 (root) and fail to start the container if it does. - If unset or false, no such validation will be performed. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - type: boolean - runAsUser: - description: |- - The UID to run the entrypoint of the container process. - Defaults to user specified in image metadata if unspecified. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - seLinuxOptions: - description: |- - The SELinux context to be applied to the container. - If unspecified, the container runtime will allocate a random SELinux context for each - container. May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is windows. - properties: - level: - description: Level is SELinux level label that applies - to the container. - type: string - role: - description: Role is a SELinux role label that applies - to the container. - type: string - type: - description: Type is a SELinux type label that applies - to the container. - type: string - user: - description: User is a SELinux user label that applies - to the container. - type: string - type: object - seccompProfile: - description: |- - The seccomp options to use by this container. If seccomp options are - provided at both the pod & container level, the container options - override the pod options. - Note that this field cannot be set when spec.os.name is windows. - properties: - localhostProfile: - description: |- - localhostProfile indicates a profile defined in a file on the node should be used. - The profile must be preconfigured on the node to work. - Must be a descending path, relative to the kubelet's configured seccomp profile location. - Must only be set if type is "Localhost". - type: string - type: - description: |- - type indicates which kind of seccomp profile will be applied. - Valid options are: - - - Localhost - a profile defined in a file on the node should be used. - RuntimeDefault - the container runtime default profile should be used. - Unconfined - no profile should be applied. - type: string - required: - - type - type: object - windowsOptions: - description: |- - The Windows specific settings applied to all containers. - If unspecified, the options from the PodSecurityContext will be used. - If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is linux. - properties: - gmsaCredentialSpec: - description: |- - GMSACredentialSpec is where the GMSA admission webhook - (https://github.com/kubernetes-sigs/windows-gmsa) inlines the contents of the - GMSA credential spec named by the GMSACredentialSpecName field. - type: string - gmsaCredentialSpecName: - description: GMSACredentialSpecName is the name - of the GMSA credential spec to use. - type: string - hostProcess: - description: |- - HostProcess determines if a container should be run as a 'Host Process' container. - This field is alpha-level and will only be honored by components that enable the - WindowsHostProcessContainers feature flag. Setting this field without the feature - flag will result in errors when validating the Pod. All of a Pod's containers must - have the same effective HostProcess value (it is not allowed to have a mix of HostProcess - containers and non-HostProcess containers). In addition, if HostProcess is true - then HostNetwork must also be set to true. - type: boolean - runAsUserName: - description: |- - The UserName in Windows to run the entrypoint of the container process. - Defaults to the user specified in image metadata if unspecified. - May also be set in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext takes precedence. - type: string - type: object - type: object - startupProbe: - description: |- - StartupProbe indicates that the Pod has successfully initialized. - If specified, no other probes are executed until this completes successfully. - If this probe fails, the Pod will be restarted, just as if the livenessProbe failed. - This can be used to provide different probe parameters at the beginning of a Pod's lifecycle, - when it might take a long time to load data or warm a cache, than during steady-state operation. - This cannot be updated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: |- - Command is the command line to execute inside the container, the working directory for the - command is root ('/') in the container's filesystem. The command is simply exec'd, it is - not run inside a shell, so traditional shell instructions ('|', etc) won't work. To use - a shell, you need to explicitly call out to that shell. - Exit status of 0 is treated as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: |- - Minimum consecutive failures for the probe to be considered failed after having succeeded. - Defaults to 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: |- - GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe feature gate. - properties: - port: - description: Port number of the gRPC service. Number - must be in the range 1 to 65535. - format: int32 - type: integer - service: - description: |- - Service is the name of the service to place in the gRPC HealthCheckRequest - (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - - - If this is not specified, the default behavior is defined by gRPC. - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: |- - Host name to connect to, defaults to the pod IP. You probably want to set - "Host" in httpHeaders instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom header - to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Name or number of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: |- - Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: |- - Number of seconds after the container has started before liveness probes are initiated. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - periodSeconds: - description: |- - How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: |- - Minimum consecutive successes for the probe to be considered successful after having failed. - Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving - a TCP port. - properties: - host: - description: 'Optional: Host name to connect to, - defaults to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: |- - Number or name of the port to access on the container. - Number must be in the range 1 to 65535. - Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: |- - Optional duration in seconds the pod needs to terminate gracefully upon probe failure. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this - value overrides the value provided by the pod spec. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - This is a beta field and requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is used if unset. - format: int64 - type: integer - timeoutSeconds: - description: |- - Number of seconds after which the probe times out. - Defaults to 1 second. Minimum value is 1. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes - format: int32 - type: integer - type: object - stdin: - description: |- - Whether this container should allocate a buffer for stdin in the container runtime. If this - is not set, reads from stdin in the container will always result in EOF. - Default is false. - type: boolean - stdinOnce: - description: |- - Whether the container runtime should close the stdin channel after it has been opened by - a single attach. When stdin is true the stdin stream will remain open across multiple attach - sessions. If stdinOnce is set to true, stdin is opened on container start, is empty until the - first client attaches to stdin, and then remains open and accepts data until the client disconnects, - at which time stdin is closed and remains closed until the container is restarted. If this - flag is false, a container processes that reads from stdin will never receive an EOF. - Default is false - type: boolean - terminationMessagePath: - description: |- - Optional: Path at which the file to which the container's termination message - will be written is mounted into the container's filesystem. - Message written is intended to be brief final status, such as an assertion failure message. - Will be truncated by the node if greater than 4096 bytes. The total message length across - all containers will be limited to 12kb. - Defaults to /dev/termination-log. - Cannot be updated. - type: string - terminationMessagePolicy: - description: |- - Indicate how the termination message should be populated. File will use the contents of - terminationMessagePath to populate the container status message on both success and failure. - FallbackToLogsOnError will use the last chunk of container log output if the termination - message file is empty and the container exited with an error. - The log output is limited to 2048 bytes or 80 lines, whichever is smaller. - Defaults to File. - Cannot be updated. - type: string - tty: - description: |- - Whether this container should allocate a TTY for itself, also requires 'stdin' to be true. - Default is false. - type: boolean - volumeDevices: - description: volumeDevices is the list of block devices - to be used by the container. - items: - description: volumeDevice describes a mapping of a raw - block device within a container. - properties: - devicePath: - description: devicePath is the path inside of the - container that the device will be mapped to. - type: string - name: - description: name must match the name of a persistentVolumeClaim - in the pod - type: string - required: - - devicePath - - name - type: object - type: array - volumeMounts: - description: |- - Pod volumes to mount into the container's filesystem. - Cannot be updated. - items: - description: VolumeMount describes a mounting of a Volume - within a container. - properties: - mountPath: - description: |- - Path within the container at which the volume should be mounted. Must - not contain ':'. - type: string - mountPropagation: - description: |- - mountPropagation determines how mounts are propagated from the host - to container and the other way around. - When not set, MountPropagationNone is used. - This field is beta in 1.10. - type: string - name: - description: This must match the Name of a Volume. - type: string - readOnly: - description: |- - Mounted read-only if true, read-write otherwise (false or unspecified). - Defaults to false. - type: boolean - subPath: - description: |- - Path within the volume from which the container's volume should be mounted. - Defaults to "" (volume's root). - type: string - subPathExpr: - description: |- - Expanded path within the volume from which the container's volume should be mounted. - Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. - Defaults to "" (volume's root). - SubPathExpr and SubPath are mutually exclusive. - type: string - required: - - mountPath - - name - type: object - type: array - workingDir: - description: |- - Container's working directory. - If not specified, the container runtime's default will be used, which - might be configured in the container image. - Cannot be updated. - type: string - required: - - name - type: object - type: array - startupProbeFailureSeconds: - description: |- - StartupProbeFailureSeconds defines the total failure seconds of startup Probe. - Default failureThreshold is 60 and the periodSeconds is 5, this means the startup - will fail if the pod can't start in 300 seconds. Your StartupProbeFailureSeconds is - the total time of seconds before startupProbe give up and fail the container start. - If startupProbeFailureSeconds can't be divided by defaultPeriodSeconds, the failureThreshold - will be rounded up. - Note: you can set it to 0 to disable the startup probe. - format: int32 - type: integer - storageVolumes: - description: "StorageVolumes defines the additional storage for - FE meta or BE/CN storage.\n\n\nFor FE component\n\tIf the storage - volume name is fe-meta or the volume mount path is /opt/starrocks/fe/meta,\n\tthen - it will be recognized as storing the FE meta.\n\tIf the storage - volume name is fe-log or the volume mount path is /opt/starrocks/fe/log,\n\tthen - it will be recognized as storing the FE log.\n\n\nFor BE component\n\tIf - the storage volume name is be-storage(or be-data) or the volume - mount path is /opt/starrocks/be/storage,\n\tthen it will be - recognized as storing the BE data.\n\tIf the storage volume - name is be-log or the volume mount path is /opt/starrocks/be/log,\n\tthen - it will be recognized as storing the BE log.\n\n\nFor CN component\n\tIf - the storage volume name is cn-log or the volume mount path is - /opt/starrocks/cn/log,\n\tthen it will be recognized as storing - the cn log.\n\n\nIf operator can't find the above storage volume - names or the volume mount paths, it will create\ndefault storage - volumes by using emptyDir." - items: - description: StorageVolume defines additional PVC template for - StatefulSets and volumeMount for pods that mount this PVC. - properties: - hostPath: - description: |- - HostPath Represents a host path mapped into a pod. - If StorageClassName is hostPath, HostPath is required. - properties: - path: - description: |- - path of the directory on the host. - If the path is a symlink, it will follow the link to the real path. - More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath - type: string - type: - description: |- - type for HostPath Volume - Defaults to "" - More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath - type: string - required: - - path - type: object - mountPath: - description: MountPath specify the path of volume mount. - type: string - name: - description: name of a storage volume. - pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*' - type: string - storageClassName: - description: |- - storageClassName is the name of the StorageClass required by the claim. - If storageClassName is not set, the default StorageClass of kubernetes will be used. - there are some special storageClassName: emptyDir, hostPath. In this case, It will use emptyDir or hostPath, not PVC. - More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1 - type: string - storageSize: - description: |- - StorageSize is a valid memory size type based on powers-of-2, so 1Mi is 1024Ki. - Supported units:Mi, Gi, GiB, Ti, Ti, Pi, Ei, Ex: `512Mi`. - It will take effect only when storageClassName is real storage class, not emptyDir or hostPath. - pattern: (^0|([0-9]*l[.])?[0-9]+((M|G|T|E|P)i))$ - type: string - subPath: - description: |- - SubPath within the volume from which the container's volume should be mounted. - Defaults to "" (volume's root). - type: string - required: - - mountPath - - name - type: object - type: array - sysctls: - description: |- - Sysctls defines a list of namespaced sysctls for the podSecurityContext.sysctls - See https://kubernetes.io/docs/tasks/administer-cluster/sysctl-cluster/ for more details. - items: - description: Sysctl defines a kernel parameter to be set - properties: - name: - description: Name of a property to set - type: string - value: - description: Value of a property to set - type: string - required: - - name - - value - type: object - type: array - terminationGracePeriodSeconds: - description: |- - TerminationGracePeriodSeconds defines duration in seconds the pod needs to terminate gracefully. May be decreased in delete request. - Value must be non-negative integer. The value zero indicates stop immediately via - the kill signal (no opportunity to shut down). - If this value is nil, the default grace period will be used instead. - The grace period is the duration in seconds after the processes running in the pod are sent - a termination signal and the time when the processes are forcibly halted with a kill signal. - Set this value longer than the expected cleanup time for your process. - Defaults to 120 seconds. - format: int64 - type: integer - tolerations: - description: (Optional) Tolerations for scheduling pods onto some - dedicated nodes - items: - description: |- - The pod this Toleration is attached to tolerates any taint that matches - the triple using the matching operator . - properties: - effect: - description: |- - Effect indicates the taint effect to match. Empty means match all taint effects. - When specified, allowed values are NoSchedule, PreferNoSchedule and NoExecute. - type: string - key: - description: |- - Key is the taint key that the toleration applies to. Empty means match all taint keys. - If the key is empty, operator must be Exists; this combination means to match all values and all keys. - type: string - operator: - description: |- - Operator represents a key's relationship to the value. - Valid operators are Exists and Equal. Defaults to Equal. - Exists is equivalent to wildcard for value, so that a pod can - tolerate all taints of a particular category. - type: string - tolerationSeconds: - description: |- - TolerationSeconds represents the period of time the toleration (which must be - of effect NoExecute, otherwise this field is ignored) tolerates the taint. By default, - it is not set, which means tolerate the taint forever (do not evict). Zero and - negative values will be treated as 0 (evict immediately) by the system. - format: int64 - type: integer - value: - description: |- - Value is the taint value the toleration matches to. - If the operator is Exists, the value should be empty, otherwise just a regular string. - type: string - type: object - type: array - topologySpreadConstraints: - description: |- - (Optional) TopologySpreadConstraints for spreading pods across failure-domains - More info: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ - items: - description: TopologySpreadConstraint specifies how to spread - matching pods among the given topology. - properties: - labelSelector: - description: |- - LabelSelector is used to find matching pods. - Pods that match this label selector are counted to determine the number of pods - in their corresponding topology domain. - properties: - matchExpressions: - description: matchExpressions is a list of label selector - requirements. The requirements are ANDed. - items: - description: |- - A label selector requirement is a selector that contains values, a key, and an operator that - relates the key and values. - properties: - key: - description: key is the label key that the selector - applies to. - type: string - operator: - description: |- - operator represents a key's relationship to a set of values. - Valid operators are In, NotIn, Exists and DoesNotExist. - type: string - values: - description: |- - values is an array of string values. If the operator is In or NotIn, - the values array must be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced during a strategic - merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: |- - matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels - map is equivalent to an element of matchExpressions, whose key field is "key", the - operator is "In", and the values array contains only "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - matchLabelKeys: - description: |- - MatchLabelKeys is a set of pod label keys to select the pods over which - spreading will be calculated. The keys are used to lookup values from the - incoming pod labels, those key-value labels are ANDed with labelSelector - to select the group of existing pods over which spreading will be calculated - for the incoming pod. Keys that don't exist in the incoming pod labels will - be ignored. A null or empty list means only match against labelSelector. - items: - type: string - type: array - x-kubernetes-list-type: atomic - maxSkew: - description: |- - MaxSkew describes the degree to which pods may be unevenly distributed. - When `whenUnsatisfiable=DoNotSchedule`, it is the maximum permitted difference - between the number of matching pods in the target topology and the global minimum. - The global minimum is the minimum number of matching pods in an eligible domain - or zero if the number of eligible domains is less than MinDomains. - For example, in a 3-zone cluster, MaxSkew is set to 1, and pods with the same - labelSelector spread as 2/2/1: - In this case, the global minimum is 1. - | zone1 | zone2 | zone3 | - | P P | P P | P | - - if MaxSkew is 1, incoming pod can only be scheduled to zone3 to become 2/2/2; - scheduling it onto zone1(zone2) would make the ActualSkew(3-1) on zone1(zone2) - violate MaxSkew(1). - - if MaxSkew is 2, incoming pod can be scheduled onto any zone. - When `whenUnsatisfiable=ScheduleAnyway`, it is used to give higher precedence - to topologies that satisfy it. - It's a required field. Default value is 1 and 0 is not allowed. - format: int32 - type: integer - minDomains: - description: |- - MinDomains indicates a minimum number of eligible domains. - When the number of eligible domains with matching topology keys is less than minDomains, - Pod Topology Spread treats "global minimum" as 0, and then the calculation of Skew is performed. - And when the number of eligible domains with matching topology keys equals or greater than minDomains, - this value has no effect on scheduling. - As a result, when the number of eligible domains is less than minDomains, - scheduler won't schedule more than maxSkew Pods to those domains. - If value is nil, the constraint behaves as if MinDomains is equal to 1. - Valid values are integers greater than 0. - When value is not nil, WhenUnsatisfiable must be DoNotSchedule. - - - For example, in a 3-zone cluster, MaxSkew is set to 2, MinDomains is set to 5 and pods with the same - labelSelector spread as 2/2/2: - | zone1 | zone2 | zone3 | - | P P | P P | P P | - The number of domains is less than 5(MinDomains), so "global minimum" is treated as 0. - In this situation, new pod with the same labelSelector cannot be scheduled, - because computed skew will be 3(3 - 0) if new Pod is scheduled to any of the three zones, - it will violate MaxSkew. - - - This is a beta field and requires the MinDomainsInPodTopologySpread feature gate to be enabled (enabled by default). - format: int32 - type: integer - nodeAffinityPolicy: - description: |- - NodeAffinityPolicy indicates how we will treat Pod's nodeAffinity/nodeSelector - when calculating pod topology spread skew. Options are: - - Honor: only nodes matching nodeAffinity/nodeSelector are included in the calculations. - - Ignore: nodeAffinity/nodeSelector are ignored. All nodes are included in the calculations. - - - If this value is nil, the behavior is equivalent to the Honor policy. - This is a beta-level feature default enabled by the NodeInclusionPolicyInPodTopologySpread feature flag. - type: string - nodeTaintsPolicy: - description: |- - NodeTaintsPolicy indicates how we will treat node taints when calculating - pod topology spread skew. Options are: - - Honor: nodes without taints, along with tainted nodes for which the incoming pod - has a toleration, are included. - - Ignore: node taints are ignored. All nodes are included. - - If this value is nil, the behavior is equivalent to the Ignore policy. This is a beta-level feature default enabled by the NodeInclusionPolicyInPodTopologySpread feature flag. type: string @@ -18019,6 +13601,22 @@ spec: description: (Optional) If specified, the pod's nodeSelector,displayName="Map of nodeSelectors to match when scheduling pods on nodes" type: object + observerSpec: + description: ObserverSpec configures optional FE observer pods. + Observer pods reuse the generic FE resources. + properties: + enabled: + description: Enabled controls whether FE observer should be + reconciled. + type: boolean + observerNumber: + default: 1 + description: ObserverNumber is the number of desired FE observer + Pods. + format: int32 + minimum: 0 + type: integer + type: object persistentVolumeClaimRetentionPolicy: description: |- PersistentVolumeClaimRetentionPolicy specifies the retention policy for PersistentVolumeClaims associated with the component. diff --git a/deploy/starrocks.com_starrocksclusters.yaml b/deploy/starrocks.com_starrocksclusters.yaml index 5b5dd41d8..39e9166fa 100644 --- a/deploy/starrocks.com_starrocksclusters.yaml +++ b/deploy/starrocks.com_starrocksclusters.yaml @@ -4496,2061 +4496,6 @@ spec: type: string type: object type: object - starRocksFeObserverSpec: - properties: - affinity: - properties: - nodeAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - preference: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchFields: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - type: object - x-kubernetes-map-type: atomic - weight: - format: int32 - type: integer - required: - - preference - - weight - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - properties: - nodeSelectorTerms: - items: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchFields: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - type: object - x-kubernetes-map-type: atomic - type: array - required: - - nodeSelectorTerms - type: object - x-kubernetes-map-type: atomic - type: object - podAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - podAffinityTerm: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - x-kubernetes-map-type: atomic - namespaceSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - x-kubernetes-map-type: atomic - namespaces: - items: - type: string - type: array - topologyKey: - type: string - required: - - topologyKey - type: object - weight: - format: int32 - type: integer - required: - - podAffinityTerm - - weight - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - items: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - x-kubernetes-map-type: atomic - namespaceSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - x-kubernetes-map-type: atomic - namespaces: - items: - type: string - type: array - topologyKey: - type: string - required: - - topologyKey - type: object - type: array - type: object - podAntiAffinity: - properties: - preferredDuringSchedulingIgnoredDuringExecution: - items: - properties: - podAffinityTerm: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - x-kubernetes-map-type: atomic - namespaceSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - x-kubernetes-map-type: atomic - namespaces: - items: - type: string - type: array - topologyKey: - type: string - required: - - topologyKey - type: object - weight: - format: int32 - type: integer - required: - - podAffinityTerm - - weight - type: object - type: array - requiredDuringSchedulingIgnoredDuringExecution: - items: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - x-kubernetes-map-type: atomic - namespaceSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - x-kubernetes-map-type: atomic - namespaces: - items: - type: string - type: array - topologyKey: - type: string - required: - - topologyKey - type: object - type: array - type: object - type: object - annotations: - additionalProperties: - type: string - type: object - args: - items: - type: string - type: array - capabilities: - properties: - add: - items: - type: string - type: array - drop: - items: - type: string - type: array - type: object - claims: - items: - properties: - name: - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - command: - items: - type: string - type: array - configMapInfo: - properties: - configMapName: - type: string - resolveKey: - type: string - type: object - configMaps: - items: - properties: - mountPath: - type: string - name: - type: string - subPath: - type: string - type: object - type: array - feEnvVars: - items: - properties: - name: - type: string - value: - type: string - valueFrom: - properties: - configMapKeyRef: - properties: - key: - type: string - name: - type: string - optional: - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - properties: - apiVersion: - type: string - fieldPath: - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - properties: - containerName: - type: string - divisor: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - properties: - key: - type: string - name: - type: string - optional: - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - hostAliases: - items: - properties: - hostnames: - items: - type: string - type: array - ip: - type: string - type: object - type: array - image: - type: string - imagePullPolicy: - type: string - imagePullSecrets: - items: - properties: - name: - type: string - type: object - x-kubernetes-map-type: atomic - type: array - initContainers: - items: - properties: - args: - items: - type: string - type: array - command: - items: - type: string - type: array - env: - items: - properties: - name: - type: string - value: - type: string - valueFrom: - properties: - configMapKeyRef: - properties: - key: - type: string - name: - type: string - optional: - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - properties: - apiVersion: - type: string - fieldPath: - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - properties: - containerName: - type: string - divisor: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - properties: - key: - type: string - name: - type: string - optional: - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - envFrom: - items: - properties: - configMapRef: - properties: - name: - type: string - optional: - type: boolean - type: object - x-kubernetes-map-type: atomic - prefix: - type: string - secretRef: - properties: - name: - type: string - optional: - type: boolean - type: object - x-kubernetes-map-type: atomic - type: object - type: array - image: - type: string - imagePullPolicy: - type: string - lifecycle: - properties: - postStart: - properties: - exec: - properties: - command: - items: - type: string - type: array - type: object - httpGet: - properties: - host: - type: string - httpHeaders: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - path: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - scheme: - type: string - required: - - port - type: object - tcpSocket: - properties: - host: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - preStop: - properties: - exec: - properties: - command: - items: - type: string - type: array - type: object - httpGet: - properties: - host: - type: string - httpHeaders: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - path: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - scheme: - type: string - required: - - port - type: object - tcpSocket: - properties: - host: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - type: object - livenessProbe: - properties: - exec: - properties: - command: - items: - type: string - type: array - type: object - failureThreshold: - format: int32 - type: integer - grpc: - properties: - port: - format: int32 - type: integer - service: - type: string - required: - - port - type: object - httpGet: - properties: - host: - type: string - httpHeaders: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - path: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - scheme: - type: string - required: - - port - type: object - initialDelaySeconds: - format: int32 - type: integer - periodSeconds: - format: int32 - type: integer - successThreshold: - format: int32 - type: integer - tcpSocket: - properties: - host: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - format: int64 - type: integer - timeoutSeconds: - format: int32 - type: integer - type: object - name: - type: string - ports: - items: - properties: - containerPort: - format: int32 - type: integer - hostIP: - type: string - hostPort: - format: int32 - type: integer - name: - type: string - protocol: - default: TCP - type: string - required: - - containerPort - type: object - type: array - x-kubernetes-list-map-keys: - - containerPort - - protocol - x-kubernetes-list-type: map - readinessProbe: - properties: - exec: - properties: - command: - items: - type: string - type: array - type: object - failureThreshold: - format: int32 - type: integer - grpc: - properties: - port: - format: int32 - type: integer - service: - type: string - required: - - port - type: object - httpGet: - properties: - host: - type: string - httpHeaders: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - path: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - scheme: - type: string - required: - - port - type: object - initialDelaySeconds: - format: int32 - type: integer - periodSeconds: - format: int32 - type: integer - successThreshold: - format: int32 - type: integer - tcpSocket: - properties: - host: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - format: int64 - type: integer - timeoutSeconds: - format: int32 - type: integer - type: object - resources: - properties: - claims: - items: - properties: - name: - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - type: object - securityContext: - properties: - allowPrivilegeEscalation: - type: boolean - capabilities: - properties: - add: - items: - type: string - type: array - drop: - items: - type: string - type: array - type: object - privileged: - type: boolean - procMount: - type: string - readOnlyRootFilesystem: - type: boolean - runAsGroup: - format: int64 - type: integer - runAsNonRoot: - type: boolean - runAsUser: - format: int64 - type: integer - seLinuxOptions: - properties: - level: - type: string - role: - type: string - type: - type: string - user: - type: string - type: object - seccompProfile: - properties: - localhostProfile: - type: string - type: - type: string - required: - - type - type: object - windowsOptions: - properties: - gmsaCredentialSpec: - type: string - gmsaCredentialSpecName: - type: string - hostProcess: - type: boolean - runAsUserName: - type: string - type: object - type: object - startupProbe: - properties: - exec: - properties: - command: - items: - type: string - type: array - type: object - failureThreshold: - format: int32 - type: integer - grpc: - properties: - port: - format: int32 - type: integer - service: - type: string - required: - - port - type: object - httpGet: - properties: - host: - type: string - httpHeaders: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - path: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - scheme: - type: string - required: - - port - type: object - initialDelaySeconds: - format: int32 - type: integer - periodSeconds: - format: int32 - type: integer - successThreshold: - format: int32 - type: integer - tcpSocket: - properties: - host: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - format: int64 - type: integer - timeoutSeconds: - format: int32 - type: integer - type: object - stdin: - type: boolean - stdinOnce: - type: boolean - terminationMessagePath: - type: string - terminationMessagePolicy: - type: string - tty: - type: boolean - volumeDevices: - items: - properties: - devicePath: - type: string - name: - type: string - required: - - devicePath - - name - type: object - type: array - volumeMounts: - items: - properties: - mountPath: - type: string - mountPropagation: - type: string - name: - type: string - readOnly: - type: boolean - subPath: - type: string - subPathExpr: - type: string - required: - - mountPath - - name - type: object - type: array - workingDir: - type: string - required: - - name - type: object - type: array - lifecycle: - properties: - postStart: - properties: - exec: - properties: - command: - items: - type: string - type: array - type: object - httpGet: - properties: - host: - type: string - httpHeaders: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - path: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - scheme: - type: string - required: - - port - type: object - tcpSocket: - properties: - host: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - preStop: - properties: - exec: - properties: - command: - items: - type: string - type: array - type: object - httpGet: - properties: - host: - type: string - httpHeaders: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - path: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - scheme: - type: string - required: - - port - type: object - tcpSocket: - properties: - host: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - type: object - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - livenessProbeFailureSeconds: - format: int32 - type: integer - minReadySeconds: - format: int32 - type: integer - nodeSelector: - additionalProperties: - type: string - type: object - persistentVolumeClaimRetentionPolicy: - properties: - whenDeleted: - type: string - whenScaled: - type: string - type: object - podLabels: - additionalProperties: - type: string - type: object - podManagementPolicy: - type: string - readOnlyRootFilesystem: - type: boolean - readinessProbeFailureSeconds: - format: int32 - type: integer - replicas: - default: 1 - format: int32 - minimum: 0 - type: integer - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - runAsNonRoot: - type: boolean - schedulerName: - type: string - secrets: - items: - properties: - mountPath: - type: string - name: - type: string - subPath: - type: string - type: object - type: array - service: - properties: - annotations: - additionalProperties: - type: string - type: object - labels: - additionalProperties: - type: string - type: object - loadBalancerIP: - type: string - loadBalancerSourceRanges: - items: - type: string - type: array - ports: - items: - properties: - containerPort: - format: int32 - type: integer - name: - type: string - nodePort: - format: int32 - type: integer - port: - format: int32 - type: integer - type: object - type: array - type: - type: string - type: object - serviceAccount: - type: string - shareProcessNamespace: - type: boolean - sidecars: - items: - properties: - args: - items: - type: string - type: array - command: - items: - type: string - type: array - env: - items: - properties: - name: - type: string - value: - type: string - valueFrom: - properties: - configMapKeyRef: - properties: - key: - type: string - name: - type: string - optional: - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - properties: - apiVersion: - type: string - fieldPath: - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - properties: - containerName: - type: string - divisor: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - properties: - key: - type: string - name: - type: string - optional: - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - envFrom: - items: - properties: - configMapRef: - properties: - name: - type: string - optional: - type: boolean - type: object - x-kubernetes-map-type: atomic - prefix: - type: string - secretRef: - properties: - name: - type: string - optional: - type: boolean - type: object - x-kubernetes-map-type: atomic - type: object - type: array - image: - type: string - imagePullPolicy: - type: string - lifecycle: - properties: - postStart: - properties: - exec: - properties: - command: - items: - type: string - type: array - type: object - httpGet: - properties: - host: - type: string - httpHeaders: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - path: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - scheme: - type: string - required: - - port - type: object - tcpSocket: - properties: - host: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - preStop: - properties: - exec: - properties: - command: - items: - type: string - type: array - type: object - httpGet: - properties: - host: - type: string - httpHeaders: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - path: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - scheme: - type: string - required: - - port - type: object - tcpSocket: - properties: - host: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - type: object - livenessProbe: - properties: - exec: - properties: - command: - items: - type: string - type: array - type: object - failureThreshold: - format: int32 - type: integer - grpc: - properties: - port: - format: int32 - type: integer - service: - type: string - required: - - port - type: object - httpGet: - properties: - host: - type: string - httpHeaders: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - path: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - scheme: - type: string - required: - - port - type: object - initialDelaySeconds: - format: int32 - type: integer - periodSeconds: - format: int32 - type: integer - successThreshold: - format: int32 - type: integer - tcpSocket: - properties: - host: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - format: int64 - type: integer - timeoutSeconds: - format: int32 - type: integer - type: object - name: - type: string - ports: - items: - properties: - containerPort: - format: int32 - type: integer - hostIP: - type: string - hostPort: - format: int32 - type: integer - name: - type: string - protocol: - default: TCP - type: string - required: - - containerPort - type: object - type: array - x-kubernetes-list-map-keys: - - containerPort - - protocol - x-kubernetes-list-type: map - readinessProbe: - properties: - exec: - properties: - command: - items: - type: string - type: array - type: object - failureThreshold: - format: int32 - type: integer - grpc: - properties: - port: - format: int32 - type: integer - service: - type: string - required: - - port - type: object - httpGet: - properties: - host: - type: string - httpHeaders: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - path: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - scheme: - type: string - required: - - port - type: object - initialDelaySeconds: - format: int32 - type: integer - periodSeconds: - format: int32 - type: integer - successThreshold: - format: int32 - type: integer - tcpSocket: - properties: - host: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - format: int64 - type: integer - timeoutSeconds: - format: int32 - type: integer - type: object - resources: - properties: - claims: - items: - properties: - name: - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - type: object - type: object - securityContext: - properties: - allowPrivilegeEscalation: - type: boolean - capabilities: - properties: - add: - items: - type: string - type: array - drop: - items: - type: string - type: array - type: object - privileged: - type: boolean - procMount: - type: string - readOnlyRootFilesystem: - type: boolean - runAsGroup: - format: int64 - type: integer - runAsNonRoot: - type: boolean - runAsUser: - format: int64 - type: integer - seLinuxOptions: - properties: - level: - type: string - role: - type: string - type: - type: string - user: - type: string - type: object - seccompProfile: - properties: - localhostProfile: - type: string - type: - type: string - required: - - type - type: object - windowsOptions: - properties: - gmsaCredentialSpec: - type: string - gmsaCredentialSpecName: - type: string - hostProcess: - type: boolean - runAsUserName: - type: string - type: object - type: object - startupProbe: - properties: - exec: - properties: - command: - items: - type: string - type: array - type: object - failureThreshold: - format: int32 - type: integer - grpc: - properties: - port: - format: int32 - type: integer - service: - type: string - required: - - port - type: object - httpGet: - properties: - host: - type: string - httpHeaders: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - path: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - scheme: - type: string - required: - - port - type: object - initialDelaySeconds: - format: int32 - type: integer - periodSeconds: - format: int32 - type: integer - successThreshold: - format: int32 - type: integer - tcpSocket: - properties: - host: - type: string - port: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - format: int64 - type: integer - timeoutSeconds: - format: int32 - type: integer - type: object - stdin: - type: boolean - stdinOnce: - type: boolean - terminationMessagePath: - type: string - terminationMessagePolicy: - type: string - tty: - type: boolean - volumeDevices: - items: - properties: - devicePath: - type: string - name: - type: string - required: - - devicePath - - name - type: object - type: array - volumeMounts: - items: - properties: - mountPath: - type: string - mountPropagation: - type: string - name: - type: string - readOnly: - type: boolean - subPath: - type: string - subPathExpr: - type: string - required: - - mountPath - - name - type: object - type: array - workingDir: - type: string - required: - - name - type: object - type: array - startupProbeFailureSeconds: - format: int32 - type: integer - storageVolumes: - items: - properties: - hostPath: - properties: - path: - type: string - type: - type: string - required: - - path - type: object - mountPath: - type: string - name: - pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*' - type: string - storageClassName: - type: string - storageSize: - pattern: (^0|([0-9]*l[.])?[0-9]+((M|G|T|E|P)i))$ - type: string - subPath: - type: string - required: - - mountPath - - name - type: object - type: array - sysctls: - items: - properties: - name: - type: string - value: - type: string - required: - - name - - value - type: object - type: array - terminationGracePeriodSeconds: - format: int64 - type: integer - tolerations: - items: - properties: - effect: - type: string - key: - type: string - operator: - type: string - tolerationSeconds: - format: int64 - type: integer - value: - type: string - type: object - type: array - topologySpreadConstraints: - items: - properties: - labelSelector: - properties: - matchExpressions: - items: - properties: - key: - type: string - operator: - type: string - values: - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - type: object - type: object - x-kubernetes-map-type: atomic - matchLabelKeys: - items: - type: string - type: array - x-kubernetes-list-type: atomic - maxSkew: - format: int32 - type: integer - minDomains: - format: int32 - type: integer - nodeAffinityPolicy: - type: string - nodeTaintsPolicy: - type: string - topologyKey: - type: string - whenUnsatisfiable: - type: string - required: - - maxSkew - - topologyKey - - whenUnsatisfiable - type: object - type: array - updateStrategy: - properties: - rollingUpdate: - properties: - maxUnavailable: - anyOf: - - type: integer - - type: string - x-kubernetes-int-or-string: true - partition: - format: int32 - type: integer - type: object - type: - type: string - type: object - type: object starRocksFeProxySpec: properties: affinity: @@ -8468,6 +6413,16 @@ spec: additionalProperties: type: string type: object + observerSpec: + properties: + enabled: + type: boolean + observerNumber: + default: 1 + format: int32 + minimum: 0 + type: integer + type: object persistentVolumeClaimRetentionPolicy: properties: whenDeleted: diff --git a/helm-charts/charts/kube-starrocks/charts/starrocks/templates/starrockscluster.yaml b/helm-charts/charts/kube-starrocks/charts/starrocks/templates/starrockscluster.yaml index 44133f0da..b45293f1f 100644 --- a/helm-charts/charts/kube-starrocks/charts/starrocks/templates/starrockscluster.yaml +++ b/helm-charts/charts/kube-starrocks/charts/starrocks/templates/starrockscluster.yaml @@ -284,181 +284,11 @@ spec: persistentVolumeClaimRetentionPolicy: {{- toYaml .Values.starrocksFESpec.persistentVolumeClaimRetentionPolicy | nindent 6 }} {{- end }} - {{- if .Values.starrocksFeObserverSpec.enabled }} - starRocksFeObserverSpec: - {{- if .Values.starrocksFeObserverSpec.initContainers }} - initContainers: - {{- toYaml .Values.starrocksFeObserverSpec.initContainers | nindent 6 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.shareProcessNamespace }} - shareProcessNamespace: {{ .Values.starrocksFeObserverSpec.shareProcessNamespace }} - {{- end }} - image: "{{ .Values.starrocksFeObserverSpec.image.repository }}:{{ default .Values.starrocksCluster.componentValues.image.tag .Values.starrocksFeObserverSpec.image.tag }}" - replicas: {{ .Values.starrocksFeObserverSpec.replicas }} - imagePullPolicy: {{ .Values.starrocksFeObserverSpec.imagePullPolicy }} - {{- if .Values.starrocksFeObserverSpec.resources }} - {{- toYaml .Values.starrocksFeObserverSpec.resources | nindent 4 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.service.type }} - service: - type: {{ .Values.starrocksFeObserverSpec.service.type }} - {{- if and (eq "LoadBalancer" .Values.starrocksFeObserverSpec.service.type) .Values.starrocksFeObserverSpec.service.loadbalancerIP }} - loadBalancerIP: {{ .Values.starrocksFeObserverSpec.service.loadbalancerIP }} - {{- end }} - {{- if and (eq "LoadBalancer" .Values.starrocksFeObserverSpec.service.type) .Values.starrocksFeObserverSpec.service.loadBalancerSourceRanges}} - loadBalancerSourceRanges: - {{- toYaml .Values.starrocksFeObserverSpec.service.loadBalancerSourceRanges | nindent 8 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.service.ports }} - ports: - {{- toYaml .Values.starrocksFeObserverSpec.service.ports | nindent 8 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.service.annotations }} - annotations: - {{- toYaml .Values.starrocksFeObserverSpec.service.annotations | nindent 8 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.service.labels }} - labels: - {{- toYaml .Values.starrocksFeObserverSpec.service.labels | nindent 8 }} - {{- end }} - {{- end }} - annotations: - app.starrocks.io/fe-config-hash: "{{template "starrockscluster.fe.config.hash" . }}" - {{- if .Values.starrocksFeObserverSpec.annotations }} - {{- toYaml .Values.starrocksFeObserverSpec.annotations | nindent 6 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.imagePullSecrets }} - imagePullSecrets: - {{- toYaml .Values.starrocksFeObserverSpec.imagePullSecrets | nindent 6 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.serviceAccount }} - serviceAccount: {{ .Values.starrocksFeObserverSpec.serviceAccount }} - {{- end }} - runAsNonRoot: {{ .Values.starrocksFeObserverSpec.runAsNonRoot }} - {{- if .Values.starrocksFeObserverSpec.readOnlyRootFilesystem }} - readOnlyRootFilesystem: {{ .Values.starrocksFeObserverSpec.readOnlyRootFilesystem }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.capabilities }} - capabilities: - {{- toYaml .Values.starrocksFeObserverSpec.capabilities | nindent 6 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.sysctls }} - sysctls: - {{- toYaml .Values.starrocksFeObserverSpec.sysctls | nindent 6 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.nodeSelector }} - nodeSelector: - {{- toYaml .Values.starrocksFeObserverSpec.nodeSelector | nindent 6 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.podLabels }} - podLabels: - {{- toYaml .Values.starrocksFeObserverSpec.podLabels | nindent 6 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.hostAliases }} - hostAliases: - {{- toYaml .Values.starrocksFeObserverSpec.hostAliases | nindent 6 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.schedulerName }} - schedulerName: {{ .Values.starrocksFeObserverSpec.schedulerName }} + {{- if .Values.starrocksFESpec.observerSpec.enabled }} + observerSpec: + enabled: true + observerNumber: {{ .Values.starrocksFESpec.observerSpec.observerNumber }} {{- end }} - feEnvVars: - - name: TZ - value: {{ .Values.timeZone }} - {{- if .Values.starrocksFeObserverSpec.feEnvVars }} - {{- /* if it is a map, we use range to iterate to merge environment variables */}} - {{- if eq (kindOf .Values.starrocksFeObserverSpec.feEnvVars) "map" }} - {{- range $key, $value := .Values.starrocksFeObserverSpec.feEnvVars }} - - name: {{ $key }} - {{- if eq (kindOf $value) "string" }} - value: {{ $value | quote }} - {{- else }} - {{- toYaml $value | nindent 8 }} - {{- end }} - {{- end }} - {{- else }} - {{- /* the default kind is slice, we keep backward compatibility */}} - {{- toYaml .Values.starrocksFeObserverSpec.feEnvVars | nindent 6 }} - {{- end }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.affinity }} - affinity: - {{- toYaml .Values.starrocksFeObserverSpec.affinity | nindent 6 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.tolerations }} - tolerations: - {{- toYaml .Values.starrocksFeObserverSpec.tolerations | nindent 6 }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.topologySpreadConstraints }} - topologySpreadConstraints: - {{- toYaml .Values.starrocksFeObserverSpec.topologySpreadConstraints | nindent 6 }} - {{- end }} - terminationGracePeriodSeconds: {{ .Values.starrocksFeObserverSpec.terminationGracePeriodSeconds }} - {{- if .Values.starrocksFeObserverSpec.startupProbeFailureSeconds }} - startupProbeFailureSeconds: {{ .Values.starrocksFeObserverSpec.startupProbeFailureSeconds }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.livenessProbeFailureSeconds }} - livenessProbeFailureSeconds: {{ .Values.starrocksFeObserverSpec.livenessProbeFailureSeconds }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.readinessProbeFailureSeconds }} - readinessProbeFailureSeconds: {{ .Values.starrocksFeObserverSpec.readinessProbeFailureSeconds }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.lifecycle }} - lifecycle: - {{- toYaml .Values.starrocksFeObserverSpec.lifecycle | nindent 6 }} - {{- end }} - {{- if and .Values.starrocksFeObserverSpec.sidecarsMap .Values.starrocksFeObserverSpec.sidecars }} - {{ fail "starrocksFeObserverSpec.sidecarsMap and starrocksFeObserverSpec.sidecars cannot be set at the same time" }} - {{- end }} - {{- if or .Values.starrocksFeObserverSpec.sidecarsMap .Values.starrocksFeObserverSpec.sidecars }} - sidecars: - {{- if .Values.starrocksFeObserverSpec.sidecarsMap }} - {{- range $name, $spec := .Values.starrocksFeObserverSpec.sidecarsMap }} - - name: {{ $name }} - {{- toYaml $spec | nindent 8 }} - {{- end }} - {{- else if .Values.starrocksFeObserverSpec.sidecars }} - {{- toYaml .Values.starrocksFeObserverSpec.sidecars | nindent 6 }} - {{- end }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.secrets }} - secrets: - {{- range .Values.starrocksFeObserverSpec.secrets }} - - name: {{ .name }} - mountPath: {{ .mountPath }} - subPath: {{ .subPath }} - {{- end }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.configMaps }} - configMaps: - {{- range .Values.starrocksFeObserverSpec.configMaps }} - - name: {{ .name }} - mountPath: {{ .mountPath }} - subPath: {{ .subPath }} - {{- end }} - {{- end }} - configMapInfo: - configMapName: {{ template "starrockscluster.fe.configmap.name" . }} - resolveKey: fe.conf - {{- if or .Values.starrocksFeObserverSpec.emptyDirs .Values.starrocksFeObserverSpec.hostPaths }} - storageVolumes: - {{- if .Values.starrocksFeObserverSpec.emptyDirs }} - {{- range .Values.starrocksFeObserverSpec.emptyDirs }} - - name: {{ .name }} - mountPath: {{ .mountPath }} - storageClassName: "emptyDir" - {{- end }} - {{- end }} - {{- if .Values.starrocksFeObserverSpec.hostPaths }} - {{- range .Values.starrocksFeObserverSpec.hostPaths }} - - name: {{ .name }} - mountPath: {{ .mountPath }} - storageClassName: "hostPath" - hostPath: - {{- toYaml .hostPath | nindent 8 }} - {{- end }} - {{- end }} - {{- end }} - {{- end }} {{- if .Values.starrocksCluster.enabledBe }} starRocksBeSpec: {{- if .Values.starrocksBeSpec.initContainers }} diff --git a/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml b/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml index 66dc7742a..1795501cb 100644 --- a/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml @@ -513,210 +513,13 @@ starrocksFESpec: # When this is set, containers will be able to view and signal processes from other containers # in the same pod, and the first process in each container will not be assigned PID 1. shareProcessNamespace: - -# spec to deploy fe observer. -starrocksFeObserverSpec: - # specify the FE observer deployment or not. - enabled: false - # number of replicas to deploy for a FE observer deployment. - replicas: 1 - image: - # image sliced by "repository:tag" - repository: starrocks/fe-ubuntu - tag: "" - imagePullPolicy: IfNotPresent - # add annotations for FE observer pods. - annotations: {} - # If runAsNonRoot is true, the container is run as a non-root user. - # The userId will be set to 1000, and the groupID will be set to 1000. - runAsNonRoot: false - # Whether this container has a read-only root filesystem. - readOnlyRootFilesystem: false - # add/drop capabilities for FE observer container. - capabilities: {} - # set sysctls for FE observer pod. - sysctls: [] - # specify the service name and port config and serviceType - service: - # the FE observer service type, only supported ClusterIP, NodePort, LoadBalancer - type: "ClusterIP" - # the loadBalancerIP for static ip config when the type=LoadBalancer and loadbalancerIp is not empty. - loadbalancerIP: "" - # add annotations for external FE observer service. - annotations: {} - # Add labels for external FE observer service. The operator may add its own default labels. - labels: {} - # Config the service port for FE observer service. - # To assign a specific port or nodePort to a service, you should specify them by the corresponding name or - # containerPort in the service configuration. If both containerPort and name are specified, containerPort takes precedence. - # For fe, port name can be http, query, rpc, edit-log, and their default container port is 8030, 9030, 9020, 9010. - ports: [] - # e.g., specify a dedicated node port for FE observer service by containerPort. - # - nodePort: 30030 # The range of valid ports is 30000-32767 - # containerPort: 8030 # The port exported on the container - # specifies the source IP ranges for the load balancer when the type=LoadBalancer. - loadBalancerSourceRanges: [] - # - 10.0.0.0/8 - # imagePullSecrets allows you to use secrets to pull images for pods. - imagePullSecrets: [] - # - name: "image-pull-secret" - # serviceAccount for FE observer access cloud service. - serviceAccount: "" - # If specified, the pod's nodeSelector,displayName="Map of nodeSelectors to match when scheduling pods on nodes" - # Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector - nodeSelector: {} - # kubernetes.io/arch: amd64 - # kubernetes.io/os: linux - # the pod labels for user select or classify pods. - podLabels: {} - # hostAliases allows adding entries to /etc/hosts inside the containers - hostAliases: [] - # - ip: "127.0.0.1" - # hostnames: - # - "example.com" - # schedulerName allows you to specify which scheduler will be used for your pods. - schedulerName: "" - # Additional FE observer container environment variables. - # See https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/ for how to define environment variables. - # Note: If you use slice to define environment variables, and if there are multiple values files, the values in the last values file will take effect. - # If you use a map to define environment variables, the values will be merged. - # You can only use one of the manners to define environment variables. - # To avoid the different types of feEnvVars, we do not define the default value of feEnvVars, e.g., feEnvVars: [] or feEnvVars: {}. - #feEnvVars: - # define environment variables by slice. - # E.g., static environment variable: - # - name: DEMO_GREETING - # value: "Hello from the environment" - # e.g., secret environment variable: - # - name: USERNAME - # valueFrom: - # secretKeyRef: - # name: mysecret - # key: username - # affinity for FE observer pod scheduling. - affinity: {} - # nodeAffinity: - # requiredDuringSchedulingIgnoredDuringExecution: - # nodeSelectorTerms: - # - matchFields: - # - key: metadata.name - # operator: In - # values: - # - target-host-name - # podAntiAffinity: - # requiredDuringSchedulingIgnoredDuringExecution: - # - labelSelector: - # matchExpressions: - # - key: app.kubernetes.io/component - # operator: In - # values: - # - fe-observer - # topologyKey: "kubernetes.io/hostname" - # Node tolerations for FE observer pod scheduling to nodes with taints - # Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ - tolerations: [] - # - key: "key" - # operator: "Equal|Exists" - # value: "value" - # effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" - # topologySpreadConstraints for scheduling pods across failure-domains. - # Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ - topologySpreadConstraints: [] - # - maxSkew: 1 - # topologyKey: topology.kubernetes.io/zone - # whenUnsatisfiable: DoNotSchedule|ScheduleAnyway - # labelSelector: - # matchLabels: - # foo: bar - # resources for FE observer pod. - resources: - requests: - cpu: 4 - memory: 4Gi - # If you want to remove one resource limit, e.g., cpu, you can set it to cpu: "unlimited". - limits: - cpu: 8 - memory: 8Gi - # mount secrets if necessary. - # see https://kubernetes.io/docs/concepts/storage/volumes/#secret for more details. - secrets: [] - # e.g., mount my-secret to /etc/my-secret - # - name: my-secret - # mountPath: /etc/my-secret - # subPath: "" - # mount configmaps if necessary. - # see https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath for more details about subPath. - configMaps: [] - # e.g., mount my-configmap to /etc/my-configmap - # - name: my-configmap - # mountPath: /etc/my-configmap - # subPath: "" - # terminationGracePeriodSeconds defines duration in seconds the FE observer pod needs to terminate gracefully. - # the default value is 120 seconds - terminationGracePeriodSeconds: 120 - - # Please upgrade the CRD with v1.8.7 released version if you want to use the following configuration. - # including: startupProbeFailureSeconds, livenessProbeFailureSeconds, readinessProbeFailureSeconds - - # StartupProbeFailureSeconds defines the total failure seconds of a startup Probe. - # the default value is 300 seconds - # You can set it to "0" to disable the probe. - startupProbeFailureSeconds: - # LivenessProbeFailureSeconds defines the total failure seconds of a liveness Probe. - # the default value is 15 seconds - # You can set it to "0" to disable the probe. - livenessProbeFailureSeconds: - # ReadinessProbeFailureSeconds defines the total failure seconds of a readiness Probe. - # the default value is 15 seconds - # You can set it to "0" to disable the probe. - readinessProbeFailureSeconds: - # Lifecycle describes actions that the management system should take in response to container lifecycle events. - # By default, Operator will add corresponding preStop hooks for different components. You can set postStart hook. - lifecycle: {} - # postStart: - # exec: - # command: - # - /bin/sh - # - -c - # - echo "Hello, world!" - # Sidecars is an optional list of containers that are run in the same pod as the starrocks component. - # You can use this field to launch helper containers that provide additional functionality to the main container. - # See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to define sidecars. - sidecars: [] - # - name: sidecar-container - # image: busybox - # command: ['sh', '-c', 'echo "hello from the sidecar container" >/opt/starrocks/fe/meta/sidecar-data.txt && sleep 3600'] - # sidecarsMap is an optional map of containers that are run in the same pod as the starrocks component. - # The reason for using sidecarsMap please refer to https://github.com/StarRocks/starrocks-kubernetes-operator/issues/618 - # sidecarsMap has higher priority than sidecars, and the key of sidecarsMap is the name of the sidecar container. - sidecarsMap: {} - # sidecar-container: - # image: busybox - # command: ['sh', '-c', 'echo "hello from the sidecar container" >/opt/starrocks/fe/meta/sidecar-data.txt && sleep 3600'] - # initContainers is an optional list of containers that are run in the same pod as the starrocks component. - # You can use this to launch helper containers that run before the main container starts. - # See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to configure a container. - initContainers: [] - # - name: init-container - # image: busybox - # command: ['sh', '-c', 'echo "hello from the init container" >/opt/starrocks/fe/meta/init-data.txt'] - # Share a single process namespace between all the containers in a pod. - # When this is set, containers will be able to view and signal processes from other containers - # in the same pod, and the first process in each container will not be assigned PID 1. - shareProcessNamespace: - # Note: will create emptyDir volume for FE observer, PVC is not supported. - emptyDirs: [] - # e.g., mount an emptyDir volume to /tmp - # - name: tmp-data - # mountPath: /tmp - # mount host paths if necessary. - # Note: This should be used with caution. - hostPaths: [] - # - name: host-data - # mountPath: /var/lib/starrocks - # hostPath: - # path: /data/starrocks - # type: DirectoryOrCreate + # Optional FE observer pods. Observer pods reuse the FE image, resources, scheduling, + # config, env, storage, and services from this starrocksFESpec. + observerSpec: + # specify the FE observer deployment or not. + enabled: false + # number of FE observer pods to deploy. + observerNumber: 1 # spec for compute node, compute node provide compute function. starrocksCnSpec: diff --git a/helm-charts/charts/kube-starrocks/values.yaml b/helm-charts/charts/kube-starrocks/values.yaml index d19232594..4186bd3f9 100644 --- a/helm-charts/charts/kube-starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/values.yaml @@ -629,210 +629,13 @@ starrocks: # When this is set, containers will be able to view and signal processes from other containers # in the same pod, and the first process in each container will not be assigned PID 1. shareProcessNamespace: - - # spec to deploy fe observer. - starrocksFeObserverSpec: - # specify the FE observer deployment or not. - enabled: false - # number of replicas to deploy for a FE observer deployment. - replicas: 1 - image: - # image sliced by "repository:tag" - repository: starrocks/fe-ubuntu - tag: "" - imagePullPolicy: IfNotPresent - # add annotations for FE observer pods. - annotations: {} - # If runAsNonRoot is true, the container is run as a non-root user. - # The userId will be set to 1000, and the groupID will be set to 1000. - runAsNonRoot: false - # Whether this container has a read-only root filesystem. - readOnlyRootFilesystem: false - # add/drop capabilities for FE observer container. - capabilities: {} - # set sysctls for FE observer pod. - sysctls: [] - # specify the service name and port config and serviceType - service: - # the FE observer service type, only supported ClusterIP, NodePort, LoadBalancer - type: "ClusterIP" - # the loadBalancerIP for static ip config when the type=LoadBalancer and loadbalancerIp is not empty. - loadbalancerIP: "" - # add annotations for external FE observer service. - annotations: {} - # Add labels for external FE observer service. The operator may add its own default labels. - labels: {} - # Config the service port for FE observer service. - # To assign a specific port or nodePort to a service, you should specify them by the corresponding name or - # containerPort in the service configuration. If both containerPort and name are specified, containerPort takes precedence. - # For fe, port name can be http, query, rpc, edit-log, and their default container port is 8030, 9030, 9020, 9010. - ports: [] - # e.g., specify a dedicated node port for FE observer service by containerPort. - # - nodePort: 30030 # The range of valid ports is 30000-32767 - # containerPort: 8030 # The port exported on the container - # specifies the source IP ranges for the load balancer when the type=LoadBalancer. - loadBalancerSourceRanges: [] - # - 10.0.0.0/8 - # imagePullSecrets allows you to use secrets to pull images for pods. - imagePullSecrets: [] - # - name: "image-pull-secret" - # serviceAccount for FE observer access cloud service. - serviceAccount: "" - # If specified, the pod's nodeSelector,displayName="Map of nodeSelectors to match when scheduling pods on nodes" - # Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector - nodeSelector: {} - # kubernetes.io/arch: amd64 - # kubernetes.io/os: linux - # the pod labels for user select or classify pods. - podLabels: {} - # hostAliases allows adding entries to /etc/hosts inside the containers - hostAliases: [] - # - ip: "127.0.0.1" - # hostnames: - # - "example.com" - # schedulerName allows you to specify which scheduler will be used for your pods. - schedulerName: "" - # Additional FE observer container environment variables. - # See https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/ for how to define environment variables. - # Note: If you use slice to define environment variables, and if there are multiple values files, the values in the last values file will take effect. - # If you use a map to define environment variables, the values will be merged. - # You can only use one of the manners to define environment variables. - # To avoid the different types of feEnvVars, we do not define the default value of feEnvVars, e.g., feEnvVars: [] or feEnvVars: {}. - #feEnvVars: - # define environment variables by slice. - # E.g., static environment variable: - # - name: DEMO_GREETING - # value: "Hello from the environment" - # e.g., secret environment variable: - # - name: USERNAME - # valueFrom: - # secretKeyRef: - # name: mysecret - # key: username - # affinity for FE observer pod scheduling. - affinity: {} - # nodeAffinity: - # requiredDuringSchedulingIgnoredDuringExecution: - # nodeSelectorTerms: - # - matchFields: - # - key: metadata.name - # operator: In - # values: - # - target-host-name - # podAntiAffinity: - # requiredDuringSchedulingIgnoredDuringExecution: - # - labelSelector: - # matchExpressions: - # - key: app.kubernetes.io/component - # operator: In - # values: - # - fe-observer - # topologyKey: "kubernetes.io/hostname" - # Node tolerations for FE observer pod scheduling to nodes with taints - # Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ - tolerations: [] - # - key: "key" - # operator: "Equal|Exists" - # value: "value" - # effect: "NoSchedule|PreferNoSchedule|NoExecute(1.6 only)" - # topologySpreadConstraints for scheduling pods across failure-domains. - # Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/ - topologySpreadConstraints: [] - # - maxSkew: 1 - # topologyKey: topology.kubernetes.io/zone - # whenUnsatisfiable: DoNotSchedule|ScheduleAnyway - # labelSelector: - # matchLabels: - # foo: bar - # resources for FE observer pod. - resources: - requests: - cpu: 4 - memory: 4Gi - # If you want to remove one resource limit, e.g., cpu, you can set it to cpu: "unlimited". - limits: - cpu: 8 - memory: 8Gi - # mount secrets if necessary. - # see https://kubernetes.io/docs/concepts/storage/volumes/#secret for more details. - secrets: [] - # e.g., mount my-secret to /etc/my-secret - # - name: my-secret - # mountPath: /etc/my-secret - # subPath: "" - # mount configmaps if necessary. - # see https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath for more details about subPath. - configMaps: [] - # e.g., mount my-configmap to /etc/my-configmap - # - name: my-configmap - # mountPath: /etc/my-configmap - # subPath: "" - # terminationGracePeriodSeconds defines duration in seconds the FE observer pod needs to terminate gracefully. - # the default value is 120 seconds - terminationGracePeriodSeconds: 120 - - # Please upgrade the CRD with v1.8.7 released version if you want to use the following configuration. - # including: startupProbeFailureSeconds, livenessProbeFailureSeconds, readinessProbeFailureSeconds - - # StartupProbeFailureSeconds defines the total failure seconds of a startup Probe. - # the default value is 300 seconds - # You can set it to "0" to disable the probe. - startupProbeFailureSeconds: - # LivenessProbeFailureSeconds defines the total failure seconds of a liveness Probe. - # the default value is 15 seconds - # You can set it to "0" to disable the probe. - livenessProbeFailureSeconds: - # ReadinessProbeFailureSeconds defines the total failure seconds of a readiness Probe. - # the default value is 15 seconds - # You can set it to "0" to disable the probe. - readinessProbeFailureSeconds: - # Lifecycle describes actions that the management system should take in response to container lifecycle events. - # By default, Operator will add corresponding preStop hooks for different components. You can set postStart hook. - lifecycle: {} - # postStart: - # exec: - # command: - # - /bin/sh - # - -c - # - echo "Hello, world!" - # Sidecars is an optional list of containers that are run in the same pod as the starrocks component. - # You can use this field to launch helper containers that provide additional functionality to the main container. - # See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to define sidecars. - sidecars: [] - # - name: sidecar-container - # image: busybox - # command: ['sh', '-c', 'echo "hello from the sidecar container" >/opt/starrocks/fe/meta/sidecar-data.txt && sleep 3600'] - # sidecarsMap is an optional map of containers that are run in the same pod as the starrocks component. - # The reason for using sidecarsMap please refer to https://github.com/StarRocks/starrocks-kubernetes-operator/issues/618 - # sidecarsMap has higher priority than sidecars, and the key of sidecarsMap is the name of the sidecar container. - sidecarsMap: {} - # sidecar-container: - # image: busybox - # command: ['sh', '-c', 'echo "hello from the sidecar container" >/opt/starrocks/fe/meta/sidecar-data.txt && sleep 3600'] - # initContainers is an optional list of containers that are run in the same pod as the starrocks component. - # You can use this to launch helper containers that run before the main container starts. - # See https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container for how to configure a container. - initContainers: [] - # - name: init-container - # image: busybox - # command: ['sh', '-c', 'echo "hello from the init container" >/opt/starrocks/fe/meta/init-data.txt'] - # Share a single process namespace between all the containers in a pod. - # When this is set, containers will be able to view and signal processes from other containers - # in the same pod, and the first process in each container will not be assigned PID 1. - shareProcessNamespace: - # Note: will create emptyDir volume for FE observer, PVC is not supported. - emptyDirs: [] - # e.g., mount an emptyDir volume to /tmp - # - name: tmp-data - # mountPath: /tmp - # mount host paths if necessary. - # Note: This should be used with caution. - hostPaths: [] - # - name: host-data - # mountPath: /var/lib/starrocks - # hostPath: - # path: /data/starrocks - # type: DirectoryOrCreate + # Optional FE observer pods. Observer pods reuse the FE image, resources, scheduling, + # config, env, storage, and services from this starrocksFESpec. + observerSpec: + # specify the FE observer deployment or not. + enabled: false + # number of FE observer pods to deploy. + observerNumber: 1 # spec for compute node, compute node provide compute function. starrocksCnSpec: diff --git a/pkg/apis/starrocks/v1/starrockscluster_types.go b/pkg/apis/starrocks/v1/starrockscluster_types.go index 4f34df10a..5d525fdf2 100644 --- a/pkg/apis/starrocks/v1/starrockscluster_types.go +++ b/pkg/apis/starrocks/v1/starrockscluster_types.go @@ -108,9 +108,6 @@ type StarRocksClusterSpec struct { // StarRocksFeSpec define fe configuration for start fe service. StarRocksFeSpec *StarRocksFeSpec `json:"starRocksFeSpec,omitempty"` - // StarRocksFeObserverSpec define fe observer configuration for start fe observer service. - StarRocksFeObserverSpec *StarRocksFeObserverSpec `json:"starRocksFeObserverSpec,omitempty"` - // StarRocksBeSpec define be configuration for start be service. StarRocksBeSpec *StarRocksBeSpec `json:"starRocksBeSpec,omitempty"` @@ -159,15 +156,26 @@ type StarRocksFeSpec struct { // +optional // feEnvVars is a slice of environment variables that are added to the pods, the default is empty. FeEnvVars []corev1.EnvVar `json:"feEnvVars,omitempty"` + + // ObserverSpec configures optional FE observer pods. Observer pods reuse the generic FE resources. + // +optional + ObserverSpec *StarRocksFeObserverSpec `json:"observerSpec,omitempty"` } -// StarRocksFeObserverSpec defines the desired state of fe observer. +// StarRocksFeObserverSpec defines the FE observer options under StarRocksFeSpec. type StarRocksFeObserverSpec struct { - StarRocksComponentSpec `json:",inline"` + // Enabled controls whether FE observer should be reconciled. + Enabled bool `json:"enabled,omitempty"` + // ObserverNumber is the number of desired FE observer Pods. + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:default=1 // +optional - // feEnvVars is a slice of environment variables that are added to the pods, the default is empty. - FeEnvVars []corev1.EnvVar `json:"feEnvVars,omitempty"` + ObserverNumber *int32 `json:"observerNumber,omitempty"` + + ComponentSpec StarRocksComponentSpec `json:"-"` + + FeEnvVars []corev1.EnvVar `json:"-"` } // StarRocksBeSpec defines the desired state of be. @@ -247,7 +255,31 @@ func (spec *StarRocksFeObserverSpec) GetReplicas() *int32 { if spec == nil { return nil } - return spec.StarRocksComponentSpec.GetReplicas() + return spec.ObserverNumber +} + +func (spec *StarRocksFeObserverSpec) IsEnabled() bool { + return spec != nil && spec.Enabled +} + +func (spec *StarRocksFeSpec) IsObserverEnabled() bool { + return spec != nil && spec.ObserverSpec.IsEnabled() +} + +func (spec *StarRocksFeSpec) ToObserverSpec() *StarRocksFeObserverSpec { + if spec == nil || !spec.IsObserverEnabled() { + return nil + } + + observerSpec := spec.ObserverSpec.DeepCopy() + spec.StarRocksComponentSpec.DeepCopyInto(&observerSpec.ComponentSpec) + if spec.FeEnvVars != nil { + observerSpec.FeEnvVars = make([]corev1.EnvVar, len(spec.FeEnvVars)) + for i := range spec.FeEnvVars { + spec.FeEnvVars[i].DeepCopyInto(&observerSpec.FeEnvVars[i]) + } + } + return observerSpec } func (spec *StarRocksBeSpec) GetReplicas() *int32 { @@ -257,6 +289,133 @@ func (spec *StarRocksBeSpec) GetReplicas() *int32 { return spec.StarRocksComponentSpec.GetReplicas() } +func (spec *StarRocksFeObserverSpec) componentSpec() *StarRocksComponentSpec { + if spec == nil { + return &StarRocksComponentSpec{} + } + return &spec.ComponentSpec +} + +func (spec *StarRocksFeObserverSpec) GetAnnotations() map[string]string { + return spec.componentSpec().GetAnnotations() +} + +func (spec *StarRocksFeObserverSpec) GetImagePullSecrets() []corev1.LocalObjectReference { + return spec.componentSpec().GetImagePullSecrets() +} + +func (spec *StarRocksFeObserverSpec) GetSchedulerName() string { + return spec.componentSpec().GetSchedulerName() +} + +func (spec *StarRocksFeObserverSpec) GetNodeSelector() map[string]string { + return spec.componentSpec().GetNodeSelector() +} + +func (spec *StarRocksFeObserverSpec) GetAffinity() *corev1.Affinity { + return spec.componentSpec().GetAffinity() +} + +func (spec *StarRocksFeObserverSpec) GetTopologySpreadConstraints() []corev1.TopologySpreadConstraint { + return spec.componentSpec().GetTopologySpreadConstraints() +} + +func (spec *StarRocksFeObserverSpec) GetTolerations() []corev1.Toleration { + return spec.componentSpec().GetTolerations() +} + +func (spec *StarRocksFeObserverSpec) GetStartupProbeFailureSeconds() *int32 { + return spec.componentSpec().GetStartupProbeFailureSeconds() +} + +func (spec *StarRocksFeObserverSpec) GetLivenessProbeFailureSeconds() *int32 { + return spec.componentSpec().GetLivenessProbeFailureSeconds() +} + +func (spec *StarRocksFeObserverSpec) GetReadinessProbeFailureSeconds() *int32 { + return spec.componentSpec().GetReadinessProbeFailureSeconds() +} + +func (spec *StarRocksFeObserverSpec) GetLifecycle() *corev1.Lifecycle { + return spec.componentSpec().GetLifecycle() +} + +func (spec *StarRocksFeObserverSpec) GetService() *StarRocksService { + return spec.componentSpec().GetService() +} + +func (spec *StarRocksFeObserverSpec) GetShareProcessNamespace() *bool { + return spec.componentSpec().GetShareProcessNamespace() +} + +func (spec *StarRocksFeObserverSpec) GetStorageVolumes() []StorageVolume { + return spec.componentSpec().GetStorageVolumes() +} + +func (spec *StarRocksFeObserverSpec) GetServiceAccount() string { + return spec.componentSpec().GetServiceAccount() +} + +func (spec *StarRocksFeObserverSpec) GetImagePullPolicy() corev1.PullPolicy { + return spec.componentSpec().GetImagePullPolicy() +} + +func (spec *StarRocksFeObserverSpec) GetImage() string { + return spec.componentSpec().GetImage() +} + +func (spec *StarRocksFeObserverSpec) GetHostAliases() []corev1.HostAlias { + return spec.componentSpec().GetHostAliases() +} + +func (spec *StarRocksFeObserverSpec) GetRunAsNonRoot() (*int64, *int64) { + return spec.componentSpec().GetRunAsNonRoot() +} + +func (spec *StarRocksFeObserverSpec) GetTerminationGracePeriodSeconds() *int64 { + return spec.componentSpec().GetTerminationGracePeriodSeconds() +} + +func (spec *StarRocksFeObserverSpec) GetCapabilities() *corev1.Capabilities { + return spec.componentSpec().GetCapabilities() +} + +func (spec *StarRocksFeObserverSpec) GetSidecars() []corev1.Container { + return spec.componentSpec().GetSidecars() +} + +func (spec *StarRocksFeObserverSpec) GetInitContainers() []corev1.Container { + return spec.componentSpec().GetInitContainers() +} + +func (spec *StarRocksFeObserverSpec) IsReadOnlyRootFilesystem() *bool { + return spec.componentSpec().IsReadOnlyRootFilesystem() +} + +func (spec *StarRocksFeObserverSpec) GetSysctls() []corev1.Sysctl { + return spec.componentSpec().GetSysctls() +} + +func (spec *StarRocksFeObserverSpec) GetCommand() []string { + return spec.componentSpec().GetCommand() +} + +func (spec *StarRocksFeObserverSpec) GetArgs() []string { + return spec.componentSpec().GetArgs() +} + +func (spec *StarRocksFeObserverSpec) GetUpdateStrategy() *appsv1.StatefulSetUpdateStrategy { + return spec.componentSpec().GetUpdateStrategy() +} + +func (spec *StarRocksFeObserverSpec) GetMinReadySeconds() *int32 { + return spec.componentSpec().GetMinReadySeconds() +} + +func (spec *StarRocksFeObserverSpec) GetPodManagementPolicy() appsv1.PodManagementPolicyType { + return spec.componentSpec().GetPodManagementPolicy() +} + func (spec *StarRocksCnSpec) GetReplicas() *int32 { if spec == nil { return nil diff --git a/pkg/apis/starrocks/v1/zz_generated.deepcopy.go b/pkg/apis/starrocks/v1/zz_generated.deepcopy.go index 3d9d310c3..644ba5990 100644 --- a/pkg/apis/starrocks/v1/zz_generated.deepcopy.go +++ b/pkg/apis/starrocks/v1/zz_generated.deepcopy.go @@ -290,11 +290,6 @@ func (in *StarRocksClusterSpec) DeepCopyInto(out *StarRocksClusterSpec) { *out = new(StarRocksFeSpec) (*in).DeepCopyInto(*out) } - if in.StarRocksFeObserverSpec != nil { - in, out := &in.StarRocksFeObserverSpec, &out.StarRocksFeObserverSpec - *out = new(StarRocksFeObserverSpec) - (*in).DeepCopyInto(*out) - } if in.StarRocksBeSpec != nil { in, out := &in.StarRocksBeSpec, &out.StarRocksBeSpec *out = new(StarRocksBeSpec) @@ -552,7 +547,12 @@ func (in *StarRocksComponentStatus) DeepCopy() *StarRocksComponentStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StarRocksFeObserverSpec) DeepCopyInto(out *StarRocksFeObserverSpec) { *out = *in - in.StarRocksComponentSpec.DeepCopyInto(&out.StarRocksComponentSpec) + if in.ObserverNumber != nil { + in, out := &in.ObserverNumber, &out.ObserverNumber + *out = new(int32) + **out = **in + } + in.ComponentSpec.DeepCopyInto(&out.ComponentSpec) if in.FeEnvVars != nil { in, out := &in.FeEnvVars, &out.FeEnvVars *out = make([]corev1.EnvVar, len(*in)) @@ -631,6 +631,11 @@ func (in *StarRocksFeSpec) DeepCopyInto(out *StarRocksFeSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.ObserverSpec != nil { + in, out := &in.ObserverSpec, &out.ObserverSpec + *out = new(StarRocksFeObserverSpec) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StarRocksFeSpec. diff --git a/pkg/k8sutils/templates/pod/spec.go b/pkg/k8sutils/templates/pod/spec.go index 3e5d0d92c..dafd759c5 100644 --- a/pkg/k8sutils/templates/pod/spec.go +++ b/pkg/k8sutils/templates/pod/spec.go @@ -79,7 +79,7 @@ func Labels(clusterName string, spec v1.SpecInterface) map[string]string { } case *v1.StarRocksFeObserverSpec: if v != nil { - addLabels(labels, v.PodLabels) + addLabels(labels, v.ComponentSpec.PodLabels) } case *v1.StarRocksFeProxySpec: if v != nil { diff --git a/pkg/k8sutils/templates/statefulset/spec.go b/pkg/k8sutils/templates/statefulset/spec.go index 616a8484d..0cbeeee90 100644 --- a/pkg/k8sutils/templates/statefulset/spec.go +++ b/pkg/k8sutils/templates/statefulset/spec.go @@ -102,6 +102,13 @@ func MakeStatefulset(object srobject.StarRocksObject, spec v1.SpecInterface, pod WhenDeleted: v.PersistentVolumeClaimRetentionPolicy.WhenDeleted, } } + case *v1.StarRocksFeObserverSpec: + if v.ComponentSpec.PersistentVolumeClaimRetentionPolicy != nil { + expectSTS.Spec.PersistentVolumeClaimRetentionPolicy = &appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy{ + WhenScaled: "", + WhenDeleted: v.ComponentSpec.PersistentVolumeClaimRetentionPolicy.WhenDeleted, + } + } case *v1.StarRocksBeSpec: if v.PersistentVolumeClaimRetentionPolicy != nil { expectSTS.Spec.PersistentVolumeClaimRetentionPolicy = &appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy{ diff --git a/pkg/subcontrollers/feobserver/feobserver_config.go b/pkg/subcontrollers/feobserver/feobserver_config.go index fb8dbb16c..2e318f0ae 100644 --- a/pkg/subcontrollers/feobserver/feobserver_config.go +++ b/pkg/subcontrollers/feobserver/feobserver_config.go @@ -13,7 +13,7 @@ import ( // GetFEObserverConfig get the fe observer config from configMap. func GetFEObserverConfig(ctx context.Context, client client.Client, observerSpec *srapi.StarRocksFeObserverSpec, namespace string) (map[string]interface{}, error) { - return k8sutils.GetConfig(ctx, client, observerSpec.ConfigMapInfo, - observerSpec.ConfigMaps, pod.GetConfigDir(observerSpec), "fe.conf", + return k8sutils.GetConfig(ctx, client, observerSpec.ComponentSpec.ConfigMapInfo, + observerSpec.ComponentSpec.ConfigMaps, pod.GetConfigDir(observerSpec), "fe.conf", namespace) } diff --git a/pkg/subcontrollers/feobserver/feobserver_controller.go b/pkg/subcontrollers/feobserver/feobserver_controller.go index c4136e4f4..0e7ce98fb 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller.go @@ -18,14 +18,12 @@ package feobserver import ( "context" - "fmt" "github.com/go-logr/logr" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" @@ -36,7 +34,6 @@ import ( "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/load" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/object" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/pod" - "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/service" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/statefulset" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers" ) @@ -63,13 +60,16 @@ func (fc *FeObserverController) GetControllerName() string { func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.StarRocksCluster) error { logger := logr.FromContextOrDiscard(ctx).WithName(fc.GetControllerName()).WithValues(log.ActionKey, log.ActionSyncCluster) ctx = logr.NewContext(ctx, logger) - if src.Spec.StarRocksFeObserverSpec == nil { - logger.Info("src.Spec.StarRocksFeObserverSpec == nil, skip sync fe observer") + feSpec := src.Spec.StarRocksFeSpec + observerSpec := feSpec.ToObserverSpec() + if observerSpec == nil { + logger.Info("fe observer is disabled, clear observer resources") + if err := fc.clearObserverResources(ctx, src); err != nil { + logger.Error(err, "clear fe observer resources failed") + return err + } return nil } - if src.Spec.StarRocksFeSpec == nil { - return fmt.Errorf("starRocksFeSpec is required before deploying fe observer") - } var err error defer func() { @@ -79,33 +79,21 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star } }() - observerSpec := src.Spec.StarRocksFeObserverSpec - if err = fc.Validating(observerSpec); err != nil { + if err = fc.Validating(feSpec); err != nil { return err } // get the fe observer configMap for resolve ports - logger.V(log.DebugLevel).Info("get fe observer configMap to resolve ports", "ConfigMapInfo", observerSpec.ConfigMapInfo) + logger.V(log.DebugLevel).Info("get fe observer configMap to resolve ports", "ConfigMapInfo", observerSpec.ComponentSpec.ConfigMapInfo) observerConfig, err := GetFEObserverConfig(ctx, fc.Client, observerSpec, src.Namespace) if err != nil { - logger.Error(err, "get fe observer config failed", "ConfigMapInfo", observerSpec.ConfigMapInfo) + logger.Error(err, "get fe observer config failed", "ConfigMapInfo", observerSpec.ComponentSpec.ConfigMapInfo) return err } - // generate new fe observer service. - logger.V(log.DebugLevel).Info("build fe observer service", "StarRocksCluster", src) + // generate new fe observer statefulset. + logger.V(log.DebugLevel).Info("build fe observer statefulset", "StarRocksCluster", src) object := object.NewFromCluster(src) - defaultLabels := load.Labels(src.Name, observerSpec) - svc := rutils.BuildExternalService(object, observerSpec, observerConfig, load.Selector(src.Name, observerSpec), defaultLabels) - searchServiceName := service.SearchServiceName(src.Name, observerSpec) - internalService := service.MakeSearchService(searchServiceName, &svc, []corev1.ServicePort{ - { - Name: "query-port", - Port: rutils.GetPort(observerConfig, rutils.QUERY_PORT), - TargetPort: intstr.FromInt(int(rutils.GetPort(observerConfig, rutils.QUERY_PORT))), - AppProtocol: func() *string { mysql := "mysql"; return &mysql }(), - }, - }, defaultLabels) podTemplateSpec, err := fc.buildPodTemplate(src, observerConfig) if err != nil { @@ -113,20 +101,15 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star return err } expectSts := statefulset.MakeStatefulset(object, observerSpec, podTemplateSpec) + expectSts.Spec.ServiceName = feSearchServiceName(src.Name) err = k8sutils.ApplyStatefulSet(ctx, fc.Client, &expectSts, false, rutils.StatefulSetDeepEqual) if err != nil { logger.Error(err, "fe observer statefulset failed", "StarRocksCluster", src) return err } - if err = k8sutils.ApplyService(ctx, fc.Client, internalService, rutils.ServiceDeepEqual); err != nil { - logger.Error(err, "deploy search service failed", "internalService", internalService) - fc.Recorder.Event(src, corev1.EventTypeWarning, "DeployFeObserverFailed", err.Error()) - return err - } - - if err = k8sutils.ApplyService(ctx, fc.Client, &svc, rutils.ServiceDeepEqual); err != nil { - logger.Error(err, "deploy external service failed", "externalService", svc) + if err = fc.deleteLegacyObserverServices(ctx, src); err != nil { + logger.Error(err, "delete legacy fe observer services failed") return err } @@ -135,7 +118,8 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star // UpdateClusterStatus update the all resource status about fe observer. func (fc *FeObserverController) UpdateClusterStatus(_ context.Context, src *srapi.StarRocksCluster) error { - observerSpec := src.Spec.StarRocksFeObserverSpec + feSpec := src.Spec.StarRocksFeSpec + observerSpec := feSpec.ToObserverSpec() if observerSpec == nil { src.Status.StarRocksFeObserverStatus = nil return nil @@ -152,7 +136,7 @@ func (fc *FeObserverController) UpdateClusterStatus(_ context.Context, src *srap } src.Status.StarRocksFeObserverStatus = fs - fs.ServiceName = service.ExternalServiceName(src.Name, observerSpec) + fs.ServiceName = feExternalServiceName(src.Name) statefulSetName := load.Name(src.Name, observerSpec) fs.ResourceNames = rutils.MergeSlices(fs.ResourceNames, []string{statefulSetName}) @@ -182,36 +166,45 @@ func (fc *FeObserverController) ClearCluster(ctx context.Context, src *srapi.Sta return nil } - observerSpec := src.Spec.StarRocksFeObserverSpec - statefulSetName := load.Name(src.Name, observerSpec) + return fc.clearObserverResources(ctx, src) +} + +func (fc *FeObserverController) Validating(feSpec *srapi.StarRocksFeSpec) error { + for i := range feSpec.StorageVolumes { + if err := feSpec.StorageVolumes[i].Validate(); err != nil { + return err + } + } + if err := srapi.ValidUpdateStrategy(feSpec.UpdateStrategy); err != nil { + return err + } + return nil +} + +func (fc *FeObserverController) clearObserverResources(ctx context.Context, src *srapi.StarRocksCluster) error { + statefulSetName := load.Name(src.Name, (*srapi.StarRocksFeObserverSpec)(nil)) if err := k8sutils.DeleteStatefulset(ctx, fc.Client, src.Namespace, statefulSetName); err != nil && !apierrors.IsNotFound(err) { - logger.Error(err, "delete statefulset failed", "statefulSetName", statefulSetName) return err } + return fc.deleteLegacyObserverServices(ctx, src) +} - searchServiceName := service.SearchServiceName(src.Name, observerSpec) +func (fc *FeObserverController) deleteLegacyObserverServices(ctx context.Context, src *srapi.StarRocksCluster) error { + searchServiceName := src.Name + "-" + srapi.DEFAULT_FE_OBSERVER + "-search" if err := k8sutils.DeleteService(ctx, fc.Client, src.Namespace, searchServiceName); err != nil && !apierrors.IsNotFound(err) { - logger.Error(err, "delete search service failed", "searchServiceName", searchServiceName) return err } - externalServiceName := service.ExternalServiceName(src.Name, observerSpec) - err := k8sutils.DeleteService(ctx, fc.Client, src.Namespace, externalServiceName) - if err != nil && !apierrors.IsNotFound(err) { - logger.Error(err, "delete external service failed", "externalServiceName", externalServiceName) + externalServiceName := src.Name + "-" + srapi.DEFAULT_FE_OBSERVER + "-service" + if err := k8sutils.DeleteService(ctx, fc.Client, src.Namespace, externalServiceName); err != nil && !apierrors.IsNotFound(err) { return err } - return nil } -func (fc *FeObserverController) Validating(observerSpec *srapi.StarRocksFeObserverSpec) error { - for i := range observerSpec.StorageVolumes { - if err := observerSpec.StorageVolumes[i].Validate(); err != nil { - return err - } - } - if err := srapi.ValidUpdateStrategy(observerSpec.UpdateStrategy); err != nil { - return err - } - return nil +func feExternalServiceName(clusterName string) string { + return clusterName + "-" + srapi.DEFAULT_FE + "-service" +} + +func feSearchServiceName(clusterName string) string { + return clusterName + "-" + srapi.DEFAULT_FE + "-search" } diff --git a/pkg/subcontrollers/feobserver/feobserver_controller_test.go b/pkg/subcontrollers/feobserver/feobserver_controller_test.go index c430a765b..96c9d7579 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller_test.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller_test.go @@ -35,7 +35,6 @@ import ( srapi "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1" rutils "github.com/StarRocks/starrocks-kubernetes-operator/pkg/common/resource_utils" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/fake" - "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/load" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/service" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/fe" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/feobserver" @@ -65,23 +64,29 @@ func TestFeObserver_ClearCluster(t *testing.T) { }, } + src.Spec.StarRocksFeSpec = &srapi.StarRocksFeSpec{ + ObserverSpec: &srapi.StarRocksFeObserverSpec{ + Enabled: true, + }, + } + sts := appsv1.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ - Name: load.Name(src.Name, src.Spec.StarRocksFeObserverSpec), + Name: "test-fe-observer", Namespace: "default", }, } svc := corev1.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: service.ExternalServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), + Name: "test-fe-observer-service", Namespace: "default", }, } ssvc := corev1.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: service.SearchServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), + Name: "test-fe-observer-search", Namespace: "default", }, } @@ -111,15 +116,8 @@ func TestFeObserver_SyncCluster(t *testing.T) { StarRocksFeSpec: &srapi.StarRocksFeSpec{ StarRocksComponentSpec: srapi.StarRocksComponentSpec{ StarRocksLoadSpec: srapi.StarRocksLoadSpec{ - Image: "starrocks.com/cn:2.40", - }, - }, - }, - StarRocksFeObserverSpec: &srapi.StarRocksFeObserverSpec{ - StarRocksComponentSpec: srapi.StarRocksComponentSpec{ - StarRocksLoadSpec: srapi.StarRocksLoadSpec{ - Replicas: rutils.GetInt32Pointer(1), - Image: "starrocks.com/cn:2.40", + Replicas: rutils.GetInt32Pointer(3), + Image: "starrocks.com/fe:2.40", ResourceRequirements: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: *resource.NewQuantity(4, resource.DecimalSI), @@ -128,6 +126,10 @@ func TestFeObserver_SyncCluster(t *testing.T) { }, }, }, + ObserverSpec: &srapi.StarRocksFeObserverSpec{ + Enabled: true, + ObserverNumber: rutils.GetInt32Pointer(2), + }, }, }, } @@ -141,19 +143,65 @@ func TestFeObserver_SyncCluster(t *testing.T) { status := src.Status.StarRocksFeObserverStatus require.NotNil(t, status) require.Equal(t, srapi.ComponentReconciling, status.Phase) - require.Equal(t, service.ExternalServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), status.ServiceName) + require.Equal(t, service.ExternalServiceName(src.Name, src.Spec.StarRocksFeSpec), status.ServiceName) var sts appsv1.StatefulSet require.NoError(t, fc.Client.Get(context.Background(), - types.NamespacedName{Name: load.Name(src.Name, src.Spec.StarRocksFeObserverSpec), Namespace: "default"}, &sts)) - var asvc corev1.Service - require.NoError(t, fc.Client.Get(context.Background(), - types.NamespacedName{Name: service.ExternalServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), Namespace: "default"}, &asvc)) - var rsvc corev1.Service - require.NoError(t, fc.Client.Get(context.Background(), - types.NamespacedName{Name: service.SearchServiceName(src.Name, src.Spec.StarRocksFeObserverSpec), Namespace: "default"}, &rsvc)) + types.NamespacedName{Name: "test-fe-observer", Namespace: "default"}, &sts)) + require.Equal(t, int32(2), *sts.Spec.Replicas) + var observerExternalSvc corev1.Service + err = fc.Client.Get(context.Background(), + types.NamespacedName{Name: "test-fe-observer-service", Namespace: "default"}, &observerExternalSvc) + require.True(t, apierrors.IsNotFound(err)) + var observerSearchSvc corev1.Service + err = fc.Client.Get(context.Background(), + types.NamespacedName{Name: "test-fe-observer-search", Namespace: "default"}, &observerSearchSvc) + require.True(t, apierrors.IsNotFound(err)) + + require.Equal(t, service.SearchServiceName(src.Name, src.Spec.StarRocksFeSpec), sts.Spec.ServiceName) + require.Equal(t, map[string]string{ + srapi.OwnerReference: "test-fe-observer", + srapi.ComponentLabelKey: srapi.DEFAULT_FE_OBSERVER, + }, sts.Spec.Selector.MatchLabels) + require.Equal(t, "starrocks.com/fe:2.40", sts.Spec.Template.Spec.Containers[0].Image) + require.Equal(t, corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("4"), + corev1.ResourceMemory: resource.MustParse("16G"), + }, sts.Spec.Template.Spec.Containers[0].Resources.Requests) + require.Equal(t, []string{"$(FE_SERVICE_NAME)"}, sts.Spec.Template.Spec.Containers[0].Args) +} + +func TestFeObserver_SyncClusterDisabled(t *testing.T) { + src := &srapi.StarRocksCluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + Namespace: "default", + }, + Spec: srapi.StarRocksClusterSpec{ + StarRocksFeSpec: &srapi.StarRocksFeSpec{ + StarRocksComponentSpec: srapi.StarRocksComponentSpec{ + StarRocksLoadSpec: srapi.StarRocksLoadSpec{ + Image: "starrocks.com/fe:2.40", + }, + }, + ObserverSpec: &srapi.StarRocksFeObserverSpec{ + Enabled: false, + }, + }, + }, + } - require.Equal(t, asvc.Spec.Selector, sts.Spec.Selector.MatchLabels) + fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src), fake.GetEventRecorderFor(nil)) + err := fc.SyncCluster(context.Background(), src) + require.NoError(t, err) + err = fc.UpdateClusterStatus(context.Background(), src) + require.NoError(t, err) + require.Nil(t, src.Status.StarRocksFeObserverStatus) + + var sts appsv1.StatefulSet + err = fc.Client.Get(context.Background(), + types.NamespacedName{Name: "test-fe-observer", Namespace: "default"}, &sts) + require.True(t, apierrors.IsNotFound(err)) } func TestFeObserver_Ready(t *testing.T) { @@ -257,7 +305,7 @@ func TestGetFEObserverConfig(t *testing.T) { args: args{ ctx: context.Background(), observerSpec: &srapi.StarRocksFeObserverSpec{ - StarRocksComponentSpec: srapi.StarRocksComponentSpec{ + ComponentSpec: srapi.StarRocksComponentSpec{ StarRocksLoadSpec: srapi.StarRocksLoadSpec{ ConfigMapInfo: srapi.ConfigMapInfo{ ConfigMapName: "feobserver-config", @@ -288,7 +336,7 @@ func TestGetFEObserverConfig(t *testing.T) { args: args{ ctx: context.Background(), observerSpec: &srapi.StarRocksFeObserverSpec{ - StarRocksComponentSpec: srapi.StarRocksComponentSpec{ + ComponentSpec: srapi.StarRocksComponentSpec{ ConfigMaps: []srapi.ConfigMapReference{ { Name: "feobserver-config", diff --git a/pkg/subcontrollers/feobserver/feobserver_pod.go b/pkg/subcontrollers/feobserver/feobserver_pod.go index e790b647f..f4371de97 100644 --- a/pkg/subcontrollers/feobserver/feobserver_pod.go +++ b/pkg/subcontrollers/feobserver/feobserver_pod.go @@ -38,7 +38,8 @@ const ( func (fc *FeObserverController) buildPodTemplate(src *srapi.StarRocksCluster, config map[string]interface{}) (*corev1.PodTemplateSpec, error) { metaName := src.Name + "-" + srapi.DEFAULT_FE_OBSERVER - observerSpec := src.Spec.StarRocksFeObserverSpec + observerSpec := src.Spec.StarRocksFeSpec.ToObserverSpec() + componentSpec := observerSpec.ComponentSpec vols, volMounts := pod.MountStorageVolumes(observerSpec) // add default volume about log, meta if not configure. @@ -50,28 +51,28 @@ func (fc *FeObserverController) buildPodTemplate(src *srapi.StarRocksCluster, } // mount configmap, secrets to pod if needed - vols, volMounts = pod.MountConfigMapInfo(vols, volMounts, observerSpec.ConfigMapInfo, _feConfigMountPath) - vols, volMounts = pod.MountConfigMaps(observerSpec, vols, volMounts, observerSpec.ConfigMaps) - vols, volMounts = pod.MountSecrets(vols, volMounts, observerSpec.Secrets) + vols, volMounts = pod.MountConfigMapInfo(vols, volMounts, componentSpec.ConfigMapInfo, _feConfigMountPath) + vols, volMounts = pod.MountConfigMaps(observerSpec, vols, volMounts, componentSpec.ConfigMaps) + vols, volMounts = pod.MountSecrets(vols, volMounts, componentSpec.Secrets) if err := k8sutils.CheckVolumes(vols, volMounts); err != nil { return nil, err } - feServiceName := service.ExternalServiceName(src.Name, src.Spec.StarRocksFeObserverSpec) + feServiceName := service.ExternalServiceName(src.Name, src.Spec.StarRocksFeSpec) envs := pod.Envs(observerSpec, config, feServiceName, src.Namespace, observerSpec.FeEnvVars) envs = append(envs, corev1.EnvVar{ Name: srapi.FE_SERVICE_NAME, - Value: service.ExternalServiceName(src.Name, src.Spec.StarRocksFeSpec), + Value: feServiceName, }) httpPort := rutils.GetPort(config, rutils.HTTP_PORT) feObserverContainer := corev1.Container{ Name: srapi.DEFAULT_FE_OBSERVER, - Image: observerSpec.Image, + Image: componentSpec.Image, Command: pod.ContainerCommand(observerSpec), Args: pod.ContainerArgs(observerSpec), Ports: pod.Ports(observerSpec, config), Env: envs, - Resources: observerSpec.ResourceRequirements, + Resources: componentSpec.ResourceRequirements, VolumeMounts: volMounts, ImagePullPolicy: observerSpec.GetImagePullPolicy(), StartupProbe: pod.StartupProbe(observerSpec.GetStartupProbeFailureSeconds(), httpPort, pod.HEALTH_API_PATH), @@ -84,7 +85,7 @@ func (fc *FeObserverController) buildPodTemplate(src *srapi.StarRocksCluster, feObserverContainer.WorkingDir = pod.GetStarRocksRootPath(observerSpec.FeEnvVars) } - if observerSpec.ConfigMapInfo.ConfigMapName != "" && observerSpec.ConfigMapInfo.ResolveKey != "" { + if componentSpec.ConfigMapInfo.ConfigMapName != "" && componentSpec.ConfigMapInfo.ResolveKey != "" { feObserverContainer.Env = append(feObserverContainer.Env, corev1.EnvVar{ Name: _envFeConfigMountPath, Value: _feConfigMountPath, From 31ee6230720e6b873572c9b45b6b999a56348f2d Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Mon, 1 Jun 2026 17:57:01 +0800 Subject: [PATCH 10/22] fix Signed-off-by: zhaohehuhu --- .../feobserver/feobserver_config.go | 19 ---- .../feobserver/feobserver_controller.go | 11 +- .../feobserver/feobserver_controller_test.go | 107 ------------------ 3 files changed, 6 insertions(+), 131 deletions(-) delete mode 100644 pkg/subcontrollers/feobserver/feobserver_config.go diff --git a/pkg/subcontrollers/feobserver/feobserver_config.go b/pkg/subcontrollers/feobserver/feobserver_config.go deleted file mode 100644 index 2e318f0ae..000000000 --- a/pkg/subcontrollers/feobserver/feobserver_config.go +++ /dev/null @@ -1,19 +0,0 @@ -package feobserver - -import ( - "context" - - "sigs.k8s.io/controller-runtime/pkg/client" - - srapi "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1" - "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils" - "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/pod" -) - -// GetFEObserverConfig get the fe observer config from configMap. -func GetFEObserverConfig(ctx context.Context, client client.Client, - observerSpec *srapi.StarRocksFeObserverSpec, namespace string) (map[string]interface{}, error) { - return k8sutils.GetConfig(ctx, client, observerSpec.ComponentSpec.ConfigMapInfo, - observerSpec.ComponentSpec.ConfigMaps, pod.GetConfigDir(observerSpec), "fe.conf", - namespace) -} diff --git a/pkg/subcontrollers/feobserver/feobserver_controller.go b/pkg/subcontrollers/feobserver/feobserver_controller.go index 0e7ce98fb..ffd5e5e56 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller.go @@ -36,6 +36,7 @@ import ( "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/pod" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/statefulset" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/fe" ) type FeObserverController struct { @@ -83,11 +84,11 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star return err } - // get the fe observer configMap for resolve ports - logger.V(log.DebugLevel).Info("get fe observer configMap to resolve ports", "ConfigMapInfo", observerSpec.ComponentSpec.ConfigMapInfo) - observerConfig, err := GetFEObserverConfig(ctx, fc.Client, observerSpec, src.Namespace) + // get the fe configMap for resolve ports + logger.V(log.DebugLevel).Info("get fe configMap to resolve ports", "ConfigMapInfo", feSpec.ConfigMapInfo) + feConfig, err := fe.GetFEConfig(ctx, fc.Client, feSpec, src.Namespace) if err != nil { - logger.Error(err, "get fe observer config failed", "ConfigMapInfo", observerSpec.ComponentSpec.ConfigMapInfo) + logger.Error(err, "get fe config failed", "ConfigMapInfo", feSpec.ConfigMapInfo) return err } @@ -95,7 +96,7 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star logger.V(log.DebugLevel).Info("build fe observer statefulset", "StarRocksCluster", src) object := object.NewFromCluster(src) - podTemplateSpec, err := fc.buildPodTemplate(src, observerConfig) + podTemplateSpec, err := fc.buildPodTemplate(src, feConfig) if err != nil { logger.Error(err, "build pod template failed") return err diff --git a/pkg/subcontrollers/feobserver/feobserver_controller_test.go b/pkg/subcontrollers/feobserver/feobserver_controller_test.go index 96c9d7579..7952cc476 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller_test.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller_test.go @@ -19,7 +19,6 @@ package feobserver_test import ( "context" "os" - "reflect" "testing" "time" @@ -272,109 +271,3 @@ func TestFeObserver_Ready(t *testing.T) { }) } } - -func TestGetFEObserverConfig(t *testing.T) { - type args struct { - ctx context.Context - observerSpec *srapi.StarRocksFeObserverSpec - namespace string - } - type fields struct { - k8sClient client.Client - } - tests := []struct { - name string - fields fields - args args - want map[string]interface{} - wantErr bool - }{ - { - name: "get config from ConfigMapInfo", - fields: fields{ - k8sClient: fake.NewFakeClient(srapi.Scheme, &corev1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{ - Name: "feobserver-config", - Namespace: "default", - }, - Data: map[string]string{ - "fe.conf": "aa = bb", - }, - }), - }, - args: args{ - ctx: context.Background(), - observerSpec: &srapi.StarRocksFeObserverSpec{ - ComponentSpec: srapi.StarRocksComponentSpec{ - StarRocksLoadSpec: srapi.StarRocksLoadSpec{ - ConfigMapInfo: srapi.ConfigMapInfo{ - ConfigMapName: "feobserver-config", - ResolveKey: "fe.conf", - }, - }, - }, - }, - namespace: "default", - }, - want: map[string]interface{}{ - "aa": "bb", - }, - }, - { - name: "get config from configMaps with matching subpath", - fields: fields{ - k8sClient: fake.NewFakeClient(srapi.Scheme, &corev1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{ - Name: "feobserver-config", - Namespace: "default", - }, - Data: map[string]string{ - "fe.conf": "cc = dd", - }, - }), - }, - args: args{ - ctx: context.Background(), - observerSpec: &srapi.StarRocksFeObserverSpec{ - ComponentSpec: srapi.StarRocksComponentSpec{ - ConfigMaps: []srapi.ConfigMapReference{ - { - Name: "feobserver-config", - MountPath: "/opt/starrocks/fe/conf/fe.conf", - SubPath: "fe.conf", - }, - }, - }, - }, - namespace: "default", - }, - want: map[string]interface{}{ - "cc": "dd", - }, - }, - { - name: "get empty config", - fields: fields{ - k8sClient: fake.NewFakeClient(srapi.Scheme), - }, - args: args{ - ctx: context.Background(), - observerSpec: &srapi.StarRocksFeObserverSpec{}, - namespace: "default", - }, - want: map[string]interface{}{}, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := feobserver.GetFEObserverConfig(tt.args.ctx, tt.fields.k8sClient, tt.args.observerSpec, tt.args.namespace) - if (err != nil) != tt.wantErr { - t.Errorf("GetFEObserverConfig() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetFEObserverConfig() got = %v, want %v", got, tt.want) - } - }) - } -} From 2a3caf2b6bc61eef35faec817dbfc242fa5c80d2 Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Fri, 5 Jun 2026 18:07:07 +0800 Subject: [PATCH 11/22] refactor and add docs Signed-off-by: zhaohehuhu --- .../starrocks.com_starrocksclusters.yaml | 7 +- doc/scale_fe_observer_howto.md | 56 +++++++++++ .../charts/starrocks/values.yaml | 4 + helm-charts/charts/kube-starrocks/values.yaml | 4 + pkg/k8sutils/templates/pod/spec.go | 4 + .../feobserver/feobserver_controller.go | 97 ++++++++++++------- .../feobserver/feobserver_controller_test.go | 82 ++++++++++++++-- 7 files changed, 209 insertions(+), 45 deletions(-) create mode 100644 doc/scale_fe_observer_howto.md diff --git a/config/crd/bases/starrocks.com_starrocksclusters.yaml b/config/crd/bases/starrocks.com_starrocksclusters.yaml index c60987647..88ac5c157 100644 --- a/config/crd/bases/starrocks.com_starrocksclusters.yaml +++ b/config/crd/bases/starrocks.com_starrocksclusters.yaml @@ -13602,8 +13602,11 @@ spec: of nodeSelectors to match when scheduling pods on nodes" type: object observerSpec: - description: ObserverSpec configures optional FE observer pods. - Observer pods reuse the generic FE resources. + description: |- + ObserverSpec configures optional FE observer pods. Observer pods reuse the generic FE resources. + The FE image must be StarRocks 4.1.0 or later. Removing observers does not automatically + run ALTER SYSTEM DROP OBSERVER; manually drop observer nodes + if SHOW FRONTENDS reports Alive = false. properties: enabled: description: Enabled controls whether FE observer should be diff --git a/doc/scale_fe_observer_howto.md b/doc/scale_fe_observer_howto.md new file mode 100644 index 000000000..99afea529 --- /dev/null +++ b/doc/scale_fe_observer_howto.md @@ -0,0 +1,56 @@ +# Scale FE observer Howto + +## Overview + +FE observers are mainly used to increase the query concurrency of a StarRocks cluster. Unlike FE followers, observers do +not participate in leader election, so adding observers does not add leader selection pressure to the cluster. + +Use `starRocksFeSpec.observerSpec` when the cluster needs more FE read capacity without changing the FE follower quorum. +Observers can be scaled with the read workload, while FE followers should still be scaled carefully because they store +metadata and participate in quorum. + +## How to correctly scale out FE read workloads by observer + +FE observers can be used to scale FE read workloads without changing the FE follower quorum. To use +`starRocksFeSpec.observerSpec`, the FE image configured in `starRocksFeSpec.image` must be StarRocks 4.1.0 or later. +The operator rejects FE observer deployment for older FE image versions because those images do not enable FE observer. + +To scale FE observers out, enable `observerSpec` and set the desired observer count: + +```yaml +starRocksFeSpec: + image: "starrocks/fe-ubuntu:4.1.0" + observerSpec: + enabled: true + observerNumber: 2 +``` + +## How to correctly scale in FE observer + +Known limitation: neither the operator nor `fe_entrypoint.sh` runs `ALTER SYSTEM DROP OBSERVER` when observers are +removed. If you decrease `starRocksFeSpec.observerSpec.observerNumber` or set +`starRocksFeSpec.observerSpec.enabled: false`, the observer Pods are removed from Kubernetes, but the removed observers +can remain in StarRocks metadata and appear as permanent `Alive=false` rows in `SHOW FRONTENDS`. Because observers are +intended for dynamic read-workload scaling, stale observer rows can accumulate after repeated scale-in operations. + +For planned observer scale-in, manually drop the observers that will be removed before lowering `observerNumber`. + +1. Execute `SHOW FRONTENDS` and find the `OBSERVER` rows for the observer Pods that will be removed. + +2. Drop each observer from StarRocks metadata by using its FE host and `EditLogPort` from `SHOW FRONTENDS`. + ```sql + mysql> ALTER SYSTEM DROP OBSERVER ":"; + ``` + + For example: + ```sql + mysql> ALTER SYSTEM DROP OBSERVER "kube-starrocks-fe-observer-1.kube-starrocks-fe-observer-search.default.svc.cluster.local:9010"; + ``` + +3. Lower `starRocksFeSpec.observerSpec.observerNumber`, or set `starRocksFeSpec.observerSpec.enabled: false` if all + observers should be removed. + +4. Execute `SHOW FRONTENDS` again and verify the removed observer rows are gone. + +If the observer Pods were already removed from Kubernetes, connect to an FE node, run `SHOW FRONTENDS`, find `OBSERVER` +rows with `Alive=false`, and run `ALTER SYSTEM DROP OBSERVER ":"` for each stale row. diff --git a/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml b/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml index 1795501cb..a8c472521 100644 --- a/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml @@ -515,6 +515,10 @@ starrocksFESpec: shareProcessNamespace: # Optional FE observer pods. Observer pods reuse the FE image, resources, scheduling, # config, env, storage, and services from this starrocksFESpec. + # FE observer requires the FE image tag to be StarRocks 4.1.0 or later. + # Known limitation: scaling observerNumber down or disabling observerSpec removes + # Kubernetes pods, but does not run ALTER SYSTEM DROP OBSERVER. Manually drop + # observer nodes if SHOW FRONTENDS reports Alive = false. observerSpec: # specify the FE observer deployment or not. enabled: false diff --git a/helm-charts/charts/kube-starrocks/values.yaml b/helm-charts/charts/kube-starrocks/values.yaml index 4186bd3f9..1c3892468 100644 --- a/helm-charts/charts/kube-starrocks/values.yaml +++ b/helm-charts/charts/kube-starrocks/values.yaml @@ -631,6 +631,10 @@ starrocks: shareProcessNamespace: # Optional FE observer pods. Observer pods reuse the FE image, resources, scheduling, # config, env, storage, and services from this starrocksFESpec. + # FE observer requires the FE image tag to be StarRocks 4.1.0 or later. + # Known limitation: scaling observerNumber down or disabling observerSpec removes + # Kubernetes pods, but does not run ALTER SYSTEM DROP OBSERVER. Manually drop + # observer nodes if SHOW FRONTENDS reports Alive = false. observerSpec: # specify the FE observer deployment or not. enabled: false diff --git a/pkg/k8sutils/templates/pod/spec.go b/pkg/k8sutils/templates/pod/spec.go index dafd759c5..2621e7669 100644 --- a/pkg/k8sutils/templates/pod/spec.go +++ b/pkg/k8sutils/templates/pod/spec.go @@ -173,6 +173,10 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, Name: v1.IS_FE_OBSERVER, Value: "true", }, + { + Name: v1.FE_SERVICE_NAME, + Value: feExternalServiceName, + }, } { addEnv(envVar) } diff --git a/pkg/subcontrollers/feobserver/feobserver_controller.go b/pkg/subcontrollers/feobserver/feobserver_controller.go index ffd5e5e56..c553aa0de 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller.go @@ -18,12 +18,15 @@ package feobserver import ( "context" + "fmt" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/service" "github.com/go-logr/logr" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" @@ -39,6 +42,8 @@ import ( "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/fe" ) +const minFeObserverImageVersion = "4.1.0" + type FeObserverController struct { Client client.Client Recorder record.EventRecorder @@ -64,13 +69,12 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star feSpec := src.Spec.StarRocksFeSpec observerSpec := feSpec.ToObserverSpec() if observerSpec == nil { - logger.Info("fe observer is disabled, clear observer resources") - if err := fc.clearObserverResources(ctx, src); err != nil { - logger.Error(err, "clear fe observer resources failed") - return err - } + logger.Info("src.Spec.StarRocksFeObserverSpec == nil, skip sync fe observer") return nil } + if src.Spec.StarRocksFeSpec == nil { + return fmt.Errorf("starRocksFeSpec is required before deploying fe observer") + } var err error defer func() { @@ -84,6 +88,10 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star return err } + if !fe.CheckFEReady(ctx, fc.Client, src.Namespace, src.Name) { + logger.Info("FE is not ready, stop sync fe observer") + return nil + } // get the fe configMap for resolve ports logger.V(log.DebugLevel).Info("get fe configMap to resolve ports", "ConfigMapInfo", feSpec.ConfigMapInfo) feConfig, err := fe.GetFEConfig(ctx, fc.Client, feSpec, src.Namespace) @@ -95,30 +103,44 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star // generate new fe observer statefulset. logger.V(log.DebugLevel).Info("build fe observer statefulset", "StarRocksCluster", src) object := object.NewFromCluster(src) - + defaultLabels := load.Labels(src.Name, observerSpec) + svc := rutils.BuildExternalService(object, observerSpec, feConfig, load.Selector(src.Name, observerSpec), defaultLabels) + searchServiceName := service.SearchServiceName(src.Name, observerSpec) + internalService := service.MakeSearchService(searchServiceName, &svc, []corev1.ServicePort{ + { + Name: "query-port", + Port: rutils.GetPort(feConfig, rutils.QUERY_PORT), + TargetPort: intstr.FromInt(int(rutils.GetPort(feConfig, rutils.QUERY_PORT))), + AppProtocol: func() *string { mysql := "mysql"; return &mysql }(), + }, + }, defaultLabels) podTemplateSpec, err := fc.buildPodTemplate(src, feConfig) if err != nil { logger.Error(err, "build pod template failed") return err } expectSts := statefulset.MakeStatefulset(object, observerSpec, podTemplateSpec) - expectSts.Spec.ServiceName = feSearchServiceName(src.Name) err = k8sutils.ApplyStatefulSet(ctx, fc.Client, &expectSts, false, rutils.StatefulSetDeepEqual) if err != nil { logger.Error(err, "fe observer statefulset failed", "StarRocksCluster", src) return err } - if err = fc.deleteLegacyObserverServices(ctx, src); err != nil { - logger.Error(err, "delete legacy fe observer services failed") + if err = k8sutils.ApplyService(ctx, fc.Client, internalService, rutils.ServiceDeepEqual); err != nil { + logger.Error(err, "deploy search service failed", "internalService", internalService) + fc.Recorder.Event(src, corev1.EventTypeWarning, "DeployFeObserverFailed", err.Error()) return err } + if err = k8sutils.ApplyService(ctx, fc.Client, &svc, rutils.ServiceDeepEqual); err != nil { + logger.Error(err, "deploy external service failed", "externalService", svc) + return err + } return nil } // UpdateClusterStatus update the all resource status about fe observer. -func (fc *FeObserverController) UpdateClusterStatus(_ context.Context, src *srapi.StarRocksCluster) error { +func (fc *FeObserverController) UpdateClusterStatus(ctx context.Context, src *srapi.StarRocksCluster) error { feSpec := src.Spec.StarRocksFeSpec observerSpec := feSpec.ToObserverSpec() if observerSpec == nil { @@ -137,7 +159,7 @@ func (fc *FeObserverController) UpdateClusterStatus(_ context.Context, src *srap } src.Status.StarRocksFeObserverStatus = fs - fs.ServiceName = feExternalServiceName(src.Name) + fs.ServiceName = service.ExternalServiceName(src.Name, feSpec) statefulSetName := load.Name(src.Name, observerSpec) fs.ResourceNames = rutils.MergeSlices(fs.ResourceNames, []string{statefulSetName}) @@ -167,7 +189,23 @@ func (fc *FeObserverController) ClearCluster(ctx context.Context, src *srapi.Sta return nil } - return fc.clearObserverResources(ctx, src) + observerSpec := src.Spec.StarRocksFeSpec.ToObserverSpec() + statefulSetName := load.Name(src.Name, observerSpec) + if err := k8sutils.DeleteStatefulset(ctx, fc.Client, src.Namespace, statefulSetName); err != nil && !apierrors.IsNotFound(err) { + return err + } + searchServiceName := service.SearchServiceName(src.Name, observerSpec) + if err := k8sutils.DeleteService(ctx, fc.Client, src.Namespace, searchServiceName); err != nil && !apierrors.IsNotFound(err) { + logger.Error(err, "delete search service failed", "searchServiceName", searchServiceName) + return err + } + externalServiceName := service.ExternalServiceName(src.Name, observerSpec) + err := k8sutils.DeleteService(ctx, fc.Client, src.Namespace, externalServiceName) + if err != nil && !apierrors.IsNotFound(err) { + logger.Error(err, "delete external service failed", "externalServiceName", externalServiceName) + return err + } + return nil } func (fc *FeObserverController) Validating(feSpec *srapi.StarRocksFeSpec) error { @@ -179,33 +217,20 @@ func (fc *FeObserverController) Validating(feSpec *srapi.StarRocksFeSpec) error if err := srapi.ValidUpdateStrategy(feSpec.UpdateStrategy); err != nil { return err } - return nil -} - -func (fc *FeObserverController) clearObserverResources(ctx context.Context, src *srapi.StarRocksCluster) error { - statefulSetName := load.Name(src.Name, (*srapi.StarRocksFeObserverSpec)(nil)) - if err := k8sutils.DeleteStatefulset(ctx, fc.Client, src.Namespace, statefulSetName); err != nil && !apierrors.IsNotFound(err) { - return err + if feSpec.ToObserverSpec() != nil { + if err := validateObserverImageVersion(feSpec.Image); err != nil { + return err + } } - return fc.deleteLegacyObserverServices(ctx, src) + return nil } -func (fc *FeObserverController) deleteLegacyObserverServices(ctx context.Context, src *srapi.StarRocksCluster) error { - searchServiceName := src.Name + "-" + srapi.DEFAULT_FE_OBSERVER + "-search" - if err := k8sutils.DeleteService(ctx, fc.Client, src.Namespace, searchServiceName); err != nil && !apierrors.IsNotFound(err) { - return err - } - externalServiceName := src.Name + "-" + srapi.DEFAULT_FE_OBSERVER + "-service" - if err := k8sutils.DeleteService(ctx, fc.Client, src.Namespace, externalServiceName); err != nil && !apierrors.IsNotFound(err) { - return err +func validateObserverImageVersion(image string) error { + imageVersion := pod.GetImageVersion(image) + _, err := pod.IsLowerThanAny(imageVersion, []string{"4.1.0"}) + if err != nil { + return fmt.Errorf("fe observer requires StarRocks FE image version >= %s "+ + "Current image version %s does not enable FE observer", minFeObserverImageVersion, imageVersion) } return nil } - -func feExternalServiceName(clusterName string) string { - return clusterName + "-" + srapi.DEFAULT_FE + "-service" -} - -func feSearchServiceName(clusterName string) string { - return clusterName + "-" + srapi.DEFAULT_FE + "-search" -} diff --git a/pkg/subcontrollers/feobserver/feobserver_controller_test.go b/pkg/subcontrollers/feobserver/feobserver_controller_test.go index 7952cc476..87996fd01 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller_test.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller_test.go @@ -57,7 +57,7 @@ func TestFeObserver_ClearCluster(t *testing.T) { StarRocksFeObserverStatus: &srapi.StarRocksFeObserverStatus{ StarRocksComponentStatus: srapi.StarRocksComponentStatus{ ResourceNames: []string{"test-fe-observer"}, - ServiceName: "test-fe-observer-access", + ServiceName: "test-fe-observer-service", }, }, }, @@ -116,7 +116,7 @@ func TestFeObserver_SyncCluster(t *testing.T) { StarRocksComponentSpec: srapi.StarRocksComponentSpec{ StarRocksLoadSpec: srapi.StarRocksLoadSpec{ Replicas: rutils.GetInt32Pointer(3), - Image: "starrocks.com/fe:2.40", + Image: "starrocks.com/fe:4.1.0", ResourceRequirements: corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceCPU: *resource.NewQuantity(4, resource.DecimalSI), @@ -133,7 +133,38 @@ func TestFeObserver_SyncCluster(t *testing.T) { }, } - fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src), fake.GetEventRecorderFor(nil)) + svc := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-fe-observer-service", + Namespace: "default", + }, + Spec: corev1.ServiceSpec{}, + } + + ssvc := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-fe-observer-search", + Namespace: "default", + }, + Spec: corev1.ServiceSpec{}, + } + + eq := &corev1.Endpoints{ + ObjectMeta: metav1.ObjectMeta{ + Name: service.ExternalServiceName(src.Name, src.Spec.StarRocksFeSpec), + Namespace: "default", + }, + Subsets: []corev1.EndpointSubset{ + { + Addresses: []corev1.EndpointAddress{ + {IP: "127.0.0.1"}, + }, + }, + }, + } + + fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src, svc, ssvc, eq), fake.GetEventRecorderFor(nil)) + err := fc.SyncCluster(context.Background(), src) require.NoError(t, err) err = fc.UpdateClusterStatus(context.Background(), src) @@ -151,18 +182,23 @@ func TestFeObserver_SyncCluster(t *testing.T) { var observerExternalSvc corev1.Service err = fc.Client.Get(context.Background(), types.NamespacedName{Name: "test-fe-observer-service", Namespace: "default"}, &observerExternalSvc) - require.True(t, apierrors.IsNotFound(err)) + require.NoError(t, err) var observerSearchSvc corev1.Service err = fc.Client.Get(context.Background(), types.NamespacedName{Name: "test-fe-observer-search", Namespace: "default"}, &observerSearchSvc) - require.True(t, apierrors.IsNotFound(err)) + require.NoError(t, err) + require.Equal(t, "None", observerSearchSvc.Spec.ClusterIP) + require.Equal(t, map[string]string{ + srapi.OwnerReference: "test-fe-observer", + srapi.ComponentLabelKey: srapi.DEFAULT_FE_OBSERVER, + }, observerSearchSvc.Spec.Selector) - require.Equal(t, service.SearchServiceName(src.Name, src.Spec.StarRocksFeSpec), sts.Spec.ServiceName) + require.Equal(t, service.SearchServiceName(src.Name, src.Spec.StarRocksFeSpec.ToObserverSpec()), sts.Spec.ServiceName) require.Equal(t, map[string]string{ srapi.OwnerReference: "test-fe-observer", srapi.ComponentLabelKey: srapi.DEFAULT_FE_OBSERVER, }, sts.Spec.Selector.MatchLabels) - require.Equal(t, "starrocks.com/fe:2.40", sts.Spec.Template.Spec.Containers[0].Image) + require.Equal(t, "starrocks.com/fe:4.1.0", sts.Spec.Template.Spec.Containers[0].Image) require.Equal(t, corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("4"), corev1.ResourceMemory: resource.MustParse("16G"), @@ -170,6 +206,38 @@ func TestFeObserver_SyncCluster(t *testing.T) { require.Equal(t, []string{"$(FE_SERVICE_NAME)"}, sts.Spec.Template.Spec.Containers[0].Args) } +func TestFeObserver_SyncClusterRejectsUnsupportedImage(t *testing.T) { + src := &srapi.StarRocksCluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + Namespace: "default", + }, + Spec: srapi.StarRocksClusterSpec{ + StarRocksFeSpec: &srapi.StarRocksFeSpec{ + StarRocksComponentSpec: srapi.StarRocksComponentSpec{ + StarRocksLoadSpec: srapi.StarRocksLoadSpec{ + Image: "starrocks.com/fe:4.0.10", + }, + }, + ObserverSpec: &srapi.StarRocksFeObserverSpec{ + Enabled: true, + ObserverNumber: rutils.GetInt32Pointer(1), + }, + }, + }, + } + + fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src), fake.GetEventRecorderFor(nil)) + err := fc.SyncCluster(context.Background(), src) + require.Error(t, err) + require.Contains(t, err.Error(), "fe observer requires StarRocks FE image version >= 4.1.0") + + var sts appsv1.StatefulSet + err = fc.Client.Get(context.Background(), + types.NamespacedName{Name: "test-fe-observer", Namespace: "default"}, &sts) + require.True(t, apierrors.IsNotFound(err)) +} + func TestFeObserver_SyncClusterDisabled(t *testing.T) { src := &srapi.StarRocksCluster{ ObjectMeta: metav1.ObjectMeta{ From 53b06a5340d7925e64558d14eb8d3c72c331e5aa Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Tue, 16 Jun 2026 15:19:45 +0800 Subject: [PATCH 12/22] fix Signed-off-by: zhaohehuhu --- config/crd/bases/starrocks.com_starrocksclusters.yaml | 7 ++----- pkg/subcontrollers/feobserver/feobserver_controller.go | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/config/crd/bases/starrocks.com_starrocksclusters.yaml b/config/crd/bases/starrocks.com_starrocksclusters.yaml index 88ac5c157..c60987647 100644 --- a/config/crd/bases/starrocks.com_starrocksclusters.yaml +++ b/config/crd/bases/starrocks.com_starrocksclusters.yaml @@ -13602,11 +13602,8 @@ spec: of nodeSelectors to match when scheduling pods on nodes" type: object observerSpec: - description: |- - ObserverSpec configures optional FE observer pods. Observer pods reuse the generic FE resources. - The FE image must be StarRocks 4.1.0 or later. Removing observers does not automatically - run ALTER SYSTEM DROP OBSERVER; manually drop observer nodes - if SHOW FRONTENDS reports Alive = false. + description: ObserverSpec configures optional FE observer pods. + Observer pods reuse the generic FE resources. properties: enabled: description: Enabled controls whether FE observer should be diff --git a/pkg/subcontrollers/feobserver/feobserver_controller.go b/pkg/subcontrollers/feobserver/feobserver_controller.go index c553aa0de..d6ce68d98 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller.go @@ -20,7 +20,6 @@ import ( "context" "fmt" - "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/service" "github.com/go-logr/logr" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -37,6 +36,7 @@ import ( "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/load" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/object" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/pod" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/service" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/statefulset" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/subcontrollers/fe" @@ -140,7 +140,7 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star } // UpdateClusterStatus update the all resource status about fe observer. -func (fc *FeObserverController) UpdateClusterStatus(ctx context.Context, src *srapi.StarRocksCluster) error { +func (fc *FeObserverController) UpdateClusterStatus(_ context.Context, src *srapi.StarRocksCluster) error { feSpec := src.Spec.StarRocksFeSpec observerSpec := feSpec.ToObserverSpec() if observerSpec == nil { From a856db8e9f01a97a495d6d4e16ec7e64804fc7af Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Fri, 7 Aug 2026 14:39:49 +0800 Subject: [PATCH 13/22] ClearCluster for observer Signed-off-by: zhaohehuhu --- .../feobserver/feobserver_controller.go | 12 ++--- .../feobserver/feobserver_controller_test.go | 52 +++++++++++++++++++ 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/pkg/subcontrollers/feobserver/feobserver_controller.go b/pkg/subcontrollers/feobserver/feobserver_controller.go index d6ce68d98..1fe488750 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller.go @@ -69,6 +69,10 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star feSpec := src.Spec.StarRocksFeSpec observerSpec := feSpec.ToObserverSpec() if observerSpec == nil { + if err := fc.ClearCluster(ctx, src); err != nil { + logger.Error(err, "clear resource failed") + return err + } logger.Info("src.Spec.StarRocksFeObserverSpec == nil, skip sync fe observer") return nil } @@ -181,15 +185,11 @@ func (fc *FeObserverController) ClearCluster(ctx context.Context, src *srapi.Sta logger := logr.FromContextOrDiscard(ctx).WithName(fc.GetControllerName()).WithValues(log.ActionKey, log.ActionCluster) ctx = logr.NewContext(ctx, logger) - if src.Status.StarRocksFeObserverStatus == nil { - return nil - } - - if src.DeletionTimestamp.IsZero() { + observerSpec := src.Spec.StarRocksFeSpec.ToObserverSpec() + if observerSpec != nil && src.DeletionTimestamp.IsZero() { return nil } - observerSpec := src.Spec.StarRocksFeSpec.ToObserverSpec() statefulSetName := load.Name(src.Name, observerSpec) if err := k8sutils.DeleteStatefulset(ctx, fc.Client, src.Namespace, statefulSetName); err != nil && !apierrors.IsNotFound(err) { return err diff --git a/pkg/subcontrollers/feobserver/feobserver_controller_test.go b/pkg/subcontrollers/feobserver/feobserver_controller_test.go index 87996fd01..438ee9246 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller_test.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller_test.go @@ -271,6 +271,58 @@ func TestFeObserver_SyncClusterDisabled(t *testing.T) { require.True(t, apierrors.IsNotFound(err)) } +func TestFeObserver_SyncClusterDisabledClearsExistingResources(t *testing.T) { + src := &srapi.StarRocksCluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + Namespace: "default", + }, + Spec: srapi.StarRocksClusterSpec{ + StarRocksFeSpec: &srapi.StarRocksFeSpec{ + ObserverSpec: &srapi.StarRocksFeObserverSpec{ + Enabled: false, + }, + }, + }, + Status: srapi.StarRocksClusterStatus{ + StarRocksFeObserverStatus: &srapi.StarRocksFeObserverStatus{}, + }, + } + + sts := &appsv1.StatefulSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-fe-observer", + Namespace: "default", + }, + } + svc := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-fe-observer-service", + Namespace: "default", + }, + } + searchSvc := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-fe-observer-search", + Namespace: "default", + }, + } + + fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src, sts, svc, searchSvc), fake.GetEventRecorderFor(nil)) + err := fc.SyncCluster(context.Background(), src) + require.NoError(t, err) + + var existingSTS appsv1.StatefulSet + err = fc.Client.Get(context.Background(), types.NamespacedName{Name: sts.Name, Namespace: "default"}, &existingSTS) + require.True(t, apierrors.IsNotFound(err)) + var existingSvc corev1.Service + err = fc.Client.Get(context.Background(), types.NamespacedName{Name: svc.Name, Namespace: "default"}, &existingSvc) + require.True(t, apierrors.IsNotFound(err)) + var existingSearchSvc corev1.Service + err = fc.Client.Get(context.Background(), types.NamespacedName{Name: searchSvc.Name, Namespace: "default"}, &existingSearchSvc) + require.True(t, apierrors.IsNotFound(err)) +} + func TestFeObserver_Ready(t *testing.T) { type args struct { ctx context.Context From 32db61566793a65c070618fc36eb4ad322a7a659 Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Fri, 7 Aug 2026 15:10:03 +0800 Subject: [PATCH 14/22] fix UTs Signed-off-by: zhaohehuhu fix UTs Signed-off-by: zhaohehuhu return nil if observer not found Signed-off-by: zhaohehuhu unified external service for fe and observer Signed-off-by: zhaohehuhu unified external serice for fe and observer Signed-off-by: zhaohehuhu --- pkg/apis/starrocks/v1/labels.go | 3 + pkg/common/resource_utils/service.go | 2 - pkg/k8sutils/load/load.go | 6 ++ pkg/k8sutils/templates/pod/spec.go | 2 + pkg/k8sutils/templates/pod/spec_test.go | 1 + pkg/k8sutils/templates/service/spec.go | 25 ++++- pkg/k8sutils/templates/service/spec_test.go | 58 ++++++++++++ pkg/subcontrollers/fe/fe_controller.go | 5 +- pkg/subcontrollers/fe/fe_controller_test.go | 8 +- .../feobserver/feobserver_controller.go | 31 +++---- .../feobserver/feobserver_controller_test.go | 93 ++++++------------- 11 files changed, 142 insertions(+), 92 deletions(-) diff --git a/pkg/apis/starrocks/v1/labels.go b/pkg/apis/starrocks/v1/labels.go index 2ebfc353f..e98f2edfa 100644 --- a/pkg/apis/starrocks/v1/labels.go +++ b/pkg/apis/starrocks/v1/labels.go @@ -26,6 +26,9 @@ const ( // ComponentResourceHash the component hash ComponentResourceHash string = "app.starrocks.components/hash" + + // FeServiceLabelKey marks pods that should be exposed through the FE external service. + FeServiceLabelKey string = "app.starrocks.io/fe-service" ) // the labels value. default statefulset name diff --git a/pkg/common/resource_utils/service.go b/pkg/common/resource_utils/service.go index 5cb1764bc..1f17a7806 100644 --- a/pkg/common/resource_utils/service.go +++ b/pkg/common/resource_utils/service.go @@ -89,8 +89,6 @@ func BuildExternalService(object object.StarRocksObject, spec srapi.SpecInterfac switch spec.(type) { case *srapi.StarRocksFeSpec: srPorts = getFeServicePorts(config, starRocksService) - case *srapi.StarRocksFeObserverSpec: - srPorts = getFeServicePorts(config, starRocksService) case *srapi.StarRocksBeSpec: srPorts = getBeServicePorts(config, starRocksService) case *srapi.StarRocksCnSpec: diff --git a/pkg/k8sutils/load/load.go b/pkg/k8sutils/load/load.go index d69d927e5..833478139 100644 --- a/pkg/k8sutils/load/load.go +++ b/pkg/k8sutils/load/load.go @@ -21,3 +21,9 @@ import ( func Selector(clusterName string, spec v1.SpecInterface) map[string]string { return Labels(Name(clusterName, spec), spec) } + +func FeServiceSelector(clusterName string) map[string]string { + return map[string]string{ + v1.FeServiceLabelKey: Name(clusterName, (*v1.StarRocksFeSpec)(nil)), + } +} diff --git a/pkg/k8sutils/templates/pod/spec.go b/pkg/k8sutils/templates/pod/spec.go index 2621e7669..b40a19e79 100644 --- a/pkg/k8sutils/templates/pod/spec.go +++ b/pkg/k8sutils/templates/pod/spec.go @@ -77,10 +77,12 @@ func Labels(clusterName string, spec v1.SpecInterface) map[string]string { if v != nil { addLabels(labels, v.PodLabels) } + labels[v1.FeServiceLabelKey] = load.Name(clusterName, (*v1.StarRocksFeSpec)(nil)) case *v1.StarRocksFeObserverSpec: if v != nil { addLabels(labels, v.ComponentSpec.PodLabels) } + labels[v1.FeServiceLabelKey] = load.Name(clusterName, (*v1.StarRocksFeSpec)(nil)) case *v1.StarRocksFeProxySpec: if v != nil { addLabels(labels, v.PodLabels) diff --git a/pkg/k8sutils/templates/pod/spec_test.go b/pkg/k8sutils/templates/pod/spec_test.go index 674bab65d..24a7fc9d8 100644 --- a/pkg/k8sutils/templates/pod/spec_test.go +++ b/pkg/k8sutils/templates/pod/spec_test.go @@ -146,6 +146,7 @@ func TestLabels(t *testing.T) { "l1": "v1", v1.OwnerReference: "test-fe", v1.ComponentLabelKey: v1.DEFAULT_FE, + v1.FeServiceLabelKey: "test-fe", }, }, } diff --git a/pkg/k8sutils/templates/service/spec.go b/pkg/k8sutils/templates/service/spec.go index e50774f06..ef28004d1 100644 --- a/pkg/k8sutils/templates/service/spec.go +++ b/pkg/k8sutils/templates/service/spec.go @@ -16,8 +16,11 @@ package service import ( corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/load" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/object" ) func MakeSearchService(serviceName string, externalService *corev1.Service, ports []corev1.ServicePort, @@ -43,6 +46,26 @@ func MakeSearchService(serviceName string, externalService *corev1.Service, port return searchSvc } +func MakeSearchServiceForSpec(starRocksObject object.StarRocksObject, spec v1.SpecInterface, ports []corev1.ServicePort, + defaultLabels map[string]string) *corev1.Service { + serviceName := SearchServiceName(starRocksObject.ClusterName, spec) + return &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: serviceName, + Namespace: starRocksObject.GetNamespace(), + Labels: defaultLabels, + OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(starRocksObject, starRocksObject.GroupVersionKind())}, + }, + Spec: corev1.ServiceSpec{ + ClusterIP: "None", + Ports: ports, + Selector: load.Selector(starRocksObject.ClusterName, spec), + // value = true, Pod don't need to become ready that be search by domain. + PublishNotReadyAddresses: true, + }, + } +} + // SearchServiceName get the domain service name, the domain service for statefulset. // domain service have PublishNotReadyAddresses. while used PublishNotReadyAddresses, the fe start need all instance domain can resolve. func SearchServiceName(clusterName string, spec v1.SpecInterface) string { @@ -65,8 +88,6 @@ func ExternalServiceName(clusterName string, spec v1.SpecInterface) string { switch spec.(type) { case *v1.StarRocksFeSpec: return clusterName + "-" + v1.DEFAULT_FE + "-service" - case *v1.StarRocksFeObserverSpec: - return clusterName + "-" + v1.DEFAULT_FE_OBSERVER + "-service" case *v1.StarRocksBeSpec: return clusterName + "-" + v1.DEFAULT_BE + "-service" case *v1.StarRocksCnSpec: diff --git a/pkg/k8sutils/templates/service/spec_test.go b/pkg/k8sutils/templates/service/spec_test.go index f16e8f116..69b99d6d7 100644 --- a/pkg/k8sutils/templates/service/spec_test.go +++ b/pkg/k8sutils/templates/service/spec_test.go @@ -22,6 +22,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/load" + "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/object" ) func TestMakeSearchService(t *testing.T) { @@ -95,6 +97,54 @@ func TestMakeSearchService(t *testing.T) { } } +func TestMakeSearchServiceForSpec(t *testing.T) { + cluster := &v1.StarRocksCluster{ + TypeMeta: metav1.TypeMeta{ + APIVersion: v1.GroupVersion.String(), + Kind: "StarRocksCluster", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + Namespace: "default", + }, + } + observerSpec := &v1.StarRocksFeObserverSpec{} + labels := load.Labels(cluster.Name, observerSpec) + ports := []corev1.ServicePort{ + { + Name: "query-port", + Port: 9030, + }, + } + + got := MakeSearchServiceForSpec(object.NewFromCluster(cluster), observerSpec, ports, labels) + + if got.Name != "test-fe-observer-search" { + t.Errorf("MakeSearchServiceForSpec() name = %v, want %v", got.Name, "test-fe-observer-search") + } + if got.Namespace != "default" { + t.Errorf("MakeSearchServiceForSpec() namespace = %v, want %v", got.Namespace, "default") + } + if !reflect.DeepEqual(got.Labels, labels) { + t.Errorf("MakeSearchServiceForSpec() labels = %v, want %v", got.Labels, labels) + } + if !reflect.DeepEqual(got.Spec.Selector, load.Selector(cluster.Name, observerSpec)) { + t.Errorf("MakeSearchServiceForSpec() selector = %v, want %v", got.Spec.Selector, load.Selector(cluster.Name, observerSpec)) + } + if got.Spec.ClusterIP != "None" { + t.Errorf("MakeSearchServiceForSpec() ClusterIP = %v, want %v", got.Spec.ClusterIP, "None") + } + if !got.Spec.PublishNotReadyAddresses { + t.Errorf("MakeSearchServiceForSpec() PublishNotReadyAddresses = %v, want %v", got.Spec.PublishNotReadyAddresses, true) + } + if !reflect.DeepEqual(got.Spec.Ports, ports) { + t.Errorf("MakeSearchServiceForSpec() ports = %v, want %v", got.Spec.Ports, ports) + } + if len(got.OwnerReferences) != 1 || got.OwnerReferences[0].Name != "test" || got.OwnerReferences[0].Kind != "StarRocksCluster" { + t.Errorf("MakeSearchServiceForSpec() OwnerReferences = %v, want one StarRocksCluster owner named test", got.OwnerReferences) + } +} + func TestSearchServiceName(t *testing.T) { type args struct { clusterName string @@ -211,6 +261,14 @@ func TestGetFeExternalServiceName(t *testing.T) { }, want: "test-fe-service", }, + { + name: "fe observer does not have external service", + args: args{ + clusterName: "test", + spec: &v1.StarRocksFeObserverSpec{}, + }, + want: "", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/subcontrollers/fe/fe_controller.go b/pkg/subcontrollers/fe/fe_controller.go index 2d7871ba0..c76786f3a 100644 --- a/pkg/subcontrollers/fe/fe_controller.go +++ b/pkg/subcontrollers/fe/fe_controller.go @@ -92,9 +92,8 @@ func (fc *FeController) SyncCluster(ctx context.Context, src *srapi.StarRocksClu logger.V(log.DebugLevel).Info("build fe service", "StarRocksCluster", src) object := object.NewFromCluster(src) defaultLabels := load.Labels(src.Name, feSpec) - svc := rutils.BuildExternalService(object, feSpec, feConfig, load.Selector(src.Name, feSpec), defaultLabels) - searchServiceName := service.SearchServiceName(src.Name, feSpec) - internalService := service.MakeSearchService(searchServiceName, &svc, []corev1.ServicePort{ + svc := rutils.BuildExternalService(object, feSpec, feConfig, load.FeServiceSelector(src.Name), defaultLabels) + internalService := service.MakeSearchServiceForSpec(object, feSpec, []corev1.ServicePort{ { Name: "query-port", Port: rutils.GetPort(feConfig, rutils.QUERY_PORT), diff --git a/pkg/subcontrollers/fe/fe_controller_test.go b/pkg/subcontrollers/fe/fe_controller_test.go index 7632927bf..25805921a 100644 --- a/pkg/subcontrollers/fe/fe_controller_test.go +++ b/pkg/subcontrollers/fe/fe_controller_test.go @@ -173,8 +173,12 @@ func Test_SyncDeploy(t *testing.T) { require.Equal(t, service.SearchServiceName(src.Name, spec), rsvc.Name) require.NoError(t, fc.Client.Get(context.Background(), types.NamespacedName{Name: load.Name(src.Name, spec), Namespace: "default"}, &st)) - // validate service selector matches statefulset selector - require.Equal(t, asvc.Spec.Selector, st.Spec.Selector.MatchLabels) + require.Equal(t, map[string]string{ + srapi.FeServiceLabelKey: "test-fe", + }, asvc.Spec.Selector) + require.Equal(t, load.Selector(src.Name, spec), rsvc.Spec.Selector) + require.Equal(t, load.Selector(src.Name, spec), st.Spec.Selector.MatchLabels) + require.Equal(t, "test-fe", st.Spec.Template.Labels[srapi.FeServiceLabelKey]) } func TestCheckFEReady(t *testing.T) { diff --git a/pkg/subcontrollers/feobserver/feobserver_controller.go b/pkg/subcontrollers/feobserver/feobserver_controller.go index 1fe488750..7ef5adb59 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller.go @@ -108,9 +108,7 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star logger.V(log.DebugLevel).Info("build fe observer statefulset", "StarRocksCluster", src) object := object.NewFromCluster(src) defaultLabels := load.Labels(src.Name, observerSpec) - svc := rutils.BuildExternalService(object, observerSpec, feConfig, load.Selector(src.Name, observerSpec), defaultLabels) - searchServiceName := service.SearchServiceName(src.Name, observerSpec) - internalService := service.MakeSearchService(searchServiceName, &svc, []corev1.ServicePort{ + internalService := service.MakeSearchServiceForSpec(object, observerSpec, []corev1.ServicePort{ { Name: "query-port", Port: rutils.GetPort(feConfig, rutils.QUERY_PORT), @@ -136,15 +134,14 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star return err } - if err = k8sutils.ApplyService(ctx, fc.Client, &svc, rutils.ServiceDeepEqual); err != nil { - logger.Error(err, "deploy external service failed", "externalService", svc) - return err - } return nil } // UpdateClusterStatus update the all resource status about fe observer. -func (fc *FeObserverController) UpdateClusterStatus(_ context.Context, src *srapi.StarRocksCluster) error { +func (fc *FeObserverController) UpdateClusterStatus(ctx context.Context, src *srapi.StarRocksCluster) error { + logger := logr.FromContextOrDiscard(ctx).WithName(fc.GetControllerName()).WithValues(log.ActionKey, log.ActionUpdateClusterStatus) + ctx = logr.NewContext(ctx, logger) + feSpec := src.Spec.StarRocksFeSpec observerSpec := feSpec.ToObserverSpec() if observerSpec == nil { @@ -163,8 +160,13 @@ func (fc *FeObserverController) UpdateClusterStatus(_ context.Context, src *srap } src.Status.StarRocksFeObserverStatus = fs - fs.ServiceName = service.ExternalServiceName(src.Name, feSpec) statefulSetName := load.Name(src.Name, observerSpec) + var st appsv1.StatefulSet + if err := fc.Client.Get(ctx, types.NamespacedName{Namespace: src.Namespace, Name: statefulSetName}, &st); apierrors.IsNotFound(err) { + logger.Info("fe observer statefulset is not found") + return nil + } + fs.ResourceNames = rutils.MergeSlices(fs.ResourceNames, []string{statefulSetName}) if err := subcontrollers.UpdateStatus(&fs.StarRocksComponentStatus, fc.Client, @@ -172,11 +174,6 @@ func (fc *FeObserverController) UpdateClusterStatus(_ context.Context, src *srap return err } - var st appsv1.StatefulSet - if err := fc.Client.Get(context.Background(), types.NamespacedName{Namespace: src.Namespace, Name: statefulSetName}, &st); err != nil { - return err - } - return nil } @@ -199,12 +196,6 @@ func (fc *FeObserverController) ClearCluster(ctx context.Context, src *srapi.Sta logger.Error(err, "delete search service failed", "searchServiceName", searchServiceName) return err } - externalServiceName := service.ExternalServiceName(src.Name, observerSpec) - err := k8sutils.DeleteService(ctx, fc.Client, src.Namespace, externalServiceName) - if err != nil && !apierrors.IsNotFound(err) { - logger.Error(err, "delete external service failed", "externalServiceName", externalServiceName) - return err - } return nil } diff --git a/pkg/subcontrollers/feobserver/feobserver_controller_test.go b/pkg/subcontrollers/feobserver/feobserver_controller_test.go index 438ee9246..b668755b6 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller_test.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller_test.go @@ -133,14 +133,6 @@ func TestFeObserver_SyncCluster(t *testing.T) { }, } - svc := &corev1.Service{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-fe-observer-service", - Namespace: "default", - }, - Spec: corev1.ServiceSpec{}, - } - ssvc := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: "test-fe-observer-search", @@ -163,7 +155,7 @@ func TestFeObserver_SyncCluster(t *testing.T) { }, } - fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src, svc, ssvc, eq), fake.GetEventRecorderFor(nil)) + fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src, ssvc, eq), fake.GetEventRecorderFor(nil)) err := fc.SyncCluster(context.Background(), src) require.NoError(t, err) @@ -173,7 +165,7 @@ func TestFeObserver_SyncCluster(t *testing.T) { status := src.Status.StarRocksFeObserverStatus require.NotNil(t, status) require.Equal(t, srapi.ComponentReconciling, status.Phase) - require.Equal(t, service.ExternalServiceName(src.Name, src.Spec.StarRocksFeSpec), status.ServiceName) + require.Empty(t, status.ServiceName) var sts appsv1.StatefulSet require.NoError(t, fc.Client.Get(context.Background(), @@ -182,7 +174,7 @@ func TestFeObserver_SyncCluster(t *testing.T) { var observerExternalSvc corev1.Service err = fc.Client.Get(context.Background(), types.NamespacedName{Name: "test-fe-observer-service", Namespace: "default"}, &observerExternalSvc) - require.NoError(t, err) + require.True(t, apierrors.IsNotFound(err)) var observerSearchSvc corev1.Service err = fc.Client.Get(context.Background(), types.NamespacedName{Name: "test-fe-observer-search", Namespace: "default"}, &observerSearchSvc) @@ -198,6 +190,7 @@ func TestFeObserver_SyncCluster(t *testing.T) { srapi.OwnerReference: "test-fe-observer", srapi.ComponentLabelKey: srapi.DEFAULT_FE_OBSERVER, }, sts.Spec.Selector.MatchLabels) + require.Equal(t, "test-fe", sts.Spec.Template.Labels[srapi.FeServiceLabelKey]) require.Equal(t, "starrocks.com/fe:4.1.0", sts.Spec.Template.Spec.Containers[0].Image) require.Equal(t, corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("4"), @@ -206,7 +199,7 @@ func TestFeObserver_SyncCluster(t *testing.T) { require.Equal(t, []string{"$(FE_SERVICE_NAME)"}, sts.Spec.Template.Spec.Containers[0].Args) } -func TestFeObserver_SyncClusterRejectsUnsupportedImage(t *testing.T) { +func TestFeObserver_UpdateClusterStatusAllowsMissingStatefulSet(t *testing.T) { src := &srapi.StarRocksCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "test", @@ -214,11 +207,6 @@ func TestFeObserver_SyncClusterRejectsUnsupportedImage(t *testing.T) { }, Spec: srapi.StarRocksClusterSpec{ StarRocksFeSpec: &srapi.StarRocksFeSpec{ - StarRocksComponentSpec: srapi.StarRocksComponentSpec{ - StarRocksLoadSpec: srapi.StarRocksLoadSpec{ - Image: "starrocks.com/fe:4.0.10", - }, - }, ObserverSpec: &srapi.StarRocksFeObserverSpec{ Enabled: true, ObserverNumber: rutils.GetInt32Pointer(1), @@ -228,17 +216,16 @@ func TestFeObserver_SyncClusterRejectsUnsupportedImage(t *testing.T) { } fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src), fake.GetEventRecorderFor(nil)) - err := fc.SyncCluster(context.Background(), src) - require.Error(t, err) - require.Contains(t, err.Error(), "fe observer requires StarRocks FE image version >= 4.1.0") - var sts appsv1.StatefulSet - err = fc.Client.Get(context.Background(), - types.NamespacedName{Name: "test-fe-observer", Namespace: "default"}, &sts) - require.True(t, apierrors.IsNotFound(err)) + err := fc.UpdateClusterStatus(context.Background(), src) + + require.NoError(t, err) + require.NotNil(t, src.Status.StarRocksFeObserverStatus) + require.Equal(t, srapi.ComponentReconciling, src.Status.StarRocksFeObserverStatus.Phase) + require.Empty(t, src.Status.StarRocksFeObserverStatus.ResourceNames) } -func TestFeObserver_SyncClusterDisabled(t *testing.T) { +func TestFeObserver_SyncClusterRejectsUnsupportedImage(t *testing.T) { src := &srapi.StarRocksCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "test", @@ -248,11 +235,12 @@ func TestFeObserver_SyncClusterDisabled(t *testing.T) { StarRocksFeSpec: &srapi.StarRocksFeSpec{ StarRocksComponentSpec: srapi.StarRocksComponentSpec{ StarRocksLoadSpec: srapi.StarRocksLoadSpec{ - Image: "starrocks.com/fe:2.40", + Image: "starrocks.com/fe:4.0.10", }, }, ObserverSpec: &srapi.StarRocksFeObserverSpec{ - Enabled: false, + Enabled: true, + ObserverNumber: rutils.GetInt32Pointer(1), }, }, }, @@ -260,10 +248,8 @@ func TestFeObserver_SyncClusterDisabled(t *testing.T) { fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src), fake.GetEventRecorderFor(nil)) err := fc.SyncCluster(context.Background(), src) - require.NoError(t, err) - err = fc.UpdateClusterStatus(context.Background(), src) - require.NoError(t, err) - require.Nil(t, src.Status.StarRocksFeObserverStatus) + require.Error(t, err) + require.Contains(t, err.Error(), "fe observer requires StarRocks FE image version >= 4.1.0") var sts appsv1.StatefulSet err = fc.Client.Get(context.Background(), @@ -271,7 +257,7 @@ func TestFeObserver_SyncClusterDisabled(t *testing.T) { require.True(t, apierrors.IsNotFound(err)) } -func TestFeObserver_SyncClusterDisabledClearsExistingResources(t *testing.T) { +func TestFeObserver_SyncClusterDisabled(t *testing.T) { src := &srapi.StarRocksCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "test", @@ -279,47 +265,28 @@ func TestFeObserver_SyncClusterDisabledClearsExistingResources(t *testing.T) { }, Spec: srapi.StarRocksClusterSpec{ StarRocksFeSpec: &srapi.StarRocksFeSpec{ + StarRocksComponentSpec: srapi.StarRocksComponentSpec{ + StarRocksLoadSpec: srapi.StarRocksLoadSpec{ + Image: "starrocks.com/fe:2.40", + }, + }, ObserverSpec: &srapi.StarRocksFeObserverSpec{ Enabled: false, }, }, }, - Status: srapi.StarRocksClusterStatus{ - StarRocksFeObserverStatus: &srapi.StarRocksFeObserverStatus{}, - }, } - sts := &appsv1.StatefulSet{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-fe-observer", - Namespace: "default", - }, - } - svc := &corev1.Service{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-fe-observer-service", - Namespace: "default", - }, - } - searchSvc := &corev1.Service{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-fe-observer-search", - Namespace: "default", - }, - } - - fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src, sts, svc, searchSvc), fake.GetEventRecorderFor(nil)) + fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src), fake.GetEventRecorderFor(nil)) err := fc.SyncCluster(context.Background(), src) require.NoError(t, err) + err = fc.UpdateClusterStatus(context.Background(), src) + require.NoError(t, err) + require.Nil(t, src.Status.StarRocksFeObserverStatus) - var existingSTS appsv1.StatefulSet - err = fc.Client.Get(context.Background(), types.NamespacedName{Name: sts.Name, Namespace: "default"}, &existingSTS) - require.True(t, apierrors.IsNotFound(err)) - var existingSvc corev1.Service - err = fc.Client.Get(context.Background(), types.NamespacedName{Name: svc.Name, Namespace: "default"}, &existingSvc) - require.True(t, apierrors.IsNotFound(err)) - var existingSearchSvc corev1.Service - err = fc.Client.Get(context.Background(), types.NamespacedName{Name: searchSvc.Name, Namespace: "default"}, &existingSearchSvc) + var sts appsv1.StatefulSet + err = fc.Client.Get(context.Background(), + types.NamespacedName{Name: "test-fe-observer", Namespace: "default"}, &sts) require.True(t, apierrors.IsNotFound(err)) } From 299d84c8f794ad7e0790cb2f4cb2d7a6163b2557 Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Tue, 20 Oct 2026 14:42:27 +0800 Subject: [PATCH 15/22] preserves a user-provided value instead of replacing Signed-off-by: zhaohehuhu --- pkg/k8sutils/templates/pod/spec.go | 24 +++++--- pkg/k8sutils/templates/pod/spec_test.go | 77 +++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 9 deletions(-) diff --git a/pkg/k8sutils/templates/pod/spec.go b/pkg/k8sutils/templates/pod/spec.go index b40a19e79..11dc0708a 100644 --- a/pkg/k8sutils/templates/pod/spec.go +++ b/pkg/k8sutils/templates/pod/spec.go @@ -17,6 +17,7 @@ package pod import ( "fmt" "os" + "slices" "strconv" "strings" @@ -107,11 +108,16 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, } } - addEnv := func(envVar corev1.EnvVar) { - if !keys[envVar.Name] && !unsupportedEnvironments[envVar.Name] { - keys[envVar.Name] = true - envs = append(envs, envVar) + addEnv := func(envVar corev1.EnvVar, overwrite bool) { + if overwrite { + envs = slices.DeleteFunc(envs, func(env corev1.EnvVar) bool { + return env.Name == envVar.Name + }) + } else if keys[envVar.Name] || unsupportedEnvironments[envVar.Name] { + return } + keys[envVar.Name] = true + envs = append(envs, envVar) } for _, envVar := range []corev1.EnvVar{ @@ -144,7 +150,7 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, Value: "FQDN", }, } { - addEnv(envVar) + addEnv(envVar, false) } switch spec.(type) { @@ -159,7 +165,7 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, Value: feExternalServiceName + "." + namespace, }, } { - addEnv(envVar) + addEnv(envVar, false) } case *v1.StarRocksFeObserverSpec: for _, envVar := range []corev1.EnvVar{ @@ -180,7 +186,7 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, Value: feExternalServiceName, }, } { - addEnv(envVar) + addEnv(envVar, envVar.Name == v1.IS_FE_OBSERVER) } case *v1.StarRocksBeSpec: for _, envVar := range []corev1.EnvVar{ @@ -197,7 +203,7 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, Value: strconv.FormatInt(int64(rutils.GetPort(config, rutils.QUERY_PORT)), 10), }, } { - addEnv(envVar) + addEnv(envVar, false) } case *v1.StarRocksCnSpec: for _, envVar := range []corev1.EnvVar{ @@ -214,7 +220,7 @@ func Envs(spec v1.SpecInterface, config map[string]interface{}, Value: strconv.FormatInt(int64(rutils.GetPort(config, rutils.QUERY_PORT)), 10), }, } { - addEnv(envVar) + addEnv(envVar, false) } } diff --git a/pkg/k8sutils/templates/pod/spec_test.go b/pkg/k8sutils/templates/pod/spec_test.go index 24a7fc9d8..126972b14 100644 --- a/pkg/k8sutils/templates/pod/spec_test.go +++ b/pkg/k8sutils/templates/pod/spec_test.go @@ -335,6 +335,83 @@ func TestEnvs(t *testing.T) { } } +func TestObserverEnvsEnforceRole(t *testing.T) { + tests := []struct { + name string + envs []corev1.EnvVar + unsupportedEnvs string + }{ + {name: "default"}, + { + name: "false value", + envs: []corev1.EnvVar{{Name: v1.IS_FE_OBSERVER, Value: "false"}}, + }, + { + name: "true value", + envs: []corev1.EnvVar{{Name: v1.IS_FE_OBSERVER, Value: "true"}}, + }, + { + name: "value from config map", + envs: []corev1.EnvVar{{ + Name: v1.IS_FE_OBSERVER, + ValueFrom: &corev1.EnvVarSource{ + ConfigMapKeyRef: &corev1.ConfigMapKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{Name: "fe-env"}, + Key: v1.IS_FE_OBSERVER, + }, + }, + }}, + }, + { + name: "duplicate values", + envs: []corev1.EnvVar{ + {Name: v1.IS_FE_OBSERVER, Value: "true"}, + {Name: v1.IS_FE_OBSERVER, Value: "false"}, + }, + }, + { + name: "unsupported environment setting", + unsupportedEnvs: v1.IS_FE_OBSERVER, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Setenv("KUBE_STARROCKS_UNSUPPORTED_ENVS", tt.unsupportedEnvs) + customEnv := corev1.EnvVar{Name: "HOST_TYPE", Value: "IP"} + feSpec := &v1.StarRocksFeSpec{ + FeEnvVars: append([]corev1.EnvVar{customEnv}, tt.envs...), + ObserverSpec: &v1.StarRocksFeObserverSpec{Enabled: true}, + } + original := feSpec.DeepCopy() + observerSpec := feSpec.ToObserverSpec() + got := Envs(observerSpec, nil, "test-fe-service", "ns", observerSpec.FeEnvVars) + var roleEnvs []corev1.EnvVar + var customEnvs []corev1.EnvVar + for _, env := range got { + switch env.Name { + case v1.IS_FE_OBSERVER: + roleEnvs = append(roleEnvs, env) + case customEnv.Name: + customEnvs = append(customEnvs, env) + } + } + want := []corev1.EnvVar{{Name: v1.IS_FE_OBSERVER, Value: "true"}} + if !reflect.DeepEqual(roleEnvs, want) { + t.Errorf("observer role envs = %v, want %v", roleEnvs, want) + } + if !reflect.DeepEqual(customEnvs, []corev1.EnvVar{customEnv}) { + t.Errorf("user environment was not preserved: %v", customEnvs) + } + if !reflect.DeepEqual(feSpec, original) { + t.Error("parent FE spec was modified") + } + if !reflect.DeepEqual(observerSpec.FeEnvVars, original.FeEnvVars) { + t.Error("inherited observer environment was modified") + } + }) + } +} + func TestSpec(t *testing.T) { type args struct { spec v1.SpecInterface From 7ad15059abbff7f10bcb2e7cbfa9008a83500652 Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Tue, 20 Oct 2026 14:58:58 +0800 Subject: [PATCH 16/22] fix sercvice label Signed-off-by: zhaohehuhu --- pkg/k8sutils/templates/service/spec.go | 28 ++------------- pkg/k8sutils/templates/service/spec_test.go | 35 ++++++++++++------- pkg/subcontrollers/fe/fe_controller.go | 5 +-- .../feobserver/feobserver_controller.go | 9 ++++- 4 files changed, 36 insertions(+), 41 deletions(-) diff --git a/pkg/k8sutils/templates/service/spec.go b/pkg/k8sutils/templates/service/spec.go index ef28004d1..6784dba02 100644 --- a/pkg/k8sutils/templates/service/spec.go +++ b/pkg/k8sutils/templates/service/spec.go @@ -15,12 +15,8 @@ package service import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - v1 "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1" - "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/load" - "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/object" + corev1 "k8s.io/api/core/v1" ) func MakeSearchService(serviceName string, externalService *corev1.Service, ports []corev1.ServicePort, @@ -46,26 +42,6 @@ func MakeSearchService(serviceName string, externalService *corev1.Service, port return searchSvc } -func MakeSearchServiceForSpec(starRocksObject object.StarRocksObject, spec v1.SpecInterface, ports []corev1.ServicePort, - defaultLabels map[string]string) *corev1.Service { - serviceName := SearchServiceName(starRocksObject.ClusterName, spec) - return &corev1.Service{ - ObjectMeta: metav1.ObjectMeta{ - Name: serviceName, - Namespace: starRocksObject.GetNamespace(), - Labels: defaultLabels, - OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(starRocksObject, starRocksObject.GroupVersionKind())}, - }, - Spec: corev1.ServiceSpec{ - ClusterIP: "None", - Ports: ports, - Selector: load.Selector(starRocksObject.ClusterName, spec), - // value = true, Pod don't need to become ready that be search by domain. - PublishNotReadyAddresses: true, - }, - } -} - // SearchServiceName get the domain service name, the domain service for statefulset. // domain service have PublishNotReadyAddresses. while used PublishNotReadyAddresses, the fe start need all instance domain can resolve. func SearchServiceName(clusterName string, spec v1.SpecInterface) string { @@ -94,6 +70,8 @@ func ExternalServiceName(clusterName string, spec v1.SpecInterface) string { return clusterName + "-" + v1.DEFAULT_CN + "-service" case *v1.StarRocksFeProxySpec: return clusterName + "-" + v1.DEFAULT_FE_PROXY + "-service" + case *v1.StarRocksFeObserverSpec: + return clusterName + "-" + v1.DEFAULT_FE_OBSERVER + "-service" } return "" } diff --git a/pkg/k8sutils/templates/service/spec_test.go b/pkg/k8sutils/templates/service/spec_test.go index 69b99d6d7..fa94de4d7 100644 --- a/pkg/k8sutils/templates/service/spec_test.go +++ b/pkg/k8sutils/templates/service/spec_test.go @@ -23,7 +23,6 @@ import ( v1 "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1" "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/load" - "github.com/StarRocks/starrocks-kubernetes-operator/pkg/k8sutils/templates/object" ) func TestMakeSearchService(t *testing.T) { @@ -97,7 +96,7 @@ func TestMakeSearchService(t *testing.T) { } } -func TestMakeSearchServiceForSpec(t *testing.T) { +func TestMakeSearchServiceForObserver(t *testing.T) { cluster := &v1.StarRocksCluster{ TypeMeta: metav1.TypeMeta{ APIVersion: v1.GroupVersion.String(), @@ -117,31 +116,41 @@ func TestMakeSearchServiceForSpec(t *testing.T) { }, } - got := MakeSearchServiceForSpec(object.NewFromCluster(cluster), observerSpec, ports, labels) + externalService := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Name: ExternalServiceName(cluster.Name, observerSpec), + Namespace: cluster.Namespace, + OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(cluster, cluster.GroupVersionKind())}, + }, + Spec: corev1.ServiceSpec{ + Selector: load.Selector(cluster.Name, observerSpec), + }, + } + got := MakeSearchService(SearchServiceName(cluster.Name, observerSpec), externalService, ports, labels) if got.Name != "test-fe-observer-search" { - t.Errorf("MakeSearchServiceForSpec() name = %v, want %v", got.Name, "test-fe-observer-search") + t.Errorf("MakeSearchService() name = %v, want %v", got.Name, "test-fe-observer-search") } if got.Namespace != "default" { - t.Errorf("MakeSearchServiceForSpec() namespace = %v, want %v", got.Namespace, "default") + t.Errorf("MakeSearchService() namespace = %v, want %v", got.Namespace, "default") } if !reflect.DeepEqual(got.Labels, labels) { - t.Errorf("MakeSearchServiceForSpec() labels = %v, want %v", got.Labels, labels) + t.Errorf("MakeSearchService() labels = %v, want %v", got.Labels, labels) } if !reflect.DeepEqual(got.Spec.Selector, load.Selector(cluster.Name, observerSpec)) { - t.Errorf("MakeSearchServiceForSpec() selector = %v, want %v", got.Spec.Selector, load.Selector(cluster.Name, observerSpec)) + t.Errorf("MakeSearchService() selector = %v, want %v", got.Spec.Selector, load.Selector(cluster.Name, observerSpec)) } if got.Spec.ClusterIP != "None" { - t.Errorf("MakeSearchServiceForSpec() ClusterIP = %v, want %v", got.Spec.ClusterIP, "None") + t.Errorf("MakeSearchService() ClusterIP = %v, want %v", got.Spec.ClusterIP, "None") } if !got.Spec.PublishNotReadyAddresses { - t.Errorf("MakeSearchServiceForSpec() PublishNotReadyAddresses = %v, want %v", got.Spec.PublishNotReadyAddresses, true) + t.Errorf("MakeSearchService() PublishNotReadyAddresses = %v, want %v", got.Spec.PublishNotReadyAddresses, true) } if !reflect.DeepEqual(got.Spec.Ports, ports) { - t.Errorf("MakeSearchServiceForSpec() ports = %v, want %v", got.Spec.Ports, ports) + t.Errorf("MakeSearchService() ports = %v, want %v", got.Spec.Ports, ports) } if len(got.OwnerReferences) != 1 || got.OwnerReferences[0].Name != "test" || got.OwnerReferences[0].Kind != "StarRocksCluster" { - t.Errorf("MakeSearchServiceForSpec() OwnerReferences = %v, want one StarRocksCluster owner named test", got.OwnerReferences) + t.Errorf("MakeSearchService() OwnerReferences = %v, want one StarRocksCluster owner named test", got.OwnerReferences) } } @@ -262,12 +271,12 @@ func TestGetFeExternalServiceName(t *testing.T) { want: "test-fe-service", }, { - name: "fe observer does not have external service", + name: "fe observer external service name", args: args{ clusterName: "test", spec: &v1.StarRocksFeObserverSpec{}, }, - want: "", + want: "test-fe-observer-service", }, } for _, tt := range tests { diff --git a/pkg/subcontrollers/fe/fe_controller.go b/pkg/subcontrollers/fe/fe_controller.go index c76786f3a..2d7871ba0 100644 --- a/pkg/subcontrollers/fe/fe_controller.go +++ b/pkg/subcontrollers/fe/fe_controller.go @@ -92,8 +92,9 @@ func (fc *FeController) SyncCluster(ctx context.Context, src *srapi.StarRocksClu logger.V(log.DebugLevel).Info("build fe service", "StarRocksCluster", src) object := object.NewFromCluster(src) defaultLabels := load.Labels(src.Name, feSpec) - svc := rutils.BuildExternalService(object, feSpec, feConfig, load.FeServiceSelector(src.Name), defaultLabels) - internalService := service.MakeSearchServiceForSpec(object, feSpec, []corev1.ServicePort{ + svc := rutils.BuildExternalService(object, feSpec, feConfig, load.Selector(src.Name, feSpec), defaultLabels) + searchServiceName := service.SearchServiceName(src.Name, feSpec) + internalService := service.MakeSearchService(searchServiceName, &svc, []corev1.ServicePort{ { Name: "query-port", Port: rutils.GetPort(feConfig, rutils.QUERY_PORT), diff --git a/pkg/subcontrollers/feobserver/feobserver_controller.go b/pkg/subcontrollers/feobserver/feobserver_controller.go index 7ef5adb59..9752a8c78 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller.go @@ -108,7 +108,9 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star logger.V(log.DebugLevel).Info("build fe observer statefulset", "StarRocksCluster", src) object := object.NewFromCluster(src) defaultLabels := load.Labels(src.Name, observerSpec) - internalService := service.MakeSearchServiceForSpec(object, observerSpec, []corev1.ServicePort{ + svc := rutils.BuildExternalService(object, observerSpec, feConfig, load.Selector(src.Name, observerSpec), defaultLabels) + searchServiceName := service.SearchServiceName(src.Name, observerSpec) + internalService := service.MakeSearchService(searchServiceName, &svc, []corev1.ServicePort{ { Name: "query-port", Port: rutils.GetPort(feConfig, rutils.QUERY_PORT), @@ -134,6 +136,11 @@ func (fc *FeObserverController) SyncCluster(ctx context.Context, src *srapi.Star return err } + if err = k8sutils.ApplyService(ctx, fc.Client, &svc, rutils.ServiceDeepEqual); err != nil { + logger.Error(err, "deploy external service failed", "externalService", svc) + return err + } + return nil } From 59ce545e09d106aa83ab815d9747c9165d4a87ee Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Tue, 20 Oct 2026 15:19:19 +0800 Subject: [PATCH 17/22] fix version comparison Signed-off-by: zhaohehuhu --- pkg/k8sutils/templates/pod/version_compare.go | 22 ++++++++++ .../templates/pod/version_compare_test.go | 30 ++++++++++++++ .../feobserver/feobserver_controller.go | 4 +- .../feobserver/feobserver_controller_test.go | 41 ++++++++++++++++++- .../feobserver/feobserver_pod.go | 4 -- 5 files changed, 94 insertions(+), 7 deletions(-) diff --git a/pkg/k8sutils/templates/pod/version_compare.go b/pkg/k8sutils/templates/pod/version_compare.go index 8ae1772e2..9d588e7e3 100644 --- a/pkg/k8sutils/templates/pod/version_compare.go +++ b/pkg/k8sutils/templates/pod/version_compare.go @@ -12,6 +12,28 @@ type Version struct { Patch int } +// IsLowerThan compares complete versions across release lines. +func IsLowerThan(checkVersion, targetVersion string) (bool, error) { + if strings.Contains(checkVersion, "latest") { + return false, nil + } + checkVer, err := parseVersion(checkVersion) + if err != nil { + return false, fmt.Errorf("failed to parse check version %s: %w", checkVersion, err) + } + targetVer, err := parseVersion(targetVersion) + if err != nil { + return false, fmt.Errorf("failed to parse target version %s: %w", targetVersion, err) + } + if checkVer.Major != targetVer.Major { + return checkVer.Major < targetVer.Major, nil + } + if checkVer.Minor != targetVer.Minor { + return checkVer.Minor < targetVer.Minor, nil + } + return checkVer.Patch < targetVer.Patch, nil +} + func IsLowerThanAny(checkVersion string, targetVersions []string) (bool, error) { if strings.Contains(checkVersion, "latest") { return false, nil diff --git a/pkg/k8sutils/templates/pod/version_compare_test.go b/pkg/k8sutils/templates/pod/version_compare_test.go index 1019b9627..a1865d49e 100644 --- a/pkg/k8sutils/templates/pod/version_compare_test.go +++ b/pkg/k8sutils/templates/pod/version_compare_test.go @@ -92,6 +92,36 @@ func TestParseVersion(t *testing.T) { } } +func TestIsLowerThan(t *testing.T) { + tests := []struct { + checkVersion string + targetVersion string + wantLower bool + wantErr bool + }{ + {checkVersion: "3.9.99", targetVersion: "4.1.0", wantLower: true}, + {checkVersion: "4.0.99", targetVersion: "4.1.0", wantLower: true}, + {checkVersion: "4.1.0", targetVersion: "4.1.0"}, + {checkVersion: "4.2.0", targetVersion: "4.1.0"}, + {checkVersion: "5.0.0", targetVersion: "4.1.0"}, + {checkVersion: "4.1.1", targetVersion: "4.1.2", wantLower: true}, + {checkVersion: "4.1.10", targetVersion: "4.1.2"}, + {checkVersion: "4.2.0-ee", targetVersion: "4.1.0"}, + {checkVersion: "latest", targetVersion: "4.1.0"}, + {checkVersion: "invalid", targetVersion: "4.1.0", wantErr: true}, + {checkVersion: "4.1.0", targetVersion: "invalid", wantErr: true}, + } + for _, tt := range tests { + t.Run(tt.checkVersion+"_vs_"+tt.targetVersion, func(t *testing.T) { + got, err := IsLowerThan(tt.checkVersion, tt.targetVersion) + if (err != nil) != tt.wantErr || got != tt.wantLower { + t.Errorf("IsLowerThan(%q, %q) = %t, %v; want %t, error=%t", + tt.checkVersion, tt.targetVersion, got, err, tt.wantLower, tt.wantErr) + } + }) + } +} + func TestIsLowerThanAny(t *testing.T) { targetVersions := []string{"3.3.17", "3.4.6", "3.5.2"} diff --git a/pkg/subcontrollers/feobserver/feobserver_controller.go b/pkg/subcontrollers/feobserver/feobserver_controller.go index 9752a8c78..85393c9c1 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller.go @@ -225,8 +225,8 @@ func (fc *FeObserverController) Validating(feSpec *srapi.StarRocksFeSpec) error func validateObserverImageVersion(image string) error { imageVersion := pod.GetImageVersion(image) - _, err := pod.IsLowerThanAny(imageVersion, []string{"4.1.0"}) - if err != nil { + isLower, err := pod.IsLowerThan(imageVersion, minFeObserverImageVersion) + if err != nil || isLower { return fmt.Errorf("fe observer requires StarRocks FE image version >= %s "+ "Current image version %s does not enable FE observer", minFeObserverImageVersion, imageVersion) } diff --git a/pkg/subcontrollers/feobserver/feobserver_controller_test.go b/pkg/subcontrollers/feobserver/feobserver_controller_test.go index b668755b6..ed4c5cf30 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller_test.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller_test.go @@ -174,7 +174,11 @@ func TestFeObserver_SyncCluster(t *testing.T) { var observerExternalSvc corev1.Service err = fc.Client.Get(context.Background(), types.NamespacedName{Name: "test-fe-observer-service", Namespace: "default"}, &observerExternalSvc) - require.True(t, apierrors.IsNotFound(err)) + require.NoError(t, err) + require.Equal(t, map[string]string{ + srapi.OwnerReference: "test-fe-observer", + srapi.ComponentLabelKey: srapi.DEFAULT_FE_OBSERVER, + }, observerExternalSvc.Spec.Selector) var observerSearchSvc corev1.Service err = fc.Client.Get(context.Background(), types.NamespacedName{Name: "test-fe-observer-search", Namespace: "default"}, &observerSearchSvc) @@ -225,6 +229,41 @@ func TestFeObserver_UpdateClusterStatusAllowsMissingStatefulSet(t *testing.T) { require.Empty(t, src.Status.StarRocksFeObserverStatus.ResourceNames) } +func TestFeObserver_ValidatingImageVersion(t *testing.T) { + tests := []struct { + version string + wantErr bool + }{ + {version: "3.5.20", wantErr: true}, + {version: "4.0.10", wantErr: true}, + {version: "4.1.0"}, + {version: "4.1.1"}, + {version: "4.2.0"}, + {version: "5.0.0"}, + {version: "4.2.0-ee"}, + {version: "latest"}, + {version: "4.2.invalid", wantErr: true}, + {version: "invalid", wantErr: true}, + } + fc := &feobserver.FeObserverController{} + for _, tt := range tests { + t.Run(tt.version, func(t *testing.T) { + spec := &srapi.StarRocksFeSpec{ + StarRocksComponentSpec: srapi.StarRocksComponentSpec{ + StarRocksLoadSpec: srapi.StarRocksLoadSpec{Image: "starrocks/fe:" + tt.version}, + }, + ObserverSpec: &srapi.StarRocksFeObserverSpec{Enabled: true}, + } + err := fc.Validating(spec) + if tt.wantErr { + require.ErrorContains(t, err, "fe observer requires StarRocks FE image version >= 4.1.0") + } else { + require.NoError(t, err) + } + }) + } +} + func TestFeObserver_SyncClusterRejectsUnsupportedImage(t *testing.T) { src := &srapi.StarRocksCluster{ ObjectMeta: metav1.ObjectMeta{ diff --git a/pkg/subcontrollers/feobserver/feobserver_pod.go b/pkg/subcontrollers/feobserver/feobserver_pod.go index f4371de97..028239103 100644 --- a/pkg/subcontrollers/feobserver/feobserver_pod.go +++ b/pkg/subcontrollers/feobserver/feobserver_pod.go @@ -60,10 +60,6 @@ func (fc *FeObserverController) buildPodTemplate(src *srapi.StarRocksCluster, feServiceName := service.ExternalServiceName(src.Name, src.Spec.StarRocksFeSpec) envs := pod.Envs(observerSpec, config, feServiceName, src.Namespace, observerSpec.FeEnvVars) - envs = append(envs, corev1.EnvVar{ - Name: srapi.FE_SERVICE_NAME, - Value: feServiceName, - }) httpPort := rutils.GetPort(config, rutils.HTTP_PORT) feObserverContainer := corev1.Container{ Name: srapi.DEFAULT_FE_OBSERVER, From 52d9eb437ed5684af76c62c572a6e0ff80ca2ef7 Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Tue, 20 Oct 2026 15:39:46 +0800 Subject: [PATCH 18/22] fix Signed-off-by: zhaohehuhu --- pkg/subcontrollers/fe/fe_controller_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/subcontrollers/fe/fe_controller_test.go b/pkg/subcontrollers/fe/fe_controller_test.go index 25805921a..6bc6a32b7 100644 --- a/pkg/subcontrollers/fe/fe_controller_test.go +++ b/pkg/subcontrollers/fe/fe_controller_test.go @@ -174,7 +174,8 @@ func Test_SyncDeploy(t *testing.T) { require.NoError(t, fc.Client.Get(context.Background(), types.NamespacedName{Name: load.Name(src.Name, spec), Namespace: "default"}, &st)) require.Equal(t, map[string]string{ - srapi.FeServiceLabelKey: "test-fe", + srapi.OwnerReference: "test-fe", + srapi.ComponentLabelKey: srapi.DEFAULT_FE, }, asvc.Spec.Selector) require.Equal(t, load.Selector(src.Name, spec), rsvc.Spec.Selector) require.Equal(t, load.Selector(src.Name, spec), st.Spec.Selector.MatchLabels) From 8e949b1480edc4bc0e50d25168fd97789e4f1c6c Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Tue, 20 Oct 2026 15:46:48 +0800 Subject: [PATCH 19/22] fix Signed-off-by: zhaohehuhu --- pkg/k8sutils/templates/service/spec.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/k8sutils/templates/service/spec.go b/pkg/k8sutils/templates/service/spec.go index 6784dba02..1552b7367 100644 --- a/pkg/k8sutils/templates/service/spec.go +++ b/pkg/k8sutils/templates/service/spec.go @@ -15,8 +15,9 @@ package service import ( - v1 "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1" corev1 "k8s.io/api/core/v1" + + v1 "github.com/StarRocks/starrocks-kubernetes-operator/pkg/apis/starrocks/v1" ) func MakeSearchService(serviceName string, externalService *corev1.Service, ports []corev1.ServicePort, From 232c836463fdfdea54dfc8b0f7d5eb75184fe5eb Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Wed, 28 Oct 2026 11:00:47 +0800 Subject: [PATCH 20/22] fix external service Signed-off-by: zhaohehuhu --- pkg/common/resource_utils/service.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/common/resource_utils/service.go b/pkg/common/resource_utils/service.go index 1f17a7806..5cb1764bc 100644 --- a/pkg/common/resource_utils/service.go +++ b/pkg/common/resource_utils/service.go @@ -89,6 +89,8 @@ func BuildExternalService(object object.StarRocksObject, spec srapi.SpecInterfac switch spec.(type) { case *srapi.StarRocksFeSpec: srPorts = getFeServicePorts(config, starRocksService) + case *srapi.StarRocksFeObserverSpec: + srPorts = getFeServicePorts(config, starRocksService) case *srapi.StarRocksBeSpec: srPorts = getBeServicePorts(config, starRocksService) case *srapi.StarRocksCnSpec: From 62fc0443f75762f39f8ed9b83a12015e433a6557 Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Wed, 28 Oct 2026 11:04:30 +0800 Subject: [PATCH 21/22] delete external service Signed-off-by: zhaohehuhu --- .../feobserver/feobserver_controller.go | 5 ++++ .../feobserver/feobserver_controller_test.go | 28 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/pkg/subcontrollers/feobserver/feobserver_controller.go b/pkg/subcontrollers/feobserver/feobserver_controller.go index 85393c9c1..a41b2efee 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller.go @@ -203,6 +203,11 @@ func (fc *FeObserverController) ClearCluster(ctx context.Context, src *srapi.Sta logger.Error(err, "delete search service failed", "searchServiceName", searchServiceName) return err } + externalServiceName := service.ExternalServiceName(src.Name, observerSpec) + if err := k8sutils.DeleteService(ctx, fc.Client, src.Namespace, externalServiceName); err != nil && !apierrors.IsNotFound(err) { + logger.Error(err, "delete external service failed", "externalServiceName", externalServiceName) + return err + } return nil } diff --git a/pkg/subcontrollers/feobserver/feobserver_controller_test.go b/pkg/subcontrollers/feobserver/feobserver_controller_test.go index ed4c5cf30..c42148f5a 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller_test.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller_test.go @@ -96,13 +96,13 @@ func TestFeObserver_ClearCluster(t *testing.T) { var est appsv1.StatefulSet err = fc.Client.Get(context.Background(), types.NamespacedName{Name: sts.Name, Namespace: "default"}, &est) - require.True(t, err == nil || apierrors.IsNotFound(err)) + require.True(t, apierrors.IsNotFound(err)) var esvc corev1.Service err = fc.Client.Get(context.Background(), types.NamespacedName{Name: svc.Name, Namespace: "default"}, &esvc) - require.True(t, err == nil || apierrors.IsNotFound(err)) + require.True(t, apierrors.IsNotFound(err)) var essvc corev1.Service err = fc.Client.Get(context.Background(), types.NamespacedName{Name: ssvc.Name, Namespace: "default"}, &essvc) - require.True(t, err == nil || apierrors.IsNotFound(err)) + require.True(t, apierrors.IsNotFound(err)) } func TestFeObserver_SyncCluster(t *testing.T) { @@ -316,17 +316,33 @@ func TestFeObserver_SyncClusterDisabled(t *testing.T) { }, } - fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src), fake.GetEventRecorderFor(nil)) + sts := &appsv1.StatefulSet{ + ObjectMeta: metav1.ObjectMeta{Name: "test-fe-observer", Namespace: "default"}, + } + externalSvc := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{Name: "test-fe-observer-service", Namespace: "default"}, + } + searchSvc := &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{Name: "test-fe-observer-search", Namespace: "default"}, + } + fc := feobserver.New(fake.NewFakeClient(srapi.Scheme, src, sts, externalSvc, searchSvc), fake.GetEventRecorderFor(nil)) err := fc.SyncCluster(context.Background(), src) require.NoError(t, err) err = fc.UpdateClusterStatus(context.Background(), src) require.NoError(t, err) require.Nil(t, src.Status.StarRocksFeObserverStatus) - var sts appsv1.StatefulSet + var actualSts appsv1.StatefulSet err = fc.Client.Get(context.Background(), - types.NamespacedName{Name: "test-fe-observer", Namespace: "default"}, &sts) + types.NamespacedName{Name: sts.Name, Namespace: "default"}, &actualSts) require.True(t, apierrors.IsNotFound(err)) + for _, name := range []string{externalSvc.Name, searchSvc.Name} { + var svc corev1.Service + err = fc.Client.Get(context.Background(), types.NamespacedName{Name: name, Namespace: "default"}, &svc) + require.True(t, apierrors.IsNotFound(err), "service %s should be deleted", name) + } + + require.NoError(t, fc.SyncCluster(context.Background(), src)) } func TestFeObserver_Ready(t *testing.T) { From 5f39bcf4384b1255118a7ea8fe37d5114cce3438 Mon Sep 17 00:00:00 2001 From: zhaohehuhu Date: Wed, 28 Oct 2026 15:19:34 +0800 Subject: [PATCH 22/22] fix UTs Signed-off-by: zhaohehuhu --- pkg/apis/starrocks/v1/labels.go | 3 --- pkg/k8sutils/load/load.go | 6 ------ pkg/k8sutils/templates/pod/spec.go | 2 -- pkg/k8sutils/templates/pod/spec_test.go | 1 - pkg/subcontrollers/fe/fe_controller_test.go | 1 - pkg/subcontrollers/feobserver/feobserver_controller_test.go | 1 - 6 files changed, 14 deletions(-) diff --git a/pkg/apis/starrocks/v1/labels.go b/pkg/apis/starrocks/v1/labels.go index e98f2edfa..2ebfc353f 100644 --- a/pkg/apis/starrocks/v1/labels.go +++ b/pkg/apis/starrocks/v1/labels.go @@ -26,9 +26,6 @@ const ( // ComponentResourceHash the component hash ComponentResourceHash string = "app.starrocks.components/hash" - - // FeServiceLabelKey marks pods that should be exposed through the FE external service. - FeServiceLabelKey string = "app.starrocks.io/fe-service" ) // the labels value. default statefulset name diff --git a/pkg/k8sutils/load/load.go b/pkg/k8sutils/load/load.go index 833478139..d69d927e5 100644 --- a/pkg/k8sutils/load/load.go +++ b/pkg/k8sutils/load/load.go @@ -21,9 +21,3 @@ import ( func Selector(clusterName string, spec v1.SpecInterface) map[string]string { return Labels(Name(clusterName, spec), spec) } - -func FeServiceSelector(clusterName string) map[string]string { - return map[string]string{ - v1.FeServiceLabelKey: Name(clusterName, (*v1.StarRocksFeSpec)(nil)), - } -} diff --git a/pkg/k8sutils/templates/pod/spec.go b/pkg/k8sutils/templates/pod/spec.go index 11dc0708a..0a07e09f6 100644 --- a/pkg/k8sutils/templates/pod/spec.go +++ b/pkg/k8sutils/templates/pod/spec.go @@ -78,12 +78,10 @@ func Labels(clusterName string, spec v1.SpecInterface) map[string]string { if v != nil { addLabels(labels, v.PodLabels) } - labels[v1.FeServiceLabelKey] = load.Name(clusterName, (*v1.StarRocksFeSpec)(nil)) case *v1.StarRocksFeObserverSpec: if v != nil { addLabels(labels, v.ComponentSpec.PodLabels) } - labels[v1.FeServiceLabelKey] = load.Name(clusterName, (*v1.StarRocksFeSpec)(nil)) case *v1.StarRocksFeProxySpec: if v != nil { addLabels(labels, v.PodLabels) diff --git a/pkg/k8sutils/templates/pod/spec_test.go b/pkg/k8sutils/templates/pod/spec_test.go index 126972b14..47f0090fd 100644 --- a/pkg/k8sutils/templates/pod/spec_test.go +++ b/pkg/k8sutils/templates/pod/spec_test.go @@ -146,7 +146,6 @@ func TestLabels(t *testing.T) { "l1": "v1", v1.OwnerReference: "test-fe", v1.ComponentLabelKey: v1.DEFAULT_FE, - v1.FeServiceLabelKey: "test-fe", }, }, } diff --git a/pkg/subcontrollers/fe/fe_controller_test.go b/pkg/subcontrollers/fe/fe_controller_test.go index 6bc6a32b7..4c3451699 100644 --- a/pkg/subcontrollers/fe/fe_controller_test.go +++ b/pkg/subcontrollers/fe/fe_controller_test.go @@ -179,7 +179,6 @@ func Test_SyncDeploy(t *testing.T) { }, asvc.Spec.Selector) require.Equal(t, load.Selector(src.Name, spec), rsvc.Spec.Selector) require.Equal(t, load.Selector(src.Name, spec), st.Spec.Selector.MatchLabels) - require.Equal(t, "test-fe", st.Spec.Template.Labels[srapi.FeServiceLabelKey]) } func TestCheckFEReady(t *testing.T) { diff --git a/pkg/subcontrollers/feobserver/feobserver_controller_test.go b/pkg/subcontrollers/feobserver/feobserver_controller_test.go index c42148f5a..36e57bc69 100644 --- a/pkg/subcontrollers/feobserver/feobserver_controller_test.go +++ b/pkg/subcontrollers/feobserver/feobserver_controller_test.go @@ -194,7 +194,6 @@ func TestFeObserver_SyncCluster(t *testing.T) { srapi.OwnerReference: "test-fe-observer", srapi.ComponentLabelKey: srapi.DEFAULT_FE_OBSERVER, }, sts.Spec.Selector.MatchLabels) - require.Equal(t, "test-fe", sts.Spec.Template.Labels[srapi.FeServiceLabelKey]) require.Equal(t, "starrocks.com/fe:4.1.0", sts.Spec.Template.Spec.Containers[0].Image) require.Equal(t, corev1.ResourceList{ corev1.ResourceCPU: resource.MustParse("4"),