Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions api/disaggregated/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ type ComputeGroup struct {
// Default System Init means that the container must be started in privileged mode.
// Default System Init configuration is implemented through the initContainers of the pod, so changes to this configuration may be ignored by k8s when it is not the first deployment.
SkipDefaultSystemInit bool `json:"skipDefaultSystemInit,omitempty"`

// AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
// Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
// Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
// Changing this configuration will cause a BE rolling restart.
AutoResolveLimitCPU bool `json:"autoResolveLimitCPU,omitempty"`
}

type CommonSpec struct {
Expand Down
16 changes: 14 additions & 2 deletions api/doris/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
)

var (
AnnotationDebugKey = "selectdb.com.doris/runmode"
AnnotationDebugValue = "debug"
AnnotationDebugKey = "selectdb.com.doris/runmode"
AnnotationDebugValue = "debug"
AnnotationDebugDorisKey = "apache.com.doris/runmode"
)

Expand Down Expand Up @@ -129,6 +129,12 @@ type BeSpec struct {
//EnableFeAffinity schedule the be pod on the hosts that have fe pod. when in test situation or have 3 fe and 3 be nodes, and wants one fe and one be in same host.
//the weight of antiAffinity in same node is greater than this affinity.
EnableFeAffinity bool `json:"enableFeAffinity,omitempty"`

// AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
// Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
// Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
// Changing this configuration will cause a BE rolling restart.
AutoResolveLimitCPU bool `json:"autoResolveLimitCPU,omitempty"`
}

// FeAddress specify the fe address, please set it when you deploy fe outside k8s or deploy components use crd except fe, if not set .
Expand Down Expand Up @@ -158,6 +164,12 @@ type CnSpec struct {

//AutoScalingPolicy auto scaling strategy
AutoScalingPolicy *AutoScalingPolicy `json:"autoScalingPolicy,omitempty"`

// AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
// Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
// Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
// Changing this configuration will cause a BE rolling restart.
AutoResolveLimitCPU bool `json:"autoResolveLimitCPU,omitempty"`
}

