Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/crd/bases/starrocks.com_starrocksclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions deploy/starrocks.com_starrocksclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6413,6 +6413,9 @@ spec:
additionalProperties:
type: string
type: object
observerNumber:
format: int32
type: integer
persistentVolumeClaimRetentionPolicy:
properties:
whenDeleted:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions helm-charts/charts/kube-starrocks/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/starrocks/v1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ const (
const (
COMPONENT_NAME = "COMPONENT_NAME"
FE_SERVICE_NAME = "FE_SERVICE_NAME"
OBSERVER_NUMBER = "OBSERVER_NUMBER"
)
2 changes: 0 additions & 2 deletions pkg/apis/starrocks/v1/load_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -304,7 +303,6 @@ type StarRocksProbe struct {
func (spec *StarRocksLoadSpec) GetReplicas() *int32 {
return spec.Replicas
}

func (spec *StarRocksLoadSpec) GetStorageVolumes() []StorageVolume {
return spec.StorageVolumes
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/starrocks/v1/starrockscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/starrocks/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions pkg/k8sutils/templates/pod/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -142,8 +141,9 @@ func Envs(spec v1.SpecInterface, config map[string]interface{},
addEnv(envVar)
}

switch spec.(type) {
switch s := spec.(type) {
case *v1.StarRocksFeSpec:
observerNumber := s.GetObserverNumber()
for _, envVar := range []corev1.EnvVar{
{
Name: v1.COMPONENT_NAME,
Expand All @@ -153,6 +153,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)
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/k8sutils/templates/pod/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"os"
"reflect"
"strconv"
"testing"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -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: "",
},
Expand Down