kubernetes-the-hard-way/docs/07-bootstrapping-etcd.md

77 lines
1.6 KiB
Markdown
Raw Normal View History

2017-08-29 00:19:25 +03:00
# Bootstrapping the etcd Cluster
2019-09-14 21:41:56 +03:00
Kubernetes components are stateless and store cluster state in [etcd](https://github.com/etcd-io/etcd). In this lab you will bootstrap a three node etcd cluster and configure it for high availability and secure remote access.
2017-08-29 00:19:25 +03:00
## Prerequisites
Copy `etcd` binaries and systemd unit files to the `server` instance:
2017-08-29 00:19:25 +03:00
```bash
scp \
downloads/etcd-v3.4.27-linux-amd64.tar.gz \
units/etcd.service \
root@server:~/
2017-08-29 00:19:25 +03:00
```
The commands in this lab must be run on the `server` machine. Login to the `server` machine using the `ssh` command. Example:
2017-08-29 00:19:25 +03:00
```bash
ssh root@server
```
2017-08-29 00:19:25 +03:00
## Bootstrapping an etcd Cluster
2017-08-29 00:19:25 +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:
```bash
{
tar -xvf etcd-v3.4.27-linux-amd64.tar.gz
mv etcd-v3.4.27-linux-amd64/etcd* /usr/local/bin/
}
2017-08-29 00:19:25 +03:00
```
### Configure the etcd Server
```bash
{
mkdir -p /etc/etcd /var/lib/etcd
chmod 700 /var/lib/etcd
cp ca.crt kube-api-server.key kube-api-server.crt \
/etc/etcd/
}
2017-08-29 00:19:25 +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:
Create the `etcd.service` systemd unit file:
```bash
mv etcd.service /etc/systemd/system/
2017-08-29 00:19:25 +03:00
```
### Start the etcd Server
```bash
{
systemctl daemon-reload
systemctl enable etcd
systemctl start etcd
}
2017-08-29 00:19:25 +03:00
```
## Verification
List the etcd cluster members:
```bash
etcdctl member list
2017-08-29 00:19:25 +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
```
Next: [Bootstrapping the Kubernetes Control Plane](08-bootstrapping-kubernetes-controllers.md)