-
Notifications
You must be signed in to change notification settings - Fork 890
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api: define API for MultiClusterService
Signed-off-by: jwcesign <[email protected]>
- Loading branch information
Showing
8 changed files
with
192 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
pkg/controllers/mcsendpointslice/mcs_endpointslice_controller.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package mcsendpointslice | ||
|
||
import ( | ||
"context" | ||
|
||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/klog/v2" | ||
controllerruntime "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/predicate" | ||
|
||
networkingv1alpha1 "github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1" | ||
"github.com/karmada-io/karmada/pkg/sharedcli/ratelimiterflag" | ||
) | ||
|
||
const ControllerName = "mcs-endpointslice-controller" | ||
|
||
type MCSEndpointSliceController struct { | ||
client.Client // used to operate ClusterResourceBinding resources. | ||
|
||
RateLimiterOptions ratelimiterflag.Options | ||
} | ||
|
||
func (c *MCSEndpointSliceController) Reconcile(ctx context.Context, req controllerruntime.Request) (controllerruntime.Result, error) { | ||
klog.V(4).Infof("Reconciling MultiClusterService %s.", req.NamespacedName.String()) | ||
|
||
mcs := &networkingv1alpha1.MultiClusterService{} | ||
if err := c.Client.Get(ctx, req.NamespacedName, mcs); err != nil { | ||
if apierrors.IsNotFound(err) { | ||
return controllerruntime.Result{}, nil | ||
} | ||
|
||
return controllerruntime.Result{}, err | ||
} | ||
|
||
if !mcs.DeletionTimestamp.IsZero() { | ||
return controllerruntime.Result{}, nil | ||
} | ||
|
||
return controllerruntime.Result{}, nil | ||
} | ||
|
||
// SetupWithManager creates a controller and register to controller manager. | ||
func (c *MCSEndpointSliceController) SetupWithManager(mgr controllerruntime.Manager) error { | ||
return controllerruntime.NewControllerManagedBy(mgr).For(&networkingv1alpha1.MultiClusterService{}). | ||
WithEventFilter(predicate.GenerationChangedPredicate{}). | ||
WithOptions(controller.Options{RateLimiter: ratelimiterflag.DefaultControllerRateLimiter(c.RateLimiterOptions)}). | ||
Complete(c) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters