kubeadm: set cluster name on the controller manager

On kubeadm's configuration it's possible to set up the cluster
name. Forward this information to the controller manager's
`--cluster-name` argument.
This commit is contained in:
Rafael Fernández López 2019-12-02 18:32:50 +01:00
parent f6337c7624
commit f0ea7bcf9e
No known key found for this signature in database
GPG Key ID: 8902294E78418CF9
2 changed files with 30 additions and 0 deletions

View File

@ -324,6 +324,11 @@ func getControllerManagerCommand(cfg *kubeadmapi.ClusterConfiguration) []string
}
}
// Set cluster name
if cfg.ClusterName != "" {
defaultArguments["cluster-name"] = cfg.ClusterName
}
// TODO: The following code should be remvoved after dual-stack is GA.
// Note: The user still retains the ability to explicitly set feature-gates and that value will overwrite this base value.
enabled, present := cfg.FeatureGates[features.IPv6DualStack]

View File

@ -579,6 +579,31 @@ func TestGetControllerManagerCommand(t *testing.T) {
cfg *kubeadmapi.ClusterConfiguration
expected []string
}{
{
name: "custom cluster name for " + cpVersion,
cfg: &kubeadmapi.ClusterConfiguration{
KubernetesVersion: cpVersion,
CertificatesDir: testCertsDir,
ClusterName: "some-other-cluster-name",
},
expected: []string{
"kube-controller-manager",
"--bind-address=127.0.0.1",
"--leader-elect=true",
"--kubeconfig=" + kubeadmconstants.KubernetesDir + "/controller-manager.conf",
"--root-ca-file=" + testCertsDir + "/ca.crt",
"--service-account-private-key-file=" + testCertsDir + "/sa.key",
"--cluster-signing-cert-file=" + testCertsDir + "/ca.crt",
"--cluster-signing-key-file=" + testCertsDir + "/ca.key",
"--use-service-account-credentials=true",
"--controllers=*,bootstrapsigner,tokencleaner",
"--authentication-kubeconfig=" + kubeadmconstants.KubernetesDir + "/controller-manager.conf",
"--authorization-kubeconfig=" + kubeadmconstants.KubernetesDir + "/controller-manager.conf",
"--client-ca-file=" + testCertsDir + "/ca.crt",
"--requestheader-client-ca-file=" + testCertsDir + "/front-proxy-ca.crt",
"--cluster-name=some-other-cluster-name",
},
},
{
name: "custom certs dir for " + cpVersion,
cfg: &kubeadmapi.ClusterConfiguration{