2017-08-29 00:19:25 +03:00
|
|
|
# Bootstrapping the etcd Cluster
|
|
|
|
|
2025-06-02 06:37:55 +03:00
|
|
|
Kubernetes components are stateless and store cluster state in [etcd]. In this
|
|
|
|
lab you will bootstrap a single node etcd cluster.
|
2017-08-29 00:19:25 +03:00
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
|
2025-06-02 06:37:55 +03:00
|
|
|
Copy `etcd` binaries and systemd unit files to the `controlplane` machine:
|
2017-08-29 00:19:25 +03:00
|
|
|
|
2023-11-01 09:16:49 +03:00
|
|
|
```bash
|
|
|
|
scp \
|
2025-04-10 09:08:13 +03:00
|
|
|
downloads/controller/etcd \
|
|
|
|
downloads/client/etcdctl \
|
2023-11-01 09:16:49 +03:00
|
|
|
units/etcd.service \
|
2025-06-03 05:13:21 +03:00
|
|
|
vagrant@controlplane:~/
|
2017-08-29 00:19:25 +03:00
|
|
|
```
|
2018-05-12 19:54:18 +03:00
|
|
|
|
2025-06-02 06:37:55 +03:00
|
|
|
The commands in this lab must be run on the `controlplane` machine. Login to
|
|
|
|
the `controlplane` machine using the `ssh` command. Example:
|
2017-08-29 00:19:25 +03:00
|
|
|
|
2023-11-01 09:16:49 +03:00
|
|
|
```bash
|
2025-06-03 05:13:21 +03:00
|
|
|
ssh vagrant@controlplane
|
2023-11-01 09:16:49 +03:00
|
|
|
```
|
2017-08-29 00:19:25 +03:00
|
|
|
|
2023-11-01 09:16:49 +03:00
|
|
|
## Bootstrapping an etcd Cluster
|
2017-08-29 00:19:25 +03:00
|
|
|
|
2023-11-01 09:16:49 +03:00
|
|
|
### Install the etcd Binaries
|
2017-08-29 00:19:25 +03:00
|
|
|
|
|
|
|
Extract and install the `etcd` server and the `etcdctl` command line utility:
|
|
|
|
|
2023-11-01 09:16:49 +03:00
|
|
|
```bash
|
2018-05-12 19:54:18 +03:00
|
|
|
{
|
2025-06-03 05:13:21 +03:00
|
|
|
sudo mv etcd etcdctl /usr/local/bin/
|
2018-05-12 19:54:18 +03:00
|
|
|
}
|
2017-08-29 00:19:25 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
### Configure the etcd Server
|
|
|
|
|
2023-11-01 09:16:49 +03:00
|
|
|
```bash
|
2018-05-12 19:54:18 +03:00
|
|
|
{
|
2025-06-03 05:13:21 +03:00
|
|
|
sudo mkdir -p /etc/etcd /var/lib/etcd
|
|
|
|
sudo chmod 700 /var/lib/etcd
|
|
|
|
sudo cp ca.crt kube-apiserver.key kube-apiserver.crt \
|
2023-11-01 09:16:49 +03:00
|
|
|
/etc/etcd/
|
2018-05-12 19:54:18 +03:00
|
|
|
}
|
2017-08-29 00:19:25 +03:00
|
|
|
```
|
|
|
|
|
2025-06-02 06:37:55 +03:00
|
|
|
Each etcd member must have a unique name within an etcd cluster. Set the etcd
|
|
|
|
name to match the hostname of the current compute instance:
|
2017-08-29 00:19:25 +03:00
|
|
|
|
|
|
|
Create the `etcd.service` systemd unit file:
|
|
|
|
|
2023-11-01 09:16:49 +03:00
|
|
|
```bash
|
2025-06-03 05:13:21 +03:00
|
|
|
sudo mv etcd.service /etc/systemd/system/
|
2017-08-29 00:19:25 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
### Start the etcd Server
|
|
|
|
|
2023-11-01 09:16:49 +03:00
|
|
|
```bash
|
2018-05-12 19:54:18 +03:00
|
|
|
{
|
2025-06-03 05:13:21 +03:00
|
|
|
sudo systemctl daemon-reload
|
|
|
|
sudo systemctl enable etcd
|
|
|
|
sudo systemctl start etcd.service
|
2018-05-12 19:54:18 +03:00
|
|
|
}
|
2017-08-29 00:19:25 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
## Verification
|
|
|
|
|
|
|
|
List the etcd cluster members:
|
|
|
|
|
2023-11-01 09:16:49 +03:00
|
|
|
```bash
|
|
|
|
etcdctl member list
|
2017-08-29 00:19:25 +03:00
|
|
|
```
|
|
|
|
|
2023-11-01 09:16:49 +03:00
|
|
|
```text
|
|
|
|
6702b0a34e2cfd39, started, controller, http://127.0.0.1:2380, http://127.0.0.1:2379, false
|
2017-08-29 00:19:25 +03:00
|
|
|
```
|
|
|
|
|
2025-06-03 16:32:11 +03:00
|
|
|
Next: [Bootstrapping the Kubernetes Control Plane](08-bootstrapping-kubernetes-controlplane)
|
2025-06-02 06:37:55 +03:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
[etcd]: https://github.com/etcd-io/etcd
|