-
Notifications
You must be signed in to change notification settings - Fork 247
CCM-MT Poc #935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
priyapande
wants to merge
2
commits into
kubernetes:master
Choose a base branch
from
priyapande:ccm-poc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+557,021
−356,172
Draft
CCM-MT Poc #935
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| bazel-* | ||
| cluster/bin | ||
| MERGED_LICENSES | ||
| go.work | ||
| go.work.sum | ||
| vendor/ | ||
| cloud-controller-manager | ||
| !cmd/cloud-controller-manager/ |
This file contains hidden or 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 hidden or 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 hidden or 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,42 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| cloudprovider "k8s.io/cloud-provider" | ||
| nodeipamcontrolleroptions "k8s.io/cloud-provider-gcp/cmd/cloud-controller-manager/options" | ||
| nodeipamconfig "k8s.io/cloud-provider-gcp/pkg/controller/nodeipam/config" | ||
| "k8s.io/cloud-provider-gcp/pkg/controller/nodemanager" | ||
| "k8s.io/cloud-provider/app" | ||
| cloudcontrollerconfig "k8s.io/cloud-provider/app/config" | ||
| controllermanagerapp "k8s.io/controller-manager/app" | ||
| "k8s.io/controller-manager/controller" | ||
| "k8s.io/klog/v2" | ||
| ) | ||
|
|
||
| // startGkeMultiNodeControllerWrapper is used to take cloud config as input and start the GKE service controller | ||
| func startGkeMultiNodeControllerWrapper(initContext app.ControllerInitContext, completedConfig *cloudcontrollerconfig.CompletedConfig, cloud cloudprovider.Interface, nodeIPAMControllerOptions nodeipamcontrolleroptions.NodeIPAMControllerOptions) app.InitFunc { | ||
| nodeIPAMControllerOptions.ApplyTo(nodeIPAMControllerOptions.NodeIPAMControllerConfiguration) | ||
| return func(ctx context.Context, controllerContext controllermanagerapp.ControllerContext) (controller.Interface, bool, error) { | ||
| return startGkeMultiNodeController(ctx, initContext, controllerContext, completedConfig, cloud, *nodeIPAMControllerOptions.NodeIPAMControllerConfiguration) | ||
| } | ||
| } | ||
|
|
||
| func startGkeMultiNodeController(ctx context.Context, initContext app.ControllerInitContext, controlexContext controllermanagerapp.ControllerContext, completedConfig *cloudcontrollerconfig.CompletedConfig, cloud cloudprovider.Interface, nodeIPAMConfig nodeipamconfig.NodeIPAMControllerConfiguration) (controller.Interface, bool, error) { | ||
| if !enableMultiProject { | ||
| klog.Warning("MultiNodeController is disabled (enable-multi-project is false)") | ||
| return nil, false, nil | ||
| } | ||
| nodeMgrCtrl, err := nodemanager.NewNodeManagerController( | ||
| completedConfig.ClientBuilder.ClientOrDie(initContext.ClientName), | ||
| controlexContext.InformerFactory, | ||
| completedConfig, controlexContext, cloud, nodeIPAMConfig) | ||
| if err != nil { | ||
| klog.Errorf("Failed to start node manager controller: %v", err) | ||
| return nil, false, nil | ||
| } | ||
|
|
||
| go nodeMgrCtrl.Run(ctx.Done()) | ||
|
|
||
| return nil, true, nil | ||
| } |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -28,9 +28,9 @@ import ( | |
| "k8s.io/apimachinery/pkg/util/wait" | ||
| cloudprovider "k8s.io/cloud-provider" | ||
| "k8s.io/cloud-provider-gcp/providers/gce" | ||
| _ "k8s.io/cloud-provider-gcp/providers/gce" | ||
|
|
||
| "k8s.io/cloud-provider/app" | ||
| "k8s.io/cloud-provider/app/config" | ||
| cloudcontrollerconfig "k8s.io/cloud-provider/app/config" | ||
| "k8s.io/cloud-provider/names" | ||
| "k8s.io/cloud-provider/options" | ||
| cliflag "k8s.io/component-base/cli/flag" | ||
|
|
@@ -45,6 +45,9 @@ const ( | |
| gkeServiceLBControllerName = "gke-service-lb-controller" | ||
| gkeServiceControllerClientName = "gke-service-controller" | ||
| gkeServiceAlias = "gke-service" | ||
| multiNodeControllerName = "gke-multi-node-controller" | ||
| multiNodeControllerClientName = "gke-multi-node-controller" | ||
| multiNodeControllerAlias = "gke-multi-node" | ||
| ) | ||
|
|
||
| // enableMultiProject is bound to a command-line flag. When true, it enables the | ||
|
|
@@ -111,6 +114,18 @@ func main() { | |
| aliasMap := names.CCMControllerAliases() | ||
| aliasMap["nodeipam"] = kcmnames.NodeIpamController | ||
| aliasMap[gkeServiceAlias] = gkeServiceLBControllerName | ||
|
|
||
| controllerInitializers[multiNodeControllerName] = app.ControllerInitFuncConstructor{ | ||
| InitContext: app.ControllerInitContext{ | ||
| ClientName: multiNodeControllerClientName, | ||
| }, | ||
| Constructor: func(initContext app.ControllerInitContext, completedConfig *cloudcontrollerconfig.CompletedConfig, cloud cloudprovider.Interface) app.InitFunc { | ||
| return startGkeMultiNodeControllerWrapper(initContext, completedConfig, cloud, nodeIpamController.nodeIPAMControllerOptions) | ||
| }, | ||
| } | ||
| // app.ControllersDisabledByDefault.Insert(names.CloudNodeController) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this |
||
| aliasMap[multiNodeControllerAlias] = multiNodeControllerName | ||
|
|
||
| command := app.NewCloudControllerManagerCommand(ccmOptions, cloudInitializer, controllerInitializers, aliasMap, fss, wait.NeverStop) | ||
|
|
||
| logs.InitLogs() | ||
|
|
@@ -121,7 +136,7 @@ func main() { | |
| } | ||
| } | ||
|
|
||
| func cloudInitializer(config *config.CompletedConfig) cloudprovider.Interface { | ||
| func cloudInitializer(config *cloudcontrollerconfig.CompletedConfig) cloudprovider.Interface { | ||
| cloudConfig := config.ComponentConfig.KubeCloudShared.CloudProvider | ||
|
|
||
| // initialize cloud provider with the cloud provider name and config file provided | ||
|
|
@@ -142,14 +157,15 @@ func cloudInitializer(config *config.CompletedConfig) cloudprovider.Interface { | |
| } | ||
|
|
||
| if enableMultiProject { | ||
| klog.Infof("HELLO PP - Testing") | ||
| gceCloud, ok := (cloud).(*gce.Cloud) | ||
| if !ok { | ||
| // Fail-fast: If enableMultiProject is set, the cloud provider MUST | ||
| // be GCE. A non-GCE provider indicates a misconfiguration. Ideally, | ||
| // we never expect this to be executed. | ||
| klog.Fatalf("multi-project mode requires GCE cloud provider, but got %T", cloud) | ||
| } | ||
| gceCloud.SetProjectFromNodeProviderID(true) | ||
| gceCloud.SetProjectFromNodeProviderID(false) | ||
| } | ||
|
|
||
| if enableDiscretePortForwarding { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented in 3c0ad5f#r2607023536 , this can be added as an opt-in new controller, that runs independently of the other controller, so users can use the flags to enable or disable one or other controller ...