Skip to content

Commit

Permalink
kubeadm selfhosting: fix pod spec mutation for controller-manager
Browse files Browse the repository at this point in the history
Modified command line options --authentication-kubeconfig and
--authorization-kubeconfig to point out to the correct location
of the controller-manager.conf

This should fix this controller-manager crash:
    failed to get delegated authentication kubeconfig: failed to get
    delegated authentication kubeconfig: stat
    /etc/kubernetes/controller-manager.conf: no such file or directory

Related issue: kubernetes/kubeadm#1281
  • Loading branch information
bart0sh committed Jan 7, 2019
1 parent fdf3810 commit 8148d95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/kubeadm/app/phases/selfhosting/podspec_mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,14 @@ func setSelfHostedVolumesForControllerManager(podSpec *v1.PodSpec) {
// This is not a problem with hostPath mounts as hostPath supports mounting one file only, instead of always a full directory. Secrets and Projected Volumes
// don't support that.
podSpec.Containers[0].Command = kubeadmutil.ReplaceArgument(podSpec.Containers[0].Command, func(argMap map[string]string) map[string]string {
argMap["kubeconfig"] = filepath.Join(selfHostedKubeConfigDir, kubeadmconstants.ControllerManagerKubeConfigFileName)
controllerManagerKubeConfigPath := filepath.Join(selfHostedKubeConfigDir, kubeadmconstants.ControllerManagerKubeConfigFileName)
argMap["kubeconfig"] = controllerManagerKubeConfigPath
if _, ok := argMap["authentication-kubeconfig"]; ok {
argMap["authentication-kubeconfig"] = controllerManagerKubeConfigPath
}
if _, ok := argMap["authorization-kubeconfig"]; ok {
argMap["authorization-kubeconfig"] = controllerManagerKubeConfigPath
}
return argMap
})
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/kubeadm/app/phases/selfhosting/podspec_mutation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ func TestSetSelfHostedVolumesForControllerManager(t *testing.T) {
},
Command: []string{
"--kubeconfig=/etc/kubernetes/controller-manager.conf",
"--authentication-kubeconfig=/etc/kubernetes/controller-manager.conf",
"--authorization-kubeconfig=/etc/kubernetes/controller-manager.conf",
"--foo=bar",
},
},
Expand Down Expand Up @@ -467,6 +469,8 @@ func TestSetSelfHostedVolumesForControllerManager(t *testing.T) {
},
Command: []string{
"--kubeconfig=/etc/kubernetes/kubeconfig/controller-manager.conf",
"--authentication-kubeconfig=/etc/kubernetes/kubeconfig/controller-manager.conf",
"--authorization-kubeconfig=/etc/kubernetes/kubeconfig/controller-manager.conf",
"--foo=bar",
},
},
Expand Down

0 comments on commit 8148d95

Please sign in to comment.