Without setting environment variable KUBECONFIG,
kops export kubecfg does not allow to export to a different file than ~/.kube/config
Please add a parameter --kubeconfig to set the location of the kubeconfig file to create.
--kubeconfig should take priority over the environment variable KUBECONFIG if both are set.
And if none are set, the default location should be ~/.kube/config.
$ kops export kubecfg --name k8s.test.eu-west-1.aws.redacted.net --state s3://k8s/kops/ --kubeconfig $HOME/test-kubeconfig.yaml
# ---> creates a file kubeconfig at the location $HOME/test-kubeconfig.yaml
When setting the environment variable KUBECONFIG, it is possible to set the location of the config file to be created.
$ export KUBECONFIG=$HOME/test-kubeconfig.yaml
$ kops export kubecfg --name k8s.test.eu-west-1.aws.redacted.net --state s3://k8s/kops/
$ cat $HOME/test-kubeconfig.yaml
apiVersion: v1
clusters:
- cluster:
...
Related to https://github.com/kubernetes/kops/issues/165 and https://github.com/kubernetes/kops/issues/1676
As far as I understand this is as designed and models kubectl. Would more documentation help, or do we have a flag that is not working??
Oh ... --config is actually not for kubeconfig. It is for the viper config file config... we need to fix the help section on that. The viper config is part of the cli tooling that we use. Think if it as a kops base config file. I actually never have used it. Not sure how and if it works ;). I am sure it does, but you should be able to set stuff like state store location. Not certain.
@chrislovecnm Thanks!
kubectl has the parameters --kubeconfig to indicate where to find the kubeconfig file.
More documentation about the kops export --config parameter would be good, yes! (there is a ticket for that here).
Is there a param to set the location of the kubeconfig file then?
If not, this ticket is a request to add one.
Nope no --kubeconfig flag here https://github.com/kubernetes/kops/blob/master/cmd/kops/export_kubecfg.go
Great idea... I am going to update the title of the issue if you do not mind. This is a great starter level issue for someone to address!
Please edit the title if I am not understanding the feature request clearly.
@chrislovecnm that's great thanks! I also updated the description
if no one is working on it yet, can i take this. as a first time contributor, it really do look like 'good-starter-issue'
We can use one liner like this
KUBECONFIG=$HOME/test-kubeconfig.yaml kops export kubecfg --name k8s.test.eu-west-1.aws.redacted.net --state s3://k8s/kops/
Is is take ? @rajatchopra do you handle this?
Not sure if this is fixed already. Proposed a fix in #4746
PTAL. Thanks.
Surprisingly not fixed yet (nor the documentation about --config).
Still have to use the export KUBECONFIG workaround. Pretty bad when you need to share a kubeconfig with someone.
Is this a good place for a bad programmer with the go book to start?
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
/remove-lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
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 rotten
So we have a PR for this now - #5955. I guess I'm wondering why we don't just use the KUBECONFIG env var?
We use kubeconfig in a few places:
I think we'd have to add the kubeconfig flag essentially to all our commands.
Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
@fejta-bot: Closing this issue.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue with/reopen.
Mark the issue as fresh with/remove-lifecycle rotten.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close
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.
Most helpful comment
Surprisingly not fixed yet (nor the documentation about --config).
Still have to use the
export KUBECONFIGworkaround. Pretty bad when you need to share a kubeconfig with someone.