Skip to content

Commit c8b123e

Browse files
authored
Merge pull request kubernetes#85843 from Itxaka/kubeadm_docker_messages
Enhance error message for failed controlplane init
2 parents 6d5eee8 + c355cad commit c8b123e

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

cmd/kubeadm/app/cmd/phases/init/waitcontrolplane.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,18 @@ var (
4747
- 'journalctl -xeu kubelet'
4848
4949
Additionally, a control plane component may have crashed or exited when started by the container runtime.
50-
To troubleshoot, list all containers using your preferred container runtimes CLI, e.g. docker.
50+
To troubleshoot, list all containers using your preferred container runtimes CLI.
51+
{{ if .IsDocker }}
5152
Here is one example how you may list all Kubernetes containers running in docker:
5253
- 'docker ps -a | grep kube | grep -v pause'
5354
Once you have found the failing container, you can inspect its logs with:
5455
- 'docker logs CONTAINERID'
56+
{{ else }}
57+
Here is one example how you may list all Kubernetes containers running in cri-o/containerd using crictl:
58+
- 'crictl --runtime-endpoint {{ .Socket }} ps -a | grep kube | grep -v pause'
59+
Once you have found the failing container, you can inspect its logs with:
60+
- 'crictl --runtime-endpoint {{ .Socket }} logs CONTAINERID'
61+
{{ end }}
5562
`)))
5663
)
5764

@@ -93,10 +100,17 @@ func runWaitControlPlanePhase(c workflow.RunData) error {
93100
fmt.Printf("[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory %q. This can take up to %v\n", data.ManifestDir(), timeout)
94101

95102
if err := waiter.WaitForKubeletAndFunc(waiter.WaitForAPI); err != nil {
96-
ctx := map[string]string{
97-
"Error": fmt.Sprintf("%v", err),
103+
context := struct {
104+
Error string
105+
Socket string
106+
IsDocker bool
107+
}{
108+
Error: fmt.Sprintf("%v", err),
109+
Socket: data.Cfg().NodeRegistration.CRISocket,
110+
IsDocker: data.Cfg().NodeRegistration.CRISocket == kubeadmconstants.DefaultDockerCRISocket,
98111
}
99-
kubeletFailTempl.Execute(data.OutputWriter(), ctx)
112+
113+
kubeletFailTempl.Execute(data.OutputWriter(), context)
100114
return errors.New("couldn't initialize a Kubernetes cluster")
101115
}
102116

0 commit comments

Comments
 (0)