kubectl config view
might not work as is as it redacts certificate data. kubectl config view --flatten
might, but I have never tried that with multiple kubeconfigs.
cc @kubernetes/sig-cli-feature-requests
—
You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
@madhusudancs @superbrothers
KUBECONFIG=~/.kube/config:~/config kubectl config view --flatten
works, but I think adding this kubectl config merge
is also ok, I can implement this since I'm working on another kubectl config
subcommand
cc @kubernetes/sig-cli-feature-requests
@shiywang it is up to SIG-CLI to decide.
@madhusudancs sure, we'll wait for @kubernetes/sig-cli-maintainers to decide.
@shiywang thanks! I've already started to implement it here
/sub
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.
Prevent issues from auto-closing with an /lifecycle frozen
comment.
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
@superbrothers commented on May 25, 2017, 7:27 AM GMT+2:
Can
kubectl config view
meet your requirements?# use multiple kubeconfig files at the same time and view merged config $ KUBECONFIG=~/.kube/config:~/.kube/kubconfig2 kubectl config view
works, except the fact your yaml config starts with ---
👎
KUBECONFIG=~/.kube/config:~/.kube/kubconfig2 kubectl config view --flatten > ~/.kube/config
Does not have a yaml config starting with ---
, however, it still works even when yaml starts with that separator.
KUBECONFIG=
/.kube/config:/.kube/kubconfig2 kubectl config view --flatten > ~/.kube/config
well, that almost worked for me, except that... only partial content was copied ! (writing while reading seemed to have messed up the final output !)
I had better luck with a temporary file :
KUBECONFIG=~/.kube/config:~/.kube/kubconfig2 kubectl config view --flatten > mergedkub && mv mergedkub ~/.kube/config
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
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
There is a problem that KUBECONFIG does not understands special chars like ~ (home dir path) so use full path. for example:
KUBECONFIG=/home/serra/.kube/config:/home/serra/.kube/config.baremetal kubectl config view --flatten > /home/serra/.kube/config
There is a problem that KUBECONFIG does not understands special chars like ~ (home dir path) so use full path. for example:
KUBECONFIG=/home/serra/.kube/config:/home/serra/.kube/config.baremetal kubectl config view --flatten > /home/serra/.kube/config
Most shells expand that for you:
$ more ~/k1
apiVersion: v1
clusters:
- cluster:
server: https://1.1.1.1
name: cluster1
contexts:
- context:
cluster: cluster1
user: user1
name: context1
current-context: context1
kind: Config
preferences: {}
users:
- name: user1
$ more ~/k2
apiVersion: v1
clusters:
- cluster:
server: https://2.2.2.2
name: cluster2
contexts:
- context:
cluster: cluster2
user: user2
name: context2
current-context: context2
kind: Config
preferences: {}
users:
- name: user2
$ KUBECONFIG=~/k1:~/k2 kubectl config view
apiVersion: v1
clusters:
- cluster:
server: https://1.1.1.1
name: cluster1
- cluster:
server: https://2.2.2.2
name: cluster2
contexts:
- context:
cluster: cluster1
user: user1
name: context1
- context:
cluster: cluster2
user: user2
name: context2
current-context: context1
kind: Config
preferences: {}
users:
- name: user1
user: {}
- name: user2
user: {}
My little bash script based on #46381 (comment)
# ~/.bashrc function kmerge() { KUBECONFIG=~/.kube/config:$1 kubectl config view --flatten > ~/.kube/mergedkub && mv ~/.kube/mergedkub ~/.kube/config }
kubectl config merge
would be easier to remember. First class support would be nice even though the workaround is clever
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
—
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
This does not seem to work if you have the same user but different token for the user for different clusters. The kubectl config view --flatten
will only keep the user and token for the first one it encounters, which defeats the purpose of trying to merge it in the first place.
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
Closed #46381.
@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.
Can this be re-opened? The workaround is nice, but a built-in supported command would be way better.
—
You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
/reopen
@0xErnie: You can't reopen an issue/PR unless you authored it or you are a collaborator.
In response to this:
/reopen
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.
—
Running into the same issue as above: The kubectl config view --flatten will only keep the user and token for the first one it encounters, which defeats the purpose of trying to merge it in the first place.
This is really annoying since its best practice to use unique tokens, but this command is truncating them when trying to merge multiple accounts/contexts into one file.
The kubectl config view --flatten will only keep the user and token for the first one it encounters, which defeats the purpose of trying to merge it in the first place.
It keeps all uniquely named users/clusters. If you have user stanzas with the same name, keeping all of them would make the resulting file ambiguous.
So how can you merge multiple files that have the same username but different tokens?
So how can you merge multiple files that have the same username but different tokens?
you cannot; those are effectively the same user stanza, and can only have a single bearer token
So if you run multiple clusters you should use a different/unique username on each? Very unintuitive.
If you want to merge them into a single kubeconfig, yes
as a note for others who are looking for an option to do this, there is now a tool to achieve this, also available as a krew plugin https://github.com/corneliusweig/konfig