kelseyhightower / kubernetes-the-hard-way

Bootstrap Kubernetes the hard way. No scripts.
Apache License 2.0
40.72k stars 13.96k forks source link

etcd systemd configuration missing #776

Closed chuckn246 closed 5 months ago

chuckn246 commented 5 months ago

I made it to 07-bootstrapping-etcd and noticed the systemd service configuration is missing.

I looked at the git history and noticed that the heredoc that originally created the service file was recently removed.

edit: https://github.com/kelseyhightower/kubernetes-the-hard-way/blob/master/docs/07-bootstrapping-etcd.md

chuckn246 commented 5 months ago

I was able to get the service started by using the etcd systemd service example from here: https://github.com/etcd-io/etcd/blob/main/contrib/systemd/etcd.service then editing it with code from the commit where the code was removed.

etcd_name=$(hostname -s)
internal_ip=$(hostname -I | awk '{ print $1 }')

cat <<EOF > /etc/systemd/system/etcd.service
[Unit]
Description=etcd key-value store
Documentation=https://github.com/etcd-io/etcd
After=network-online.target local-fs.target remote-fs.target time-sync.target
Wants=network-online.target local-fs.target remote-fs.target time-sync.target

[Service]
Type=notify
Environment=ETCD_UNSUPPORTED_ARCH=arm64
ExecStart=/usr/local/bin/etcd \\
  --name ${etcd_name} \\
  --cert-file=/etc/etcd/kube-api-server.crt \\
  --key-file=/etc/etcd/kube-api-server.key \\
  --peer-cert-file=/etc/etcd/kube-api-server.crt \\
  --peer-key-file=/etc/etcd/kube-api-server.key \\
  --trusted-ca-file=/etc/etcd/ca.crt \\
  --peer-trusted-ca-file=/etc/etcd/ca.crt \\
  --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 ${etcd_name}=https://${internal_ip}:2380 \\
  --initial-cluster-state new \\
  --data-dir=/var/lib/etcd
Restart=always
RestartSec=10s
LimitNOFILE=40000

[Install]
WantedBy=multi-user.target
EOF

I'm not sure if this is correct yet but the service starts.

riabuz commented 5 months ago

In the doc, it prompts you to use the the etcd service found in the units/ dir

chuckn246 commented 5 months ago

In the doc, it prompts you to use the the etcd service found in the units/ dir

oh drr, yup it's in the scp command..

Thanks!