Skip to content

Commit

Permalink
Merge pull request #4323 from Rains6/dev-mcs-zhc
Browse files Browse the repository at this point in the history
feat: List&watch mcs and service, reconcile the work in execution namespace
  • Loading branch information
karmada-bot authored Nov 29, 2023
2 parents f46f681 + 33ae852 commit 7032767
Show file tree
Hide file tree
Showing 7 changed files with 442 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/controller-manager/app/controllermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import (
"github.com/karmada-io/karmada/pkg/controllers/gracefuleviction"
"github.com/karmada-io/karmada/pkg/controllers/hpareplicassyncer"
"github.com/karmada-io/karmada/pkg/controllers/mcs"
"github.com/karmada-io/karmada/pkg/controllers/multiclusterservice"
"github.com/karmada-io/karmada/pkg/controllers/namespace"
"github.com/karmada-io/karmada/pkg/controllers/status"
"github.com/karmada-io/karmada/pkg/controllers/unifiedauth"
Expand Down Expand Up @@ -224,6 +225,7 @@ func init() {
controllers["federatedHorizontalPodAutoscaler"] = startFederatedHorizontalPodAutoscalerController
controllers["cronFederatedHorizontalPodAutoscaler"] = startCronFederatedHorizontalPodAutoscalerController
controllers["hpaReplicasSyncer"] = startHPAReplicasSyncerController
controllers["multiclusterservice"] = startMCSController
}

func startClusterController(ctx controllerscontext.Context) (enabled bool, err error) {
Expand Down Expand Up @@ -631,6 +633,18 @@ func startHPAReplicasSyncerController(ctx controllerscontext.Context) (enabled b
return true, nil
}

func startMCSController(ctx controllerscontext.Context) (enabled bool, err error) {
mcsController := &multiclusterservice.MCSController{
Client: ctx.Mgr.GetClient(),
EventRecorder: ctx.Mgr.GetEventRecorderFor(multiclusterservice.ControllerName),
RateLimiterOptions: ctx.Opts.RateLimiterOptions,
}
if err = mcsController.SetupWithManager(ctx.Mgr); err != nil {
return false, err
}
return true, nil
}

// setupControllers initialize controllers and setup one by one.
func setupControllers(mgr controllerruntime.Manager, opts *options.Options, stopChan <-chan struct{}) {
restConfig := mgr.GetConfig()
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/networking/v1alpha1/service_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const (
ResourcePluralMultiClusterService = "multiclusterservices"
// ResourceNamespaceScopedMultiClusterService indicates if MultiClusterService is NamespaceScoped.
ResourceNamespaceScopedMultiClusterService = true
// MCSServiceAppliedConditionType is indicates the condition type of mcs service applied.
MCSServiceAppliedConditionType = "ServiceApplied"
)

// +genclient
Expand Down
23 changes: 23 additions & 0 deletions pkg/apis/networking/v1alpha1/well_known_constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2023 The Karmada Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

const (
// MultiClusterServicePermanentIDLabel is the identifier of a MultiClusterService object.
// Karmada generates a unique identifier, such as metadata.UUID, for each MultiClusterService object.
// This identifier will be used as a label selector to locate corresponding work of service.
// The reason for generating a new unique identifier instead of simply using metadata.UUID is because:
// In backup scenarios, when applying the backup resource manifest in a new cluster, the UUID may change.
MultiClusterServicePermanentIDLabel = "multiclusterservice.karmada.io/permanent-id"
)
Loading

0 comments on commit 7032767

Please sign in to comment.