Kubernetes cluster name change
Asked Answered
H

2

7

I'm creating a cluster with kubeadm init --with-stuff (Kubernetes 1.8.4, for reasons). I can setup nodes, weave, etc. But I have a problem setting the cluster name. When I open the admin.conf or a different config file I see:

name: kubernetes

When I run kubectl config get-clusters:

NAME
kubernetes

Which is the default. Is there a way to set the cluster name during init (there is no command line parameter)? Or is there a way to change this after the init? The current name is referenced in many files in /etc/kubernetes/

Best Regrads
Kamil

Holcman answered 14/3, 2018 at 11:27 Comment(0)
O
5

You can now do so using kubeadm's config file. PR here:

https://github.com/kubernetes/kubernetes/pull/60852

Using the kubeadm config you just set the following at the top level

clusterName: kubernetes
Ouphe answered 16/11, 2018 at 18:33 Comment(0)
N
3

No, you cannot change a name of running cluster, because it serves for discovery inside a cluster and this would require near-simultaneous changing it across the cluster.

Sadly, you also cannot change a name of the cluster before init. Here is the issue on Github.

Update: From version 1.12, kubeadm allow you to change a cluster name before an "init" stage.

To do it (for sure for versions >=1.15, for lower versions commands can be different, commands changed somewhen between versions 1.12 and 1.15), you need to set clusterName value in a cluster configuration file like that:

  1. Save default configuration to a file (cluster config is optional, so we need to do that step first for not to write it from scratch) by a kubeadm config print init-defaults < init-config.yaml command.
  2. Set clusterName value in the config.
  3. Run kubeadm init with a config argument: kubeadm init --config init-config.yaml
Nubbly answered 14/3, 2018 at 13:9 Comment(1)
That's a bit of a disaster if you want to change the name of a running cluster then!Brenza

© 2022 - 2024 — McMap. All rights reserved.