Skip to content

Commit

Permalink
feat: support NoRSMEnv feature gate (#8059)
Browse files Browse the repository at this point in the history
  • Loading branch information
free6om authored Aug 30, 2024
1 parent 117f8b5 commit 5fe4b49
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func init() {
viper.SetDefault(constant.FeatureGateIgnoreConfigTemplateDefaultMode, false)
viper.SetDefault(constant.FeatureGateComponentReplicasAnnotation, true)
viper.SetDefault(constant.FeatureGateInPlacePodVerticalScaling, false)
viper.SetDefault(constant.FeatureGateNoRSMEnv, false)
}

type flagName string
Expand Down
2 changes: 2 additions & 0 deletions deploy/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ spec:
value: {{ .Values.featureGates.componentReplicasAnnotation.enabled | quote }}
- name: IN_PLACE_POD_VERTICAL_SCALING
value: {{ .Values.featureGates.inPlacePodVerticalScaling.enabled | quote }}
- name: NO_RSM_ENV
value: {{ .Values.featureGates.noRSMEnv.enabled | quote }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
Expand Down
2 changes: 2 additions & 0 deletions deploy/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,8 @@ featureGates:
enabled: true
inPlacePodVerticalScaling:
enabled: false
noRSMEnv:
enabled: false

vmagent:

Expand Down
3 changes: 3 additions & 0 deletions pkg/constant/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ const (
// FeatureGateInPlacePodVerticalScaling specifies to enable in-place pod vertical scaling
// NOTE: This feature depends on the InPlacePodVerticalScaling feature of the K8s cluster in which the KubeBlocks runs.
FeatureGateInPlacePodVerticalScaling = "IN_PLACE_POD_VERTICAL_SCALING"

// FeatureGateNoRSMEnv specifies not to create the '$(instanceset.name)-rsm-env' ConfigMap object.
FeatureGateNoRSMEnv = "NO_RSM_ENV"
)
7 changes: 3 additions & 4 deletions pkg/controller/instanceset/object_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func getHeadlessSvcName(itsName string) string {
}

func buildEnvConfigMap(its workloads.InstanceSet, labels map[string]string) (*corev1.ConfigMap, error) {
if viper.GetBool(constant.FeatureGateNoRSMEnv) {
return nil, nil
}
envData, err := buildEnvConfigData(its)
if err != nil {
return nil, err
Expand Down Expand Up @@ -433,10 +436,6 @@ func buildEnvConfigData(its workloads.InstanceSet) (map[string]string, error) {
uid := string(its.UID)
strReplicas := strconv.Itoa(int(*its.Spec.Replicas))
generateReplicaEnv := func(prefix string, podNames []string) {
// avoid to build too many envs
// TODO(free6om): don't hard code
maxEnv := 128
podNames = podNames[:min(len(podNames), maxEnv)]
for _, podName := range podNames {
_, ordinal := ParseParentNameAndOrdinal(podName)
hostNameTplKey := prefix + strconv.Itoa(ordinal) + "_HOSTNAME"
Expand Down
5 changes: 4 additions & 1 deletion pkg/controller/instanceset/reconciler_assistant_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ func (a *assistantObjectReconciler) Reconcile(tree *kubebuilderx.ObjectTree) (ku
if svc != nil {
objects = append(objects, svc)
}
objects = append(objects, headLessSvc, envConfig)
objects = append(objects, headLessSvc)
if envConfig != nil {
objects = append(objects, envConfig)
}
for _, object := range objects {
if err := intctrlutil.SetOwnership(its, object, model.GetScheme(), finalizer); err != nil {
return kubebuilderx.Continue, err
Expand Down

0 comments on commit 5fe4b49

Please sign in to comment.