-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
kube-proxy: add --write-config-to flag #45908
kube-proxy: add --write-config-to flag #45908
Conversation
cmd/kube-proxy/app/server.go
Outdated
@@ -88,7 +95,8 @@ func checkKnownProxyMode(proxyMode string) bool { | |||
// Options contains everything necessary to create and run a proxy server. | |||
type Options struct { | |||
// ConfigFile is the location of the proxy server's configuration file. | |||
ConfigFile string | |||
ConfigFile string | |||
WriteConfig 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.
godoc please. Is it a path name? Then configWritePath would be self-explaining.
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 is currently a path name. I debated having --write-config
be a bool
, which would mean you'd do --config=foo.yaml --write-config
, but that's not what we did in OpenShift, so I went this route instead. What do you think makes the most sense?
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.
--write-config-to
or --write-config-path
would show that it is not a bool.
Actually, I was talking more about the Go field name in my comment above.
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.
Sure, I can change the variable name and doc it.
@@ -104,11 +112,15 @@ type Options struct { | |||
master string | |||
// healthzPort is the port to be used by the healthz server. | |||
healthzPort int32 | |||
|
|||
scheme *runtime.Scheme |
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.
Having this in the Options is strange. If it is just for writing, can't be create them locally in the write func?
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 wanted to share the scheme with the applyDefaults
function, and hopefully also where we set up the event recorder (since it needs a scheme). Is there a better way?
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's the only state we have, right? (next to globals) It looks strange in my eyes to have that in options. But I can live with it I guess.
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 could make it a package-level global but was trying to avoid that. The other thing I'll say is that Options
is really just a struct that holds state/context for running this command, so something like CommandContext
might be a more appropriate name.
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, context sounds much better.
cmd/kube-proxy/app/server.go
Outdated
registry = registered.NewOrDie("") | ||
) | ||
|
||
o.scheme = runtime.NewScheme() |
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 move these 3 lines into the two funcs, simple enough IMO.
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.
And we don't need the registry here. Just call componentconfig.AddToScheme and componentconfigv1alpha1.AddToScheme.
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.
@ncdc what about the second comment above? We are trying to remove the registry from many places, e.g. from the clients. We shouldn't rely on the static information it provides, but use discovery in kubectl/proxy/client-go instead. Here it's only about encoding, we do not even need discovery.
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.
@sttts to be honest, I'm still learning the ins and outs of API registration, schemes, etc, so whatever you all say is the right way to do this, I'm happy to do that. So if we don't want or need a registry, I'll get rid of 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.
once people have learned it, we change it again :-) So don't worry.
Updated based on first round of code review |
@k8s-bot pull-kubernetes-federation-e2e-gce test this |
6242f21
to
5cccd64
Compare
cmd/kube-proxy/app/server.go
Outdated
healthzPort: 10256, | ||
opts, err := NewOptions() | ||
if err != nil { | ||
glog.Fatalf("unable to initialize command options: %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.
nit: Unable
Only one nit and the Options->CommandContext (can also live with Options, just cosmetics). Otherwise, lgtm. |
Add --write-config flag to kube-proxy to write the default configuration values to the specified file location.
5cccd64
to
032e2f6
Compare
@sttts updated |
lgtm |
@mikedanese @deads2k @liggitt want to review? |
/approve |
Scanned it and looks good. I'm happy if sttts is happy. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, mikedanese, ncdc
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
@ncdc worth a short release note? |
@sttts added it at the top, ptal |
lgtm |
Automatic merge from submit-queue |
} | ||
|
||
// AddFlags adds flags to fs and binds them to options. | ||
func AddFlags(options *Options, fs *pflag.FlagSet) { | ||
fs.StringVar(&options.ConfigFile, "config", options.ConfigFile, "The path to the configuration file.") | ||
fs.StringVar(&options.WriteConfigTo, "write-config-to", options.WriteConfigTo, "If set, write the default configuration values to this file and exit.") |
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.
Does this always write DEFAULT values or effective values after parsing config (e.g. configmap)
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.
@thockin what configmap?
Hypothetical :)
…On Tue, May 23, 2017 at 5:31 AM, Andy Goldstein ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In cmd/kube-proxy/app/server.go
<#45908 (comment)>
:
> }
// AddFlags adds flags to fs and binds them to options.
func AddFlags(options *Options, fs *pflag.FlagSet) {
fs.StringVar(&options.ConfigFile, "config", options.ConfigFile, "The path to the configuration file.")
+ fs.StringVar(&options.WriteConfigTo, "write-config-to", options.WriteConfigTo, "If set, write the default configuration values to this file and exit.")
@thockin <https://github.com/thockin> what configmap?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#45908 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFVgVGalXEnntpT9QZqEu9pT94Pjphc5ks5r8tGpgaJpZM4NdDLX>
.
|
@thockin it currently writes default values as that's all we have to work with. |
Add --write-config-to flag to kube-proxy to write the default configuration
values to the specified file location.
@deads2k suggested I create my own scheme for this, so I followed the example he shared with me. The only bit currently still referring to
api.Scheme
is where we create the event broadcaster recorder. In order to use the custom private scheme, I either have to pass it in toNewProxyServer()
, or I have to makeNewProxyServer()
a member of theOptions
struct. If the former, then I probably need to exportOptions.scheme
. Thoughts?cc @mikedanese @sttts @liggitt @deads2k @smarterclayton @timothysc @kubernetes/sig-network-pr-reviews @kubernetes/sig-api-machinery-pr-reviews