2

I'm struggling while following Kelsey Hightower's "Kubernetes the Hard Way" tutorial. I've gone off script, because I'm trying to bootstrap k8s on a local server.

I've got the point where I'm bootstrapping etcd, however, when I'm creating the service I'm getting an error:

Failed to start etcd.service: Unit is not loaded properly: Bad message.
See system logs and 'systemctl status etcd.service' for details.

Checking the logs and I get:

Jun 21 20:16:49 controller-0 systemd[1]: [/etc/systemd/system/etcd.service:9] Missing '='.
Jun 21 20:16:49 controller-0 systemd[1]: [/etc/systemd/system/etcd.service:9] Missing '='.
Jun 21 20:17:25 controller-0 systemd[1]: [/etc/systemd/system/etcd.service:9] Missing '='.

Here's the etcd.service file:

[Unit]
Description=etcd service
Documentation=https://github.com/coreos/etcd

[Service]
User=etcd
Type=notify
ExecStart=/usr/local/bin/etcd \\
 --name ${ETCD_NAME} \\
 --data-dir /var/lib/etcd \\
 --initial-advertise-peer-urls http://${ETCD_HOST_IP}:2380 \\
 --listen-peer-urls http://${ETCD_HOST_IP}:2380 \\
 --listen-client-urls http://${ETCD_HOST_IP}:2379,http://127.0.0.1:2379 \\
 --advertise-client-urls http://${ETCD_HOST_IP}:2379 \\
 --initial-cluster-token etcd-cluster-1 \\
 --initial-cluster etcd-1=http://192.168.0.7:2380 \\
 --initial-cluster-state new \\
 --heartbeat-interval 1000 \\
 --election-timeout 5000
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
| improve this question | | | | |
  • Are you sure that is your unit file? Some lines appear to be missing, and there appear to be extra characters at the end of some lines. – Michael Hampton Jun 22 '19 at 3:59
  • you're right, I missed the first line which is [Unit]. I added it. The \\ are because the one line is extremely long – Baron Jun 22 '19 at 5:15
  • You should have one backslash, not two. – Michael Hampton Jun 22 '19 at 6:15
  • Thanks this was it! – Baron Jun 22 '19 at 20:59
  • 1
    Hello @Baron, Could you add your solution as an answer and mark it as approved? It will make your solution more visible if anyone will be searching for similar issues. – PjoterS Jun 25 '19 at 14:32
2

The answer was pointed out by @Michael Hampton. The two backslashes were because the code was supposed to be written from the terminal (in the guide). In the etcd.service file, lines should be broken with a single .

[Unit]
Description=etcd service
Documentation=https://github.com/coreos/etcd

[Service]
User=etcd
Type=notify
ExecStart=/usr/local/bin/etcd \
 --name ${ETCD_NAME} \
 --data-dir /var/lib/etcd \
 --initial-advertise-peer-urls http://${ETCD_HOST_IP}:2380 \
 --listen-peer-urls http://${ETCD_HOST_IP}:2380 \
 --listen-client-urls http://${ETCD_HOST_IP}:2379,http://127.0.0.1:2379 \
 --advertise-client-urls http://${ETCD_HOST_IP}:2379 \
 --initial-cluster-token etcd-cluster-1 \
 --initial-cluster etcd-1=http://192.168.0.7:2380 \
 --initial-cluster-state new \
 --heartbeat-interval 1000 \
 --election-timeout 5000
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.