-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: hot reload kubeconfig #2144
feat: hot reload kubeconfig #2144
Conversation
Welcome @opeco17! |
b6dafdd
to
4cd1901
Compare
kubeconfig := os.Getenv("KUBECONFIG") | ||
if kubeconfig == "" { | ||
// Assume $HOME is always defined. | ||
kubeconfig = os.Getenv("HOME") + "/.kube/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.
Will this alter a user's config file?
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.
Yes, kubeconfig will be altered temporary by the following line
err = exec.Command("kubectl", "config", "set-cluster", "ksm-hot-reload-kubeconfig-test").Run()
When the test is finished, kubeconfig will be reverted
err := exec.Command("kubectl", "config", "delete-cluster", "ksm-hot-reload-kubeconfig-test").Run()
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.
Maybe we could create a temporary copy of the kubeconfig that is passed just to be extra safe and still have access to the local cluster?
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.
Sounds good
I've implemented that feature (https://github.com/kubernetes/kube-state-metrics/pull/2144/files#diff-c529068bd1416eaf280644910132aa60a6736c14af241a6c9b118f19fe228c81R41-R62)
Could you please review it again?
/triage accepted |
Pending https://github.com/kubernetes/kube-state-metrics/pull/2144/files#r1307670306, the PR looks good to me. Do you think you'll be able to address it by Wednesday? |
4cd1901
to
a0fd543
Compare
a0fd543
to
7bf825d
Compare
/lgtm /hold |
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.
/lgtm
/approve
/unhold
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dgrisonnet, mrueg, opeco17 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 |
What this PR does / why we need it:
This PR enables Kube State Metrics to hot reload kubeconfig automatically when it's changed. This feature is useful because kubeconfig should be short-lived and updated frequently.
How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)
No change
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #2120