Bootstrapping etcd: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| (9 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
=== Download | === Download etcd === | ||
<syntaxhighlight> | <syntaxhighlight lang="bash"> | ||
wget -q --show-progress --https-only --timestamping \ | wget -q --show-progress --https-only --timestamping \ | ||
"https://github.com/etcd-io/etcd/releases/download/v3.4. | "https://github.com/etcd-io/etcd/releases/download/v3.4.16/etcd-v3.4.16-linux-amd64.tar.gz" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Validate | === systems startup script for etcd === | ||
<syntaxhighlight lang="bash"> | |||
INTERNAL_IP=$(ifconfig ens4 | grep -v inet6 |grep 'inet' | tr -s ' ' | cut -d' ' -f3) | |||
cat <<EOF | sudo tee /etc/systemd/system/etcd.service | |||
[Unit] | |||
Description=etcd | |||
Documentation=https://github.com/coreos | |||
[Service] | |||
Type=notify | |||
ExecStart=/usr/local/bin/etcd \\ | |||
--name ${ETCD_NAME} \\ | |||
--cert-file=/etc/etcd/kubernetes.pem \\ | |||
--key-file=/etc/etcd/kubernetes-key.pem \\ | |||
--peer-cert-file=/etc/etcd/kubernetes.pem \\ | |||
--peer-key-file=/etc/etcd/kubernetes-key.pem \\ | |||
--trusted-ca-file=/etc/etcd/ca.pem \\ | |||
--peer-trusted-ca-file=/etc/etcd/ca.pem \\ | |||
--peer-client-cert-auth \\ | |||
--client-cert-auth \\ | |||
--initial-advertise-peer-urls https://${INTERNAL_IP}:2380 \\ | |||
--listen-peer-urls https://${INTERNAL_IP}:2380 \\ | |||
--listen-client-urls https://${INTERNAL_IP}:2379,https://127.0.0.1:2379 \\ | |||
--advertise-client-urls https://${INTERNAL_IP}:2379 \\ | |||
--initial-cluster-token etcd-cluster-0 \\ | |||
--initial-cluster us-etcd-01=https://10.1.20.11:2380,us-etcd-02=https://10.1.20.12:2380,us-etcd-03=https://10.1.20.10:2380 \\ | |||
--initial-cluster-state new \\ | |||
--data-dir=/var/lib/etcd | |||
Restart=on-failure | |||
RestartSec=5 | |||
[Install] | |||
WantedBy=multi-user.target | |||
EOF | |||
</syntaxhighlight> | |||
=== Validate etcd Installation === | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo ETCDCTL_API=3 etcdctl endpoint status --cluster -w table --cacert=/etc/etcd/ca.pem --cert=/etc/etcd/etcd.pem --key=/etc/etcd/etcd-key.pem | sudo ETCDCTL_API=3 etcdctl endpoint status --cluster -w table --cacert=/etc/etcd/ca.pem --cert=/etc/etcd/etcd.pem --key=/etc/etcd/etcd-key.pem | ||
+-------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | |||
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | | |||
+-------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | |||
| https://10.1.20.12:2379 | 29458c1e3b5d42da | 3.4.9 | 5.3 MB | false | false | 3152 | 39760 | 39760 | | | |||
| https://10.1.20.10:2379 | 2b1ec301a82f6187 | 3.4.9 | 5.3 MB | false | false | 3152 | 39760 | 39760 | | | |||
| https://10.1.20.11:2379 | bbd865a60d3517fb | 3.4.9 | 5.3 MB | true | false | 3152 | 39760 | 39760 | | | |||
+-------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 06:53, 26 May 2021
Download etcd
wget -q --show-progress --https-only --timestamping \
"https://github.com/etcd-io/etcd/releases/download/v3.4.16/etcd-v3.4.16-linux-amd64.tar.gz"
systems startup script for etcd
INTERNAL_IP=$(ifconfig ens4 | grep -v inet6 |grep 'inet' | tr -s ' ' | cut -d' ' -f3)
cat <<EOF | sudo tee /etc/systemd/system/etcd.service
[Unit]
Description=etcd
Documentation=https://github.com/coreos
[Service]
Type=notify
ExecStart=/usr/local/bin/etcd \\
--name ${ETCD_NAME} \\
--cert-file=/etc/etcd/kubernetes.pem \\
--key-file=/etc/etcd/kubernetes-key.pem \\
--peer-cert-file=/etc/etcd/kubernetes.pem \\
--peer-key-file=/etc/etcd/kubernetes-key.pem \\
--trusted-ca-file=/etc/etcd/ca.pem \\
--peer-trusted-ca-file=/etc/etcd/ca.pem \\
--peer-client-cert-auth \\
--client-cert-auth \\
--initial-advertise-peer-urls https://${INTERNAL_IP}:2380 \\
--listen-peer-urls https://${INTERNAL_IP}:2380 \\
--listen-client-urls https://${INTERNAL_IP}:2379,https://127.0.0.1:2379 \\
--advertise-client-urls https://${INTERNAL_IP}:2379 \\
--initial-cluster-token etcd-cluster-0 \\
--initial-cluster us-etcd-01=https://10.1.20.11:2380,us-etcd-02=https://10.1.20.12:2380,us-etcd-03=https://10.1.20.10:2380 \\
--initial-cluster-state new \\
--data-dir=/var/lib/etcd
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
Validate etcd Installation
sudo ETCDCTL_API=3 etcdctl endpoint status --cluster -w table --cacert=/etc/etcd/ca.pem --cert=/etc/etcd/etcd.pem --key=/etc/etcd/etcd-key.pem
+-------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS |
+-------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
| https://10.1.20.12:2379 | 29458c1e3b5d42da | 3.4.9 | 5.3 MB | false | false | 3152 | 39760 | 39760 | |
| https://10.1.20.10:2379 | 2b1ec301a82f6187 | 3.4.9 | 5.3 MB | false | false | 3152 | 39760 | 39760 | |
| https://10.1.20.11:2379 | bbd865a60d3517fb | 3.4.9 | 5.3 MB | true | false | 3152 | 39760 | 39760 | |
+-------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+