// BrokerSpec describes a template for creating copies of a broker software service, if deploy broker we recommend you add affinity for deploy with be pod.
Expand Down
21 changes: 21 additions & 0 deletions config/crd/bases/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,13 @@ spec:
description: annotation for fe pods. user can config monitor annotation
for collect to monitor system.
type: object
autoResolveLimitCPU:
description: |-
AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
Changing this configuration will cause a BE rolling restart.
type: boolean
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
Expand Down Expand Up @@ -5093,6 +5100,13 @@ spec:
description: annotation for fe pods. user can config monitor annotation
for collect to monitor system.
type: object
autoResolveLimitCPU:
description: |-
AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
Changing this configuration will cause a BE rolling restart.
type: boolean
autoScalingPolicy:
description: AutoScalingPolicy auto scaling strategy
properties:
Expand Down Expand Up @@ -10146,6 +10160,13 @@ spec:
Annotations is an unstructured key value map stored with a resource that may be
set by external tools to store and retrieve arbitrary metadata.
type: object
autoResolveLimitCPU:
description: |-
AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
Changing this configuration will cause a BE rolling restart.
type: boolean
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,13 @@ spec:
Annotations is an unstructured key value map stored with a resource that may be
set by external tools to store and retrieve arbitrary metadata.
type: object
autoResolveLimitCPU:
description: |-
AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
Changing this configuration will cause a BE rolling restart.
type: boolean
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/doris.apache.com_dorisclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,13 @@ spec:
description: annotation for fe pods. user can config monitor annotation
for collect to monitor system.
type: object
autoResolveLimitCPU:
description: |-
AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
Changing this configuration will cause a BE rolling restart.
type: boolean
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
Expand Down Expand Up @@ -5093,6 +5100,13 @@ spec:
description: annotation for fe pods. user can config monitor annotation
for collect to monitor system.
type: object
autoResolveLimitCPU:
description: |-
AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
Changing this configuration will cause a BE rolling restart.
type: boolean
autoScalingPolicy:
description: AutoScalingPolicy auto scaling strategy
properties:
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/doris.selectdb.com_dorisclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,13 @@ spec:
description: annotation for fe pods. user can config monitor annotation
for collect to monitor system.
type: object
autoResolveLimitCPU:
description: |-
AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
Changing this configuration will cause a BE rolling restart.
type: boolean
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
Expand Down Expand Up @@ -5093,6 +5100,13 @@ spec:
description: annotation for fe pods. user can config monitor annotation
for collect to monitor system.
type: object
autoResolveLimitCPU:
description: |-
AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
Changing this configuration will cause a BE rolling restart.
type: boolean
autoScalingPolicy:
description: AutoScalingPolicy auto scaling strategy
properties:
Expand Down
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,7 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,13 @@ spec:
Annotations is an unstructured key value map stored with a resource that may be
set by external tools to store and retrieve arbitrary metadata.
type: object
autoResolveLimitCPU:
description: |-
AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
Changing this configuration will cause a BE rolling restart.
type: boolean
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,13 @@ spec:
description: annotation for fe pods. user can config monitor annotation
for collect to monitor system.
type: object
autoResolveLimitCPU:
description: |-
AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
Changing this configuration will cause a BE rolling restart.
type: boolean
claims:
description: |-
Claims lists the names of resources, defined in spec.resourceClaims,
Expand Down Expand Up @@ -5093,6 +5100,13 @@ spec:
description: annotation for fe pods. user can config monitor annotation
for collect to monitor system.
type: object
autoResolveLimitCPU:
description: |-
AutoResolveLimitCPU indicates whether to automatically set the CPU limit to doris BE config.
Default value is 'false'. This means that the Doris BE is unaware of the CPU configuration of resources.
Enabling this configuration means injecting an ENV named BE_CPU_LIMIT with the value requests.cpu into the pod. This configuration will also appear in the 'be.conf' file inside the BE container.
Changing this configuration will cause a BE rolling restart.
type: boolean
autoScalingPolicy:
description: AutoScalingPolicy auto scaling strategy
properties:
Expand Down
30 changes: 19 additions & 11 deletions pkg/common/utils/resource/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
package resource

import (
"strconv"
"strings"

dv1 "github.com/apache/doris-operator/api/disaggregated/v1"
v1 "github.com/apache/doris-operator/api/doris/v1"
"github.com/apache/doris-operator/pkg/common/utils/kerberos"
Expand All @@ -26,8 +29,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/klog/v2"
"strconv"
"strings"
)

