mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-18 20:17:04 +00:00
Feat: add feature gate to allow disbale cluster watch at the start of vela-core (#5632)
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
This commit is contained in:
@@ -100,6 +100,7 @@ helm install --create-namespace -n vela-system kubevela kubevela/vela-core --wai
|
||||
| `featureGates.preDispatchDryRun` | enable dryrun before dispatching resources. Enable this flag can help prevent unsuccessful dispatch resources entering resourcetracker and improve the user experiences of gc but at the cost of increasing network requests. | `true` |
|
||||
| `featureGates.validateComponentWhenSharding` | enable component validation in webhook when sharding mode enabled | `false` |
|
||||
| `featureGates.disableWebhookAutoSchedule` | disable auto schedule for application mutating webhook when sharding enabled | `false` |
|
||||
| `featureGates.disableBootstrapClusterInfo` | disable the cluster info bootstrap at the starting of the controller | `false` |
|
||||
|
||||
|
||||
### MultiCluster parameters
|
||||
|
||||
@@ -302,6 +302,7 @@ spec:
|
||||
- "--feature-gates=GzipApplicationRevision={{- .Values.featureGates.gzipApplicationRevision | toString -}}"
|
||||
- "--feature-gates=ZstdApplicationRevision={{- .Values.featureGates.zstdApplicationRevision | toString -}}"
|
||||
- "--feature-gates=PreDispatchDryRun={{- .Values.featureGates.preDispatchDryRun | toString -}}"
|
||||
- "--feature-gates=DisableBootstrapClusterInfo={{- .Values.featureGates.disableBootstrapClusterInfo | toString -}}"
|
||||
{{ if .Values.authentication.enabled }}
|
||||
{{ if .Values.authentication.withUser }}
|
||||
- "--authentication-with-user"
|
||||
|
||||
@@ -112,6 +112,7 @@ optimize:
|
||||
##@param featureGates.preDispatchDryRun enable dryrun before dispatching resources. Enable this flag can help prevent unsuccessful dispatch resources entering resourcetracker and improve the user experiences of gc but at the cost of increasing network requests.
|
||||
##@param featureGates.validateComponentWhenSharding enable component validation in webhook when sharding mode enabled
|
||||
##@param featureGates.disableWebhookAutoSchedule disable auto schedule for application mutating webhook when sharding enabled
|
||||
##@param featureGates.disableBootstrapClusterInfo disable the cluster info bootstrap at the starting of the controller
|
||||
##@param
|
||||
featureGates:
|
||||
enableLegacyComponentRevision: false
|
||||
@@ -124,6 +125,7 @@ featureGates:
|
||||
preDispatchDryRun: true
|
||||
validateComponentWhenSharding: false
|
||||
disableWebhookAutoSchedule: false
|
||||
disableBootstrapClusterInfo: false
|
||||
|
||||
## @section MultiCluster parameters
|
||||
|
||||
|
||||
@@ -100,6 +100,9 @@ const (
|
||||
// If set to true, the webhook will not make auto schedule for applications and users can make customized
|
||||
// scheduler for assigning shards to applications
|
||||
DisableWebhookAutoSchedule = "DisableWebhookAutoSchedule"
|
||||
|
||||
// DisableBootstrapClusterInfo disable the cluster info bootstrap at the starting of the controller
|
||||
DisableBootstrapClusterInfo = "DisableBootstrapClusterInfo"
|
||||
)
|
||||
|
||||
var defaultFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
|
||||
@@ -121,6 +124,7 @@ var defaultFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
|
||||
PreDispatchDryRun: {Default: true, PreRelease: featuregate.Alpha},
|
||||
ValidateComponentWhenSharding: {Default: false, PreRelease: featuregate.Alpha},
|
||||
DisableWebhookAutoSchedule: {Default: false, PreRelease: featuregate.Alpha},
|
||||
DisableBootstrapClusterInfo: {Default: false, PreRelease: featuregate.Alpha},
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/kubevela/pkg/util/singleton"
|
||||
"github.com/oam-dev/cluster-gateway/pkg/generated/clientset/versioned"
|
||||
"github.com/pkg/errors"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
@@ -32,6 +33,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/selection"
|
||||
apitypes "k8s.io/apimachinery/pkg/types"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubectl/pkg/scheme"
|
||||
@@ -43,6 +45,7 @@ import (
|
||||
clustercommon "github.com/oam-dev/cluster-gateway/pkg/common"
|
||||
|
||||
"github.com/oam-dev/kubevela/apis/types"
|
||||
"github.com/oam-dev/kubevela/pkg/features"
|
||||
"github.com/oam-dev/kubevela/pkg/utils/common"
|
||||
velaerrors "github.com/oam-dev/kubevela/pkg/utils/errors"
|
||||
)
|
||||
@@ -55,18 +58,16 @@ func InitClusterInfo(cfg *rest.Config) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := client.New(cfg, client.Options{Scheme: common.Scheme})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
clusters, err := prismclusterv1alpha1.NewClusterClient(client).List(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "fail to get registered clusters")
|
||||
}
|
||||
for _, cluster := range clusters.Items {
|
||||
if err = SetClusterVersionInfo(ctx, cfg, cluster.Name); err != nil {
|
||||
klog.Warningf("set cluster version for %s: %v, skip it...", cluster.Name, err)
|
||||
continue
|
||||
if !utilfeature.DefaultMutableFeatureGate.Enabled(features.DisableBootstrapClusterInfo) {
|
||||
clusters, err := prismclusterv1alpha1.NewClusterClient(singleton.KubeClient.Get()).List(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "fail to get registered clusters")
|
||||
}
|
||||
for _, cluster := range clusters.Items {
|
||||
if err = SetClusterVersionInfo(ctx, cfg, cluster.Name); err != nil {
|
||||
klog.Warningf("set cluster version for %s: %v, skip it...", cluster.Name, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user