Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable etcd service auto start in CoreOS via systemd

I have deployed a CoreOS standealone server with VMware image follow this guide to experience CoreOS.

After deploy success, I found that my CoreOS only enable Docker service, without etcd and fleet service running. Although I know how to use systemd to run etcd and fleet service manually. And I also know use a proper cloud-config can install CoreOS in which etcd and fleet service start automatically.

But I want to know that:

  1. Is it possible to place a unit file in /etc/systemd/system to make systemd starts etcd service automatically?
  2. If can, what is the content of the unit file?
  3. If cannot, what is the other way?

Thanks

like image 341
Yang Lifan Avatar asked Mar 18 '23 23:03

Yang Lifan


2 Answers

  1. Yes. You must have a an etcd.service and fleet.service with an Install section. I've added WantedBy=default.target in mine.

  2. They are already placed on coreos systems within /usr/lib64/systemd/system/. You can copy them to /etc/systemd/system/:

$ cp /usr/lib64/systemd/system/etcd.service /etc/systemd/system/
$ cp /usr/lib64/systemd/system/fleet.service /etc/systemd/system/
$ echo -e '[Install]\nWantedBy=default.target >> /etc/systemd/system/fleet.service
$ echo -e '[Install]\nWantedBy=default.target >> /etc/systemd/system/etcd.service
$ systemctl enable etcd.service
$ systemctl enable fleet.service

I'll also give you the general warning here that I have no idea what changes to /etc/systemd/ do in the long run, given CoreOSs upgrade system. An upgrade could wipe out /etc/systemd/ leaving you in a confused state as to what happened to your customized systemd scripts not managed by cloud-init.

like image 85
Sheena Artrip Avatar answered Mar 31 '23 12:03

Sheena Artrip


The proper way to do this is with cloud-config. Specifically for VMware, you'll need to serve the cloud-config via config-drive as documented.

It's kind of a pain, but it'll work.

like image 23
Rob Avatar answered Mar 31 '23 13:03

Rob