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

Use Kubernete's own func that creates config by apiserver or kubeconfig #371

Merged
merged 2 commits into from
Mar 8, 2018

Conversation

metalmatze
Copy link
Contributor

@metalmatze metalmatze commented Feb 17, 2018

Instead of implementing this logic ourselves we can simply leverage Kubernet's built-in function, which does exactly what we need.

We want to run kube-state-metrics outside of a cluster and simply give it an apiserver url. Right now this also needs a kubeconfig.


This change is Reviewable

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 17, 2018
@metalmatze
Copy link
Contributor Author

Oh. I didn't see that I need to comment. 😁
CLA is signed.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 21, 2018
@brancz
Copy link
Member

brancz commented Feb 26, 2018

This seems fine to me, I slightly worry about backward compatibility if we remove the --in-cluster flag, but on the other hand I expect this to be a very small amount of users and it's a change that clearly breaks and not in a weird behavior at runtime. I think I'm ok with it, wdyt @andyxning ?

main.go Outdated
}
if options.apiserver != "" {
glog.Infof("apiserver set to: %v", options.apiserver)
if options.apiserver == "" && options.kubeconfig == "" {
Copy link
Member

Choose a reason for hiding this comment

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

These two lines are unnecessary as BuildConfigFromFlags will check and log this.

@andyxning
Copy link
Member

@metalmatze I have added a comment. PTAL.

BTW, as stated by @brancz , This is not a backward compatible change. Especially when in-cluster and kubeconfig or apiserver are both set or default kubeconfig file exists. Because after the change, kube-state-metrics will use kubeconfig config instead of in-cluster config for BuildConfigFromFlags will first use kubeconfig instead of in-cluster.

However, i also think that this should not be a big problem as we have already set in-cluster to true as the default behavior and do not specify in-cluster command line argument in kube-state-metrics deployment. Setting both in-cluster to true and kubeconfig or apiserver or there is an existing default kubeconfig file should be rarely. Overall this lgtm.

We should add a statement in the next release note to make this change widly known.

@metalmatze
Copy link
Contributor Author

I have remove the 3 unnecessary lines.

@metalmatze
Copy link
Contributor Author

/assign @andyxning

@andyxning
Copy link
Member

/lgtm

/cc @brancz

@k8s-ci-robot k8s-ci-robot requested a review from brancz March 8, 2018 02:06
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 8, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andyxning, metalmatze

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 8, 2018
@k8s-ci-robot k8s-ci-robot merged commit 7590d83 into kubernetes:master Mar 8, 2018
jmcarp added a commit to jmcarp/prometheus-boshrelease that referenced this pull request Apr 15, 2018
As of kubernetes/kube-state-metrics#371, the
`--in-cluster` flag is unsupported. Passing this flag now causes
`kube-state-metrics` to error.
while1malloc0 pushed a commit to while1malloc0/kube-state-metrics that referenced this pull request Jul 2, 2018
Use Kubernete's own func that creates config by apiserver or kubeconfig
ehashman added a commit to ehashman/kube-state-metrics that referenced this pull request Sep 28, 2018
ehashman added a commit to ehashman/kube-state-metrics that referenced this pull request Oct 8, 2018
ehashman added a commit to ehashman/kube-state-metrics that referenced this pull request Oct 8, 2018
k8s-ci-robot added a commit that referenced this pull request Oct 9, 2018
Add changelog note for breaking change in #371
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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants