etcd: add systemd unit support for clustering

Refer https://etcd.io/docs/v3.5/op-guide/clustering/
for etcd clustering design background details.

etcd-new.service triggers only, when the config file available
in the specified path. This generic serive helps to start etcd
cluster based on the project specific use cases and config
files.

etcd-new.service only required to run on initial setup or new node
add into the existing cluster. All other use cases use regular
etcd.service to start etcd with existing cluster configuration.

Signed-off-by: ojayanth <ojayanth@in.ibm.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
ojayanth
2023-05-12 05:08:41 -05:00
committed by Khem Raj
parent 9400a94fc1
commit a179653ce2
3 changed files with 29 additions and 1 deletions
@@ -0,0 +1,9 @@
[Unit]
Description=Monitor the etcd config file changes
[Path]
PathChanged=/run/etcd-new.conf
Unit=etcd-new.service
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,15 @@
[Unit]
Description=etcd cluster member start/add service
Documentation=https://etcd.io/docs/v3.5/op-guide/clustering/
ConditionPathExists=!/var/lib/etcd/member
ConditionPathExists=/run/etcd-new.conf
OnFailure=etcd.service
[Service]
Type=notify
EnvironmentFile=/run/etcd-new.conf
ExecStart=/usr/bin/etcd
Restart=no
[Install]
WantedBy=multi-user.target
+5 -1
View File
@@ -10,6 +10,8 @@ SRC_URI = " \
file://0001-test_lib.sh-remove-gobin-requirement-during-build.patch;patchdir=src/${GO_IMPORT} \ file://0001-test_lib.sh-remove-gobin-requirement-during-build.patch;patchdir=src/${GO_IMPORT} \
file://etcd.service \ file://etcd.service \
file://etcd-existing.conf \ file://etcd-existing.conf \
file://etcd-new.service \
file://etcd-new.path \
" "
SRCREV = "215b53cf3b48ee761f4c40908b3874b2e5e95e9f" SRCREV = "215b53cf3b48ee761f4c40908b3874b2e5e95e9f"
@@ -53,7 +55,7 @@ go_do_compile:prepend() {
REQUIRED_DISTRO_FEATURES = "systemd" REQUIRED_DISTRO_FEATURES = "systemd"
SYSTEMD_PACKAGES = "${PN}" SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN}:append = " etcd.service" SYSTEMD_SERVICE:${PN}:append = " etcd.service etcd-new.service etcd-new.path"
do_install:append() { do_install:append() {
install -d ${D}${bindir}/ install -d ${D}${bindir}/
@@ -63,6 +65,8 @@ do_install:append() {
install -m 0644 ${WORKDIR}/etcd-existing.conf -D -t ${D}${sysconfdir}/etcd.d install -m 0644 ${WORKDIR}/etcd-existing.conf -D -t ${D}${sysconfdir}/etcd.d
install -d ${D}${systemd_system_unitdir} install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/etcd.service ${D}${systemd_system_unitdir}/ install -m 0644 ${WORKDIR}/etcd.service ${D}${systemd_system_unitdir}/
install -m 0644 ${WORKDIR}/etcd-new.service ${D}${systemd_system_unitdir}/
install -m 0644 ${WORKDIR}/etcd-new.path ${D}${systemd_system_unitdir}/
} }
FILES:${PN}:append = " ${sysconfdir}/etcd.d/etcd-existing.conf" FILES:${PN}:append = " ${sysconfdir}/etcd.d/etcd-existing.conf"