javascript icon indicating copy to clipboard operation
javascript copied to clipboard

Anything similar to Golang clientcmd ModifyConfig?

Open ZedYeung opened this issue 6 years ago • 9 comments
trafficstars

It looks like currently, we could only read the config file, is there any method like Golang clientcmd ModifyConfig so that we could modify the config file?

ZedYeung avatar Sep 13 '19 06:09 ZedYeung

Not currently. Can you describe your use case in more detail? Do you want to modify and then save to file a kubeconfig?

brendandburns avatar Sep 13 '19 22:09 brendandburns

yes, ideally, i hope it could be same as Golang clientcmd ModifyConfig.

On Fri, Sep 13, 2019, 3:59 PM Brendan Burns [email protected] wrote:

Not currently. Can you describe your use case in more detail? Do you want to modify and then save to file a kubeconfig?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kubernetes-client/javascript/issues/340?email_source=notifications&email_token=ADEI5D6R4JBFOQEAAJUHFATQJQLOZA5CNFSM4IWMVKXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6WMI3Q#issuecomment-531416174, or mute the thread https://github.com/notifications/unsubscribe-auth/ADEI5DZCCMQY7ZP2TD2EDGTQJQLOZANCNFSM4IWMVKXA .

ZedYeung avatar Sep 14 '19 01:09 ZedYeung

For future reference, code is here: https://github.com/kubernetes/client-go/blob/master/tools/clientcmd/config.go#L158

Hrm. Why not just modify the config object in Javascript and then export to YAML?

That function seems super twisty and it's not exactly clear to me why its useful.

Can you describe your use case in more detail?

Thanks

brendandburns avatar Sep 14 '19 22:09 brendandburns

That is exactly what it did. It is very true that function is super twisty with some rules. I just want to keep consistent with that official rule to modify the config file, in case some specific rule would be broken. But looks like that is not easy. What I do now is just modifying only one file in the order env KUBECONFIG and then ~/.kube/config. Hope that is good.

ZedYeung avatar Sep 14 '19 23:09 ZedYeung

That seems reasonable for now. I'll leave this issue open, but I don't expect we'll implement this in the near term.

brendandburns avatar Sep 16 '19 15:09 brendandburns

If I really understand how tokens refreshing is implemented, new fetched tokens (at least for oidc) are not stored in ~/.kube/config, that means, if a refresh occurs, ~/.kube/config becomes obsolete. Also if other clients are to be run after, they will get old and unusable tokens from ~/.kube/config. The current refreshing process is only useful for a single long-running client ? I see that you've started working on configuration exporting (https://github.com/kubernetes-client/javascript/pull/372) Will tokens persistence be implemented soon ? Meanwhile, should it be done by the app using the client ? Thanks

machine424 avatar Nov 25 '19 10:11 machine424

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Feb 24 '20 09:02 fejta-bot

Token persistence is tricky, because it is potentially racy between multiple different clients running on the same machine.

I'd prefer that people handle it themselves in their application code rather than this library accidentally corrupting someone's kubeconfig.

brendandburns avatar Feb 26 '20 22:02 brendandburns

/lifecycle frozen

brendandburns avatar Feb 26 '20 22:02 brendandburns