Skip to content

Commit

Permalink
chore: add reconcile workers for cluster and component controller.
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyelei committed Mar 11, 2024
1 parent f46b068 commit ee3c1bb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"flag"
"fmt"
"os"
"runtime"
"strings"
"time"

Expand All @@ -34,7 +35,7 @@ import (
snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
"github.com/spf13/pflag"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
k8sruntime "k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
discoverycli "k8s.io/client-go/discovery"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
Expand Down Expand Up @@ -70,7 +71,7 @@ const (
)

var (
scheme = runtime.NewScheme()
scheme = k8sruntime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
)

Expand Down Expand Up @@ -109,6 +110,7 @@ func init() {
viper.SetDefault(constant.KBDataScriptClientsImage, "apecloud/kubeblocks-datascript:latest")
viper.SetDefault(constant.KubernetesClusterDomainEnv, constant.DefaultDNSDomain)
viper.SetDefault(rsm.FeatureGateRSMCompatibilityMode, true)
viper.SetDefault(constant.CfgKBReconcileWorkers, runtime.NumCPU())
}

type flagName string
Expand Down
4 changes: 4 additions & 0 deletions controllers/apps/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -223,6 +224,9 @@ func (r *ClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
// TODO: add filter predicate for core API objects
b := ctrl.NewControllerManagedBy(mgr).
For(&appsv1alpha1.Cluster{}).
WithOptions(controller.Options{
MaxConcurrentReconciles: viper.GetInt(constant.CfgKBReconcileWorkers),
}).
Owns(&appsv1.StatefulSet{}).
Owns(&appsv1.Deployment{}).
Owns(&workloads.ReplicatedStateMachine{}).
Expand Down
4 changes: 4 additions & 0 deletions deploy/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ spec:
- name: CM_AFFINITY
value: {{ toJson . | quote }}
{{- end }}
{{- if .Values.reconcileWorkers }}
- name: KUBEBLOCKS_RECONCILE_WORKERS
values: {{ .Values.reconcileWorkers }}
{{- end }}
{{- with .Values.nodeSelector }}
- name: CM_NODE_SELECTOR
value: {{ toJson . | quote }}
Expand Down
4 changes: 4 additions & 0 deletions deploy/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ image:
##
replicaCount: 1

## MaxConcurrentReconciles for cluster and component controllers.
##
reconcileWorkers: ""

## @param nameOverride
##
nameOverride: ""
Expand Down
2 changes: 2 additions & 0 deletions pkg/constant/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const (

// customized encryption key for encrypting the password of connection credential.
CfgKeyDPEncryptionKey = "DP_ENCRYPTION_KEY"

CfgKBReconcileWorkers = "KUBEBLOCKS_RECONCILE_WORKERS"
)

const (
Expand Down

0 comments on commit ee3c1bb

Please sign in to comment.