etcd: systemd unit support to start existing etcd node

Added etcd service and configuration file support to start etcd service
with existing cluster configuration.

Change-Id: Ia52bbf20fd1951aa76184da54af94231d2324888
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:02:37 -05:00
committed by Khem Raj
parent d5b57d8505
commit 9400a94fc1
3 changed files with 64 additions and 1 deletions
@@ -0,0 +1,37 @@
# This is the configuration file to start the etcd server with
# existing cluster configuration in the data directory.
# Initial cluster state ('new' or 'existing').
ETCD_INITIAL_CLUSTER_STATE='existing'
# Path to the data directory.
ETCD_DATA_DIR='/var/lib/etcd'
# Time (in milliseconds) of a heartbeat interval.
ETCD_HEARTBEAT_INTERVAL=100
# Time (in milliseconds) for an election to timeout.
ETCD_ELECTION_TIMEOUT=1000
# List of comma separated URLs to listen on for peer traffic.
ETCD_LISTEN_PEER_URLS=http://localhost:2380
# List of comma separated URLs to listen on for client traffic.
ETCD_LISTEN_CLIENT_URLS=http://localhost:2379
# List of this member's peer URLs to advertise to the rest of the cluster.
# The URLs needed to be a comma-separated list.
ETCD_INITIAL_ADVERTISE_PEER_URLS=http://localhost:2380
# List of this member's client URLs to advertise to the public.
# The URLs needed to be a comma-separated list.
ETCD_ADVERTISE_CLIENT_URLS=http://localhost:2379
# Enable info-level logging for etcd.
ETCD_LOG_LEVEL='info'
# Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd.
ETCD_LOG_OUTPUTS='default'
# etcd is not officially supported on arm64
ETCD_UNSUPPORTED_ARCH='arm'
@@ -0,0 +1,15 @@
[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
ConditionPathExists=/var/lib/etcd/member
[Service]
Type=notify
EnvironmentFile=/etc/etcd.d/etcd-existing.conf
ExecStart=/usr/bin/etcd
Restart=always
[Install]
WantedBy=multi-user.target
+12 -1
View File
@@ -8,6 +8,8 @@ SRC_URI = " \
git://github.com/etcd-io/etcd;branch=release-3.5;protocol=https \
file://0001-xxhash-bump-to-v2.1.2.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-existing.conf \
"
SRCREV = "215b53cf3b48ee761f4c40908b3874b2e5e95e9f"
@@ -22,7 +24,7 @@ RDEPENDS:${PN}-dev = " \
export GO111MODULE="on"
inherit go
inherit go systemd pkgconfig
# Go based binaries do not handle being stripped
INHIBIT_PACKAGE_STRIP = "1"
@@ -49,10 +51,19 @@ go_do_compile:prepend() {
chmod u+w -R ${WORKDIR}/build/pkg/mod
}
REQUIRED_DISTRO_FEATURES = "systemd"
SYSTEMD_PACKAGES = "${PN}"
SYSTEMD_SERVICE:${PN}:append = " etcd.service"
do_install:append() {
install -d ${D}${bindir}/
install -m 0755 ${D}/usr/lib/go/src/go.etcd.io/etcd/v3/bin/etcd ${D}${bindir}
install -m 0755 ${D}/usr/lib/go/src/go.etcd.io/etcd/v3/bin/etcdctl ${D}${bindir}
install -m 0755 ${D}/usr/lib/go/src/go.etcd.io/etcd/v3/bin/etcdutl ${D}${bindir}
install -m 0644 ${WORKDIR}/etcd-existing.conf -D -t ${D}${sysconfdir}/etcd.d
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/etcd.service ${D}${systemd_system_unitdir}/
}
FILES:${PN}:append = " ${sysconfdir}/etcd.d/etcd-existing.conf"