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

Ability to configure user and cluster name in AdminKubeConfigFile #416

Closed
shashidharatd opened this issue Sep 1, 2017 · 21 comments
Closed
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Milestone

Comments

@shashidharatd
Copy link

When we bring up k8s cluster using kubeadm, the cluster is configured with default cluster-name of kubernetes and user name kubernetes-admin in admin.conf kubeconfig file.
When user wants to deploy multiple clusters and manage them from same kubeconfig file by merging the kubeconfigs of multiple deployments, there will be duplicate user-names but different users, which makes it difficult to merge the kubeconfigs.
So we need the ability in kubeadm to customize the cluster and user-names written to admin.conf

/cc @pipejakob @luxas

@shashidharatd
Copy link
Author

/cc @fisherxu

@fisherxu
Copy link
Contributor

@shashidharatd Have send a pr :)

@fisherxu
Copy link
Contributor

Hi, @pipejakob @luxas, As said in this issue, I think we should make cluster-name and user-name configurable in kubeadm , and can you give some suggestions about this? Thanks :)

@fabriziopandini
Copy link
Member

My comments on #52470

@fejta-bot
Copy link

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

@k8s-ci-robot k8s-ci-robot added lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 7, 2018
@timothysc timothysc self-assigned this Jan 31, 2018
@timothysc
Copy link
Member

kubernetes/kubernetes#55901 addresses.

@timothysc timothysc added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. kind/feature Categorizes issue or PR as related to a new feature. and removed triaged labels Apr 7, 2018
@timothysc timothysc added this to the v1.11 milestone Apr 7, 2018
@ps-aux
Copy link

ps-aux commented Apr 9, 2018

@timothysc could you please exlain how kubernetes/kubernetes#55901 addresses custom username/cluster name config ?

@timothysc
Copy link
Member

@ps-aux Sorry wrong link.
kubernetes/kubernetes#60852 addresses clustername, and has been merged.

kubernetes/kubernetes#52470 - addressed both, but I'm not sold on kubeadm touching multi-user space. IMO this is policy and can/should be done separately.

As a result, I'm closing this issue.

If folks have a compelling argument on user override that requires putting it into kubeadm, please open a new issue that is scoped to just that problem.

@sekrett
Copy link

sekrett commented Jul 20, 2018

Is there any option for kubeadm init for specifying cluster name? I did not find it. I created a config file but it is experimental. Such an important thing should be easy to configure.

@neolit123
Copy link
Member

@sekrett
on this page search for the config field: clusterName. it can be set in the config.

@sekrett
Copy link

sekrett commented Jul 24, 2018

As I said before I created a config file and it works. I don't like the fact it's apiVersion is alpha.

@neolit123
Copy link
Member

this is how k8s features work, alpha -> beta -> GA.
https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/#using-a-feature

there is a command called kubeadm config migrate that will help you to update your config from the alpha version to beta, once the beta version is released.

@sekrett
Copy link

sekrett commented Jul 24, 2018

@neolit123 Nice information, thanks. That page says that using an alpha version may be buggy and should not be used in long living clusters, that's the thing I am concerned about. I dumped a config file with kubeadm config print-default and it is pretty long. Maybe I should minimise it so that it contains only clusterName and hope it will not lead to bugs?

@neolit123
Copy link
Member

@sekrett

Nice information, thanks. That page says that using an alpha version may be buggy and should not be used in long living clusters, that's the thing I am concerned about.

moving the config away from alpha is a slow process. we expect the config to be beta in 1.12.

I dumped a config file with kubeadm config print-default and it is pretty long. Maybe I should minimise it so that it contains only clusterName and hope it will not lead to bugs?

you can extract only the parts that you need from print-default.

@sekrett
Copy link

sekrett commented Jul 24, 2018

Got it, thanks!

@caboteria
Copy link

Hi! I just bumped into this issue when I tried to do the same thing as OP, i.e., build two clusters with kubeadm then configure kubectl to control both of them. When you provide both config files to kubectl (for example, by putting both in $KUBECONFIG) it can distinguish between both clusters because they can have different names, but because both admin users have the same name kubectl picks only one and uses that so it can access only one of the two clusters.

It would be very useful to be able to specify the admin user name when the cluster is built since then kubectl could control multiple kubeadm-created clusters.

@timothysc could you please elaborate on your comment "I'm not sold on kubeadm touching multi-user space. IMO this is policy and can/should be done separately."? How can I do this separately? It seems like I get a user named kubernetes-admin with no way to change that, which feels like a policy decision to me.

I'd be willing to look at making a new PR with just the user name part of kubernetes/kubernetes#52470 but don't want to waste my time if it will get shot down.

Thanks!

@neolit123
Copy link
Member

@caboteria

hi, in kubeadm 1.20 (to be released) we extended the command kubeadm alpha kubeconfig to accept the ClusterConfiguration object:
https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2

this allows you to generate kubeconfig files for different clusters / users / orgs.

we cannot backport this extension to older releases, but technically you could use the 1.20 binary to generate kubeconfig for older clusters.

@caboteria
Copy link

hi @neolit123 , thanks for the info! That looks like an improvement but I don't see anything about setting the admin user name. I'm still learning my way around k8s, am I missing something? It looks like I'll still be unable to init a cluster with an admin user named anything but kubernetes-admin.

Thanks again!

@neolit123
Copy link
Member

neolit123 commented Oct 31, 2020

the new command allows --client-name:
https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/cmd/alpha/kubeconfig.go#L97

so you could do this command kubeadm alpha kubeconfig user --client-name=some-admin --org=system:masters --config=some-file-with-ClusterConfiguration

ClusterConfiguration can be used for the:

  • controlPlaneEndpoint - apiserver address in the kubeconfig
  • clusterName - name of the cluster

@caboteria
Copy link

Thank you @neolit123, that works!

Back to #416 (comment) :

I'd be willing to look at making a new PR with just the user name part of kubernetes/kubernetes#52470 but don't want to waste my time if it will get shot down.

I think it would be a better user experience to specify the default admin user name (like we can specify the cluster name) instead of having to create a second user.

Another potential approach would be to have the default admin name be based on the cluster name, e.g., clusterName+"-admin". Then if the client changed the cluster name the admin name would track that change. WDYT?

@neolit123
Copy link
Member

this idea was rejected before, but if you feel strongly about it, please log a new issue with a detailed description and link to this old ticket. it can be discussed for v1beta3. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
10 participants