Skip to content

Commit 33ae852

Browse files
committed
List&watch mcs and service, reconcile the work in execution namespace
Signed-off-by: z00623291 <[email protected]>
1 parent dd9f54c commit 33ae852

File tree

7 files changed

+442
-0
lines changed

7 files changed

+442
-0
lines changed

cmd/controller-manager/app/controllermanager.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import (
6363
"github.com/karmada-io/karmada/pkg/controllers/gracefuleviction"
6464
"github.com/karmada-io/karmada/pkg/controllers/hpareplicassyncer"
6565
"github.com/karmada-io/karmada/pkg/controllers/mcs"
66+
"github.com/karmada-io/karmada/pkg/controllers/multiclusterservice"
6667
"github.com/karmada-io/karmada/pkg/controllers/namespace"
6768
"github.com/karmada-io/karmada/pkg/controllers/status"
6869
"github.com/karmada-io/karmada/pkg/controllers/unifiedauth"
@@ -224,6 +225,7 @@ func init() {
224225
controllers["federatedHorizontalPodAutoscaler"] = startFederatedHorizontalPodAutoscalerController
225226
controllers["cronFederatedHorizontalPodAutoscaler"] = startCronFederatedHorizontalPodAutoscalerController
226227
controllers["hpaReplicasSyncer"] = startHPAReplicasSyncerController
228+
controllers["multiclusterservice"] = startMCSController
227229
}
228230

229231
func startClusterController(ctx controllerscontext.Context) (enabled bool, err error) {
@@ -631,6 +633,18 @@ func startHPAReplicasSyncerController(ctx controllerscontext.Context) (enabled b
631633
return true, nil
632634
}
633635

636+
func startMCSController(ctx controllerscontext.Context) (enabled bool, err error) {
637+
mcsController := &multiclusterservice.MCSController{
638+
Client: ctx.Mgr.GetClient(),
639+
EventRecorder: ctx.Mgr.GetEventRecorderFor(multiclusterservice.ControllerName),
640+
RateLimiterOptions: ctx.Opts.RateLimiterOptions,
641+
}
642+
if err = mcsController.SetupWithManager(ctx.Mgr); err != nil {
643+
return false, err
644+
}
645+
return true, nil
646+
}
647+
634648
// setupControllers initialize controllers and setup one by one.
635649
func setupControllers(mgr controllerruntime.Manager, opts *options.Options, stopChan <-chan struct{}) {
636650
restConfig := mgr.GetConfig()

pkg/apis/networking/v1alpha1/service_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const (
3030
ResourcePluralMultiClusterService = "multiclusterservices"
3131
// ResourceNamespaceScopedMultiClusterService indicates if MultiClusterService is NamespaceScoped.
3232
ResourceNamespaceScopedMultiClusterService = true
33+
// MCSServiceAppliedConditionType is indicates the condition type of mcs service applied.
34+
MCSServiceAppliedConditionType = "ServiceApplied"
3335
)
3436

3537
// +genclient
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright 2023 The Karmada Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package v1alpha1
15+
16+
const (
17+
// MultiClusterServicePermanentIDLabel is the identifier of a MultiClusterService object.
18+
// Karmada generates a unique identifier, such as metadata.UUID, for each MultiClusterService object.
19+
// This identifier will be used as a label selector to locate corresponding work of service.
20+
// The reason for generating a new unique identifier instead of simply using metadata.UUID is because:
21+
// In backup scenarios, when applying the backup resource manifest in a new cluster, the UUID may change.
22+
MultiClusterServicePermanentIDLabel = "multiclusterservice.karmada.io/permanent-id"
23+
)

0 commit comments

Comments
 (0)