-
Notifications
You must be signed in to change notification settings - Fork 306
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
add configmap based config #928
Conversation
Hi @cadmuxe. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: cadmuxe The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
cmd/glbc/main.go
Outdated
time.Sleep(30 * time.Second) | ||
return |
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.
Should we add IsStopped functions to all the controllers and do a check in here?
/cc @freehan |
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.
just some, will continue
pkg/cmconfig/config.go
Outdated
// Config holds configmap based configurations. | ||
type Config struct { | ||
EnableASM bool | ||
ASMServiceNEGSkipNamespaces string // should be common seperated namespaces. |
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.
Use list of strings?
cmd/glbc/main.go
Outdated
stopCh := make(chan struct{}) | ||
cmConfig := cmConifgController.GetConfig() | ||
if cmConifgController.IsConfigMapConfigModeOn() { |
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.
need to flag gate this behavior. Let me think about it.
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.
I added the flag gate to the controller. if it's enabled, it will try to load the configmap and watch it.
if disabled, it will just return the default config structure.
The idea is, even this feature is disabled, we want to get the default config. and I don't want to put the get default config out from the controller.
/ok-to-test |
cmd/glbc/main.go
Outdated
lbc := controller.NewLoadBalancerController(ctx, stopCh) | ||
|
||
fwc := firewalls.NewFirewallController(ctx, flags.F.NodePortRanges.Values()) | ||
|
||
if ctx.EnableASMConfigMapConfig { |
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.
move to below ctx.Init()
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.
I moved it to the below of lbc := controller.NewLoadBalancerController(ctx, stopCh)
Because the RegisterInformer need to call lbc.Stop.
pkg/context/context.go
Outdated
if cmConfig.EnableASM { | ||
dynamicClient, err := dynamic.NewForConfig(ctx.KubeConfig) | ||
if err != nil { | ||
klog.Fatalf("Failed to create kubernetes dynamic client: %v", err) |
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.
throw an event to the Config Map
} | ||
|
||
// GetConfig returns the internal Config | ||
func (c *ConfigMapConfigController) GetConfig() Config { |
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.
I would recommend this return (Config, boolean)
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.
It the controller was created with NewConfigMapConfigController, the c.currentConfig would never be null. Which means, if it's null, we probably want the program fail directly.
Imaging we change this to (Config, boolean), and in the case that it return (config, false).
What should the caller to doe?
- fail the program [ same as now]
- make a new Config which use the default value. [ I want to put the make default logic in the NewConfigMapConfigController function but not anywhere else. ]
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.
Okay.
cmd/glbc/main.go
Outdated
go app.RunHTTPServer(ctx.HealthCheck) | ||
|
||
if !flags.F.LeaderElection.LeaderElect { | ||
runControllers(ctx) | ||
return | ||
} | ||
|
||
leaderElectionCtx, leaderElectionCancel := context.WithCancel(context.Background()) | ||
electionConfig, err := makeLeaderElectionConfig(leaderElectKubeClient, ctx.Recorder(flags.F.LeaderElection.LockObjectNamespace), func() { | ||
runControllers(ctx) |
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.
@bowei suggested exiting the program directly. after runController exits. That is more reliable.
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.
yeah, agree.
} | ||
|
||
// LoadValue loads configs from a map, it will ignore any unknow/unvalid field. | ||
func (c *Config) LoadValue(m map[string]string, recordWarning func(msg string)) { |
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.
I think this function may be too complex.
Check out this one, it is very simple and straightforward.
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/legacy-cloud-providers/gce/gce_clusterid.go#L234
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.
agree, the initial idea was keeping this generic.
Updated.
} | ||
|
||
// GetConfig returns the internal Config | ||
func (c *ConfigMapConfigController) GetConfig() Config { |
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.
Okay.
No description provided.