liveBook · Manning

Etcd

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

etcd is a consistent distributed key-value store used by Kubernetes to persist cluster configuration and resource state.

etcd is the control plane’s key–value datastore for Kubernetes cluster configuration. It records resource state, such as how many pods and Deployments exist and which ports Services expose. It does not store application data. Losing this configuration would make it difficult to recreate the cluster’s resources. section 2.2 section 2.4

To locate and check etcd on a control plane node:

  • Look for its system pod in the kube-system namespace. To list pods on a specific control plane node, run `kubectl get po -o wide -A --field-selector spec.nodeName=kind-control-plane`. section 2.1.2 section 9.3.1
  • Inspect `/etc/kubernetes/manifests` for the control plane’s static-pod YAML. The kubelet picks up these manifests rather than relying on the scheduler to create the pods. section 2.4 section 9.3.1
  • Check the API server’s `--etcd-servers` address and its etcd CA, client certificate, and client key settings in `kube-apiserver.yaml`. The API server uses these credentials to communicate securely with etcd. section 2.2

Diagnose an API server that cannot reach etcd

After an interrupted control plane upgrade, first check whether the kubelet is running with `systemctl status kubelet`. If the API server container has exited, use `crictl ps -a` and `crictl logs <containerid>`. A connection-refused error for `127.0.0.2:2379` points to an incorrect etcd address in the API server manifest. Correct the address, restart the kubelet, then verify that the API server is running with `crictl ps` and that the API responds with `kubectl get ns`. section 8.2.5

spec:
  containers:
  - command:
    - kube-apiserver
    - --etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt
    - --etcd-certfile=/etc/kubernetes/pki/apiserver-etcd-client.crt
    - --etcd-keyfile=/etc/kubernetes/pki/apiserver-etcd-client.key
    - --etcd-servers=https://127.0.0.1:2379

The API server manifest shows the etcd endpoint alongside the CA file, client certificate, and client key used for its connection. section 2.2

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Explains the pod, API server TLS settings, and a connectivity repair; does not demonstrate direct datastore operations.
Examples
Uses an API server manifest and a wrong-endpoint failure diagnosed through crictl logs and verified with kubectl.
What it assumes
Assumes access to a Kubernetes control plane and basic command-line administration while defining etcd’s role in cluster state.
What you can do after
Diagnose/debug an API server’s etcd connection by checking its endpoint, certificates, container logs, and recovered API access.
How it connects
Connects etcd to the API server, control plane static pods, kubelet, TLS certificates, and cluster state.

Also explained in

Compare how 2 books explain etcd →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.