const (
Expand Down Expand Up @@ -87,7 +88,7 @@ const (

DISAGGREGATED_FE_MAIN_CONTAINER_NAME = "fe"
DISAGGREGATED_BE_MAIN_CONTAINER_NAME = "compute"
DISAGGREGATED_MS_MAIN_CONTAINER_NAME= "metaservice"
DISAGGREGATED_MS_MAIN_CONTAINER_NAME = "metaservice"
)

type ProbeType string
Expand Down Expand Up @@ -452,6 +453,14 @@ func NewBaseMainContainer(dcr *v1.DorisCluster, config map[string]interface{}, c
envs = append(envs, corev1.EnvVar{Name: "SKIP_CHECK_ULIMIT", Value: "true"})
}

if componentType == v1.Component_BE && dcr.Spec.BeSpec.AutoResolveLimitCPU && spec.Limits.Cpu() != nil {
envs = append(envs, corev1.EnvVar{Name: "BE_CPU_LIMIT", Value: spec.Limits.Cpu().String()})
}

if componentType == v1.Component_CN && dcr.Spec.CnSpec.AutoResolveLimitCPU && spec.Limits.Cpu() != nil {
envs = append(envs, corev1.EnvVar{Name: "BE_CPU_LIMIT", Value: spec.Limits.Cpu().String()})
}

if len(GetMountConfigMapInfo(spec.ConfigMapInfo)) != 0 {
_, configVolumeMounts := getMultiConfigVolumeAndVolumeMount(&spec.ConfigMapInfo, componentType)
volumeMounts = append(volumeMounts, configVolumeMounts...)
Expand Down Expand Up @@ -571,12 +580,12 @@ func buildKerberosEnv(info *v1.KerberosInfo, config map[string]interface{}, comp
return buildKerberosEnvUseSecretMountPath(info.KeytabPath, config, string(componentType))
}

func BuildKerberosEnvForDDC(info *dv1.KerberosInfo, config map[string]interface{}, componentType dv1.DisaggregatedComponentType)[]corev1.EnvVar {
func BuildKerberosEnvForDDC(info *dv1.KerberosInfo, config map[string]interface{}, componentType dv1.DisaggregatedComponentType) []corev1.EnvVar {
if info == nil {
return nil
}

return buildKerberosEnvUseSecretMountPath(info.KeytabPath, config, string(componentType))
return buildKerberosEnvUseSecretMountPath(info.KeytabPath, config, string(componentType))
}

func buildKerberosEnvUseSecretMountPath(keytabPath string, config map[string]interface{}, componentType string) []corev1.EnvVar {
Expand Down Expand Up @@ -739,8 +748,7 @@ func getFeDefaultVolumesVolumeMounts() ([]corev1.Volume, []corev1.VolumeMount) {
return volumes, volumMounts
}

//
func GetPodInfoVolumesVolumeMounts() ([]corev1.Volume, []corev1.VolumeMount){
func GetPodInfoVolumesVolumeMounts() ([]corev1.Volume, []corev1.VolumeMount) {
return appendPodInfoVolumesVolumeMounts(nil, nil)
}

Expand Down Expand Up @@ -932,16 +940,16 @@ func getKerberosVolumeAndVolumeMount(kerberosInfo *v1.KerberosInfo) ([]corev1.Vo
return getKerberosConfigAndSecretVolumeAndVolumeMount(kerberosInfo.Krb5ConfigMap, kerberosInfo.KeytabSecretName)
}

//get the kerberos volume and mounts to ddc.
func GetDv1KerberosVolumeAndVolumeMount(kerberosInfo *dv1.KerberosInfo)([]corev1.Volume, []corev1.VolumeMount) {
// get the kerberos volume and mounts to ddc.
func GetDv1KerberosVolumeAndVolumeMount(kerberosInfo *dv1.KerberosInfo) ([]corev1.Volume, []corev1.VolumeMount) {
if kerberosInfo == nil {
return []corev1.Volume{}, []corev1.VolumeMount{}
}

return getKerberosConfigAndSecretVolumeAndVolumeMount(kerberosInfo.Krb5ConfigMap, kerberosInfo.KeytabSecretName)
}

//abstract a base function for dcr and ddc used.
// abstract a base function for dcr and ddc used.
func getKerberosConfigAndSecretVolumeAndVolumeMount(configMapName, secretName string) ([]corev1.Volume, []corev1.VolumeMount) {
var volumes []corev1.Volume
var volumeMounts []corev1.VolumeMount
Expand Down Expand Up @@ -1226,7 +1234,7 @@ func constructBeDefaultInitContainer(defaultImage string) corev1.Container {
func UseNewDefaultInitContainerImage(pts *corev1.PodTemplateSpec) {
var beImage string
for _, c := range pts.Spec.Containers {
if c.Name == string(v1.Component_BE) || c.Name == string(DISAGGREGATED_BE_MAIN_CONTAINER_NAME){
if c.Name == string(v1.Component_BE) || c.Name == string(DISAGGREGATED_BE_MAIN_CONTAINER_NAME) {
beImage = c.Image
break
}
Expand Down
Loading