Skip to content
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

Merged
merged 1 commit into from
May 19, 2017

Conversation

ncdc
Copy link
Member

@ncdc ncdc commented May 16, 2017

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 to NewProxyServer(), or I have to make NewProxyServer() a member of the Options struct. If the former, then I probably need to export Options.scheme. Thoughts?

cc @mikedanese @sttts @liggitt @deads2k @smarterclayton @timothysc @kubernetes/sig-network-pr-reviews @kubernetes/sig-api-machinery-pr-reviews

Add --write-config-to flag to kube-proxy to allow users to write the default configuration settings to a file.

@k8s-ci-robot k8s-ci-robot added sig/network Categorizes an issue or PR as relevant to SIG Network. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 16, 2017
@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels May 16, 2017
@timothysc timothysc added this to the v1.7 milestone May 16, 2017
@@ -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
Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Member Author

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
Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

registry = registered.NewOrDie("")
)

o.scheme = runtime.NewScheme()
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

@ncdc
Copy link
Member Author

ncdc commented May 17, 2017

Updated based on first round of code review

@ncdc
Copy link
Member Author

ncdc commented May 17, 2017

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@ncdc ncdc force-pushed the kube-proxy-write-config branch from 6242f21 to 5cccd64 Compare May 17, 2017 18:50
@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 18, 2017
healthzPort: 10256,
opts, err := NewOptions()
if err != nil {
glog.Fatalf("unable to initialize command options: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Unable

@sttts
Copy link
Contributor

sttts commented May 18, 2017

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.
@ncdc ncdc force-pushed the kube-proxy-write-config branch from 5cccd64 to 032e2f6 Compare May 18, 2017 14:35
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 18, 2017
@ncdc
Copy link
Member Author

ncdc commented May 18, 2017

@sttts updated

@sttts
Copy link
Contributor

sttts commented May 18, 2017

lgtm

@ncdc
Copy link
Member Author

ncdc commented May 18, 2017

@mikedanese @deads2k @liggitt want to review?

@deads2k
Copy link
Contributor

deads2k commented May 18, 2017

/approve

@mikedanese
Copy link
Member

Scanned it and looks good. I'm happy if sttts is happy.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 18, 2017
@k8s-github-robot
Copy link

[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 /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 18, 2017
@k8s-github-robot k8s-github-robot added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label May 18, 2017
@sttts
Copy link
Contributor

sttts commented May 19, 2017

@ncdc worth a short release note?

@ncdc ncdc changed the title kube-proxy: add --write-config flag kube-proxy: add --write-config-to flag May 19, 2017
@k8s-github-robot k8s-github-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels May 19, 2017
@ncdc ncdc removed the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label May 19, 2017
@ncdc
Copy link
Member Author

ncdc commented May 19, 2017

@sttts added it at the top, ptal

@sttts
Copy link
Contributor

sttts commented May 19, 2017

lgtm

@ncdc
Copy link
Member Author

ncdc commented May 19, 2017

@k8s-bot kops aws e2e test this
@k8s-bot pull-kubernetes-federation-e2e-gce test this

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 9a5694b into kubernetes:master May 19, 2017
}

// 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.")
Copy link
Member

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thockin what configmap?

@thockin
Copy link
Member

thockin commented May 24, 2017 via email

@ncdc
Copy link
Member Author

ncdc commented May 24, 2017

@thockin it currently writes default values as that's all we have to work with.

@ncdc ncdc deleted the kube-proxy-write-config branch October 22, 2018 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/network Categorizes an issue or PR as relevant to SIG Network. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants