Skip to content

Talos: Unable to connect to the server: EOF – find the API server

Talostested on Talos Linux v1.14.6, Kubernetes v1.37.2

If the API server fails, Talos still has the Talos API: containers, logs, get and patch keep working. Instead of SSH and crictl you ask the node with talosctl which static pod isn't ready and why.

Symptom

kubectl get nodes 2>&1 | cut -c1-88
Unable to connect to the server: EOF

Depending on timing you may also see "connection reset by peer" or "connection refused". kubectl can't help any more – Talos can.

Diagnosis

Status of the static pods, then the last log line of the API server container and its rendered manifest.

talosctl -n 10.5.0.2 get staticpodstatus | awk '{print $4, $6}'
ID=$(talosctl -n 10.5.0.2 containers --namespace cri \
  | grep -o 'kube-apiserver-talos-controlplane-1:kube-apiserver:[0-9a-f]*' | tail -1)
talosctl -n 10.5.0.2 logs --namespace cri kube-system/$ID --tail 1 \
  | grep -o '"command failed".*'
talosctl -n 10.5.0.2 get staticpods kube-apiserver -o yaml | grep feature-gates
ID READY
kube-system/kube-apiserver-talos-controlplane-1 False
kube-system/kube-controller-manager-talos-controlplane-1 False
kube-system/kube-scheduler-talos-controlplane-1 False
"command failed" err="unrecognized feature gate: DebugBuchGate"
                - --feature-gates=DebugBuchGate=true

Causes

KubeAPIServerConfigA flag kube-apiserver doesn't know

In the course an unknown feature gate via extraArgs. Talos re-renders the static pod from the machine config; the container dies immediately and the kubelet restarts it with backoff.

cat > apiserver-kaputt.yaml <<'EOF'
apiVersion: v1alpha1
kind: KubeAPIServerConfig
extraArgs:
  feature-gates: DebugBuchGate=true
EOF

Knock-on effectController manager and scheduler not ready

Both depend on the API server and are therefore False as well. The cause is in the API server.

Fix

Remove the entry with a patch using $patch: delete and wait until /readyz answers. Only when all three static pods are ready does the controller manager work again.
cat > apiserver-fix.yaml <<'EOF'
apiVersion: v1alpha1
kind: KubeAPIServerConfig
extraArgs:
  feature-gates:
    $patch: delete
EOF
T0=$(date +%s)
talosctl -n 10.5.0.2 patch mc --patch @apiserver-fix.yaml
until kubectl get --raw /readyz >/dev/null 2>&1; do sleep 2; done
echo "nach $(( $(date +%s) - T0 )) s"
patched MachineConfigs.config.talos.dev/v1alpha1 at the node 10.5.0.2
Applied configuration without a reboot
nach 42 s
▶
Break it yourself and find it – free
Debugging Kubernetes, day 19: the same faults on Talos – kubelet, API server, Pod Security, mirror, NetworkPolicy and metrics-server, investigated with talosctl.
Go to day 19 →

FAQ

What should I do before a patch like this?

Take an etcd snapshot with talosctl etcd snapshot. talosctl patch also has --mode try: the change only applies for --timeout (one minute by default) and is rolled back unless you confirm it.

Related error patterns

More