mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Enhance error message for failed controlplane init
Currently if the controlplane fails to init, we print out a message with some example commands that only show docker CLI. This tries to improve that by printing the example commands for docker, cri-o and containerd by checking the socket looking for the default docker socket.
This commit is contained in:
parent
bd77d5f441
commit
c355cadbb1
@ -47,11 +47,18 @@ var (
|
||||
- 'journalctl -xeu kubelet'
|
||||
|
||||
Additionally, a control plane component may have crashed or exited when started by the container runtime.
|
||||
To troubleshoot, list all containers using your preferred container runtimes CLI, e.g. docker.
|
||||
To troubleshoot, list all containers using your preferred container runtimes CLI.
|
||||
{{ if .IsDocker }}
|
||||
Here is one example how you may list all Kubernetes containers running in docker:
|
||||
- 'docker ps -a | grep kube | grep -v pause'
|
||||
Once you have found the failing container, you can inspect its logs with:
|
||||
- 'docker logs CONTAINERID'
|
||||
{{ else }}
|
||||
Here is one example how you may list all Kubernetes containers running in cri-o/containerd using crictl:
|
||||
- 'crictl --runtime-endpoint {{ .Socket }} ps -a | grep kube | grep -v pause'
|
||||
Once you have found the failing container, you can inspect its logs with:
|
||||
- 'crictl --runtime-endpoint {{ .Socket }} logs CONTAINERID'
|
||||
{{ end }}
|
||||
`)))
|
||||
)
|
||||
|
||||
@ -93,10 +100,17 @@ func runWaitControlPlanePhase(c workflow.RunData) error {
|
||||
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)
|
||||
|
||||
if err := waiter.WaitForKubeletAndFunc(waiter.WaitForAPI); err != nil {
|
||||
ctx := map[string]string{
|
||||
"Error": fmt.Sprintf("%v", err),
|
||||
context := struct {
|
||||
Error string
|
||||
Socket string
|
||||
IsDocker bool
|
||||
}{
|
||||
Error: fmt.Sprintf("%v", err),
|
||||
Socket: data.Cfg().NodeRegistration.CRISocket,
|
||||
IsDocker: data.Cfg().NodeRegistration.CRISocket == kubeadmconstants.DefaultDockerCRISocket,
|
||||
}
|
||||
kubeletFailTempl.Execute(data.OutputWriter(), ctx)
|
||||
|
||||
kubeletFailTempl.Execute(data.OutputWriter(), context)
|
||||
return errors.New("couldn't initialize a Kubernetes cluster")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user