Skip to content

Commit

Permalink
Merge pull request #289 from catpineapple/workload-group-support
Browse files Browse the repository at this point in the history
[fature](dcr)add workload group support
  • Loading branch information
intelligentfu8 authored Nov 13, 2024
2 parents da8f381 + 34930e5 commit 1a70fe9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/doris/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ type FeSpec struct {
type BeSpec struct {
//the foundation spec for creating be software services.
BaseSpec `json:",inline"`

// EnableWorkloadGroup is a switch that determines whether the doris cluster enables the workload group.
// Default value is 'false'.
// Enabling it means that the container must be started in privileged mode.
// Please confirm whether the host machine and k8s cluster allow it.
// Doris workloadgroup reference document: https://doris.apache.org/docs/admin-manual/resource-admin/workload-group
EnableWorkloadGroup bool `json:"enableWorkloadGroup,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
2 changes: 2 additions & 0 deletions pkg/common/utils/resource/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const (

ENV_FE_PORT = "FE_QUERY_PORT"

ENABLE_WORKLOAD_GROUP = "ENABLE_WORKLOAD_GROUP"

ENV_FE_ELECT_NUMBER = "ELECT_NUMBER"

COMPONENT_TYPE = "COMPONENT_TYPE"
Expand Down
17 changes: 17 additions & 0 deletions pkg/controller/sub_controller/be/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ package be

import (
"context"
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"strconv"

v1 "github.com/apache/doris-operator/api/doris/v1"
Expand All @@ -36,7 +38,15 @@ func (be *Controller) buildBEPodTemplateSpec(dcr *v1.DorisCluster) corev1.PodTem
containers = append(containers, podTemplateSpec.Spec.Containers...)
beContainer := be.beContainer(dcr)
containers = append(containers, beContainer)

if dcr.Spec.BeSpec.EnableWorkloadGroup {
if dcr.Spec.BeSpec.ContainerSecurityContext == nil {
dcr.Spec.BeSpec.ContainerSecurityContext = &corev1.SecurityContext{}
}
dcr.Spec.BeSpec.ContainerSecurityContext.Privileged = pointer.Bool(true)
}
containers = resource.ApplySecurityContext(containers, dcr.Spec.BeSpec.ContainerSecurityContext)

podTemplateSpec.Spec.Containers = containers
return podTemplateSpec
}
Expand Down Expand Up @@ -96,6 +106,13 @@ func (be *Controller) beContainer(dcr *v1.DorisCluster) corev1.Container {
Value: feQueryPort,
})

if dcr.Spec.BeSpec.EnableWorkloadGroup {
c.Env = append(c.Env, corev1.EnvVar{
Name: resource.ENABLE_WORKLOAD_GROUP,
Value: fmt.Sprintf("%t", dcr.Spec.BeSpec.EnableWorkloadGroup),
})
}

return c
}

Expand Down

0 comments on commit 1a70fe9

Please sign in to comment.