Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Hoofdstuk 12Naam in de cursus: Troubleshooting

Troubleshoot pods, nodes, the control plane and the network

Troubleshooting is 30 % of the CKA — the biggest domain. Use the same order every time: what is the status, what do the events say, what do the logs say, and only then change something.

  • 5 Lessen
  • 12 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

Vaardigheden in dit hoofdstuk

  • Clusters, nodes, componenten, services en netwerken debuggen

12.1

Debug a pod

The pod status tells you where to look.

StatusUsual causeLook at
PendingNo node fits (resources, taints, affinity), PVC not bounddescribe pod events
ImagePullBackOff / ErrImagePullWrong image name/tag, private registry without secretdescribe pod events
CrashLoopBackOffThe app exits: bad config, missing env, wrong commandlogs --previous
CreateContainerConfigErrorMissing ConfigMap or Secretdescribe pod
Running but not ReadyReadiness probe failsdescribe pod, app logs
OOMKilledMemory limit too lowdescribe pod (Last State)
kubectl get pods -n shop -o wide
kubectl describe pod web-7d9f -n shop
kubectl logs web-7d9f -n shop
kubectl logs web-7d9f -n shop --previous
kubectl logs web-7d9f -n shop -c sidecar
kubectl get events -n shop --sort-by=.lastTimestamp
kubectl exec -it web-7d9f -n shop -- sh
kubectl debug -it web-7d9f -n shop --image=busybox:1.36 --target=nginx

12.2

Debug a node

A NotReady node usually has a stopped or broken kubelet or container runtime.

kubectl get nodes
kubectl describe node worker1 | grep -A8 Conditions
ssh worker1
systemctl status kubelet
journalctl -u kubelet -n 50 --no-pager
systemctl status containerd
crictl ps -a
crictl logs CONTAINER_ID
df -h ; free -m
systemctl enable --now kubelet
Symptom in the kubelet logFix
failed to load kubelet config fileWrong path or typo in /var/lib/kubelet/config.yaml
unable to connect to the runtimeStart containerd; check the socket path
Certificate errorsWrong CA or expired certs (kubeadm certs check-expiration)
Disk or memory pressureClean up space; check Conditions

12.3

Debug the control plane

The control-plane parts are static pods. When the API server is down, kubectl does not work — use crictl and the log files.

kubectl get pods -n kube-system
crictl ps -a | grep -E 'apiserver|etcd|scheduler|controller'
crictl logs $(crictl ps -a --name kube-apiserver -q | head -1)
ls /var/log/pods/
tail -n 30 /var/log/pods/kube-system_kube-apiserver-*/kube-apiserver/*.log
vim /etc/kubernetes/manifests/kube-apiserver.yaml

Examentip

A typo in a manifest under /etc/kubernetes/manifests/ (a wrong flag, a wrong certificate path) is a favourite exam task. Compare with a working cluster or the docs, fix, wait 30 – 60 s.

12.4

Debug Services and DNS

Follow the path: DNS → Service → endpoints → pod port.

kubectl get svc web -n shop -o wide
kubectl get endpointslices -n shop -l kubernetes.io/service-name=web
kubectl get pods -n shop -l app=web --show-labels
kubectl run t --rm -it --image=busybox:1.36 --restart=Never -- nslookup web.shop
kubectl run t --rm -it --image=busybox:1.36 --restart=Never -- wget -qO- -T 3 http://web.shop
kubectl get pods -n kube-system -l k8s-app=kube-dns
kubectl logs -n kube-system -l k8s-app=kube-dns --tail=20
FindingCause
No endpointsSelector does not match pod labels, or pods not ready
Endpoints OK, connection refusedtargetPort is not the port the app listens on
Name does not resolveCoreDNS down, or a NetworkPolicy blocks port 53
Works by IP, not from other namespacesA NetworkPolicy

12.5

Use logs and metrics of the cluster

Resource use and cluster events help find the reason.

kubectl top nodes
kubectl top pods -A --sort-by=memory | head
kubectl get events -A --field-selector type=Warning
kubectl get --raw='/readyz?verbose' | tail

Alle commando's in dit hoofdstuk