diff --git a/hack/local-up-karmada.sh b/hack/local-up-karmada.sh index a18ea97c7e8a..c768790d5ade 100755 --- a/hack/local-up-karmada.sh +++ b/hack/local-up-karmada.sh @@ -74,7 +74,11 @@ ${KARMADACTL_BIN} join --karmada-context="${KARMADA_APISERVER_CLUSTER_NAME}" ${M "${REPO_ROOT}"/hack/deploy-scheduler-estimator.sh "${MAIN_KUBECONFIG}" "${HOST_CLUSTER_NAME}" "${MEMBER_CLUSTER_KUBECONFIG}" "${MEMBER_CLUSTER_2_NAME}" # step4. register pull mode member clusters and install scheduler-estimator -"${REPO_ROOT}"/hack/deploy-agent-and-estimator.sh "${MAIN_KUBECONFIG}" "${HOST_CLUSTER_NAME}" "${MAIN_KUBECONFIG}" "${KARMADA_APISERVER_CLUSTER_NAME}" "${MEMBER_CLUSTER_KUBECONFIG}" "${PULL_MODE_CLUSTER_NAME}" +export VERSION="latest" +export REGISTRY="docker.io/karmada" +KARMADA_REGISTER_COMMAND=$(${KARMADACTL_BIN} token create --print-register-command --kubeconfig ${MAIN_KUBECONFIG} --karmada-context ${KARMADA_APISERVER_CLUSTER_NAME}) +eval ${KARMADA_REGISTER_COMMAND} --kubeconfig "${MEMBER_CLUSTER_KUBECONFIG}" --context "${PULL_MODE_CLUSTER_NAME}" --cluster-name "${PULL_MODE_CLUSTER_NAME}" --karmada-agent-image "${REGISTRY}/karmada-agent:${VERSION}" --feature-gates CustomizedClusterResourceModeling=true,MultiClusterService=true +"${REPO_ROOT}"/hack/deploy-scheduler-estimator.sh "${MAIN_KUBECONFIG}" "${HOST_CLUSTER_NAME}" "${MEMBER_CLUSTER_KUBECONFIG}" "${PULL_MODE_CLUSTER_NAME}" # step5. deploy metrics-server in member clusters "${REPO_ROOT}"/hack/deploy-k8s-metrics-server.sh "${MEMBER_CLUSTER_KUBECONFIG}" "${MEMBER_CLUSTER_1_NAME}" diff --git a/pkg/karmadactl/register/register.go b/pkg/karmadactl/register/register.go index b0123b6e2359..33ca395a141e 100644 --- a/pkg/karmadactl/register/register.go +++ b/pkg/karmadactl/register/register.go @@ -36,6 +36,7 @@ import ( rbacv1 "k8s.io/api/rbac/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + utilerrors "k8s.io/apimachinery/pkg/util/errors" k8srand "k8s.io/apimachinery/pkg/util/rand" "k8s.io/apimachinery/pkg/util/wait" kubeclient "k8s.io/client-go/kubernetes" @@ -49,6 +50,7 @@ import ( "k8s.io/kubectl/pkg/util/templates" "github.com/karmada-io/karmada/pkg/apis/cluster/validation" + "github.com/karmada-io/karmada/pkg/features" karmadaclientset "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" "github.com/karmada-io/karmada/pkg/karmadactl/options" cmdutil "github.com/karmada-io/karmada/pkg/karmadactl/util" @@ -196,7 +198,7 @@ func NewCmdRegister(parentCommand string) *cobra.Command { flags.Int32Var(&opts.CertExpirationSeconds, "cert-expiration-seconds", DefaultCertExpirationSeconds, "The expiration time of certificate.") flags.BoolVar(&opts.DryRun, "dry-run", false, "Run the command in dry-run mode, without making any server requests.") flags.StringVar(&opts.ProxyServerAddress, "proxy-server-address", "", "Address of the proxy server that is used to proxy to the cluster.") - + flags.StringVar(&opts.FeatureGates, "feature-gates", "", "Comma-separated list of key=value pairs that describe feature gates for alpha/experimental features of karmada-agent. More info: https://github.com/karmada-io/karmada/blob/master/pkg/features/features.go") return cmd } @@ -259,6 +261,9 @@ type CommandRegisterOption struct { memberClusterEndpoint string memberClusterClient *kubeclient.Clientset + // FeatureGates for alpha/experimental features of karmada-agent. + FeatureGates string + // rbacResources contains RBAC resources that grant the necessary permissions for pull mode cluster to access to Karmada control plane. rbacResources *RBACResources } @@ -315,6 +320,15 @@ func (o *CommandRegisterOption) Validate() error { return fmt.Errorf("need to verify CACertHashes, or set --discovery-token-unsafe-skip-ca-verification=true") } + if len(o.FeatureGates) != 0 { + if err := features.FeatureGate.Set(o.FeatureGates); err != nil { + return fmt.Errorf("parse flag --feature-gates failed, %s", err.Error()) + } + if errs := features.FeatureGate.Validate(); len(errs) != 0 { + return fmt.Errorf("invalid feature gates(%s): %s", o.FeatureGates, utilerrors.NewAggregate(errs).Error()) + } + } + return nil } @@ -1030,6 +1044,7 @@ func (o *CommandRegisterOption) makeKarmadaAgentDeployment() *appsv1.Deployment fmt.Sprintf("--proxy-server-address=%s", o.ProxyServerAddress), fmt.Sprintf("--leader-elect-resource-namespace=%s", o.Namespace), fmt.Sprintf("--cluster-namespace=%s", o.ClusterNamespace), + fmt.Sprintf("--feature-gates=%s", o.FeatureGates), "--cluster-status-update-frequency=10s", "--metrics-bind-address=:8080", "--health-probe-bind-address=0.0.0.0:10357",