mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-17 18:06:59 +02:00
fix(etcd.service): refactor to support cloudinit and easy c10n slaughtering
This commit is contained in:
parent
20da555fa2
commit
e6b4539b92
@ -11,7 +11,7 @@ coreos:
|
|||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
StandardOutput=journal+console
|
StandardOutput=journal+console
|
||||||
ExecStart=/usr/share/oem/usr/bin/ec2-ssh-key
|
ExecStart=/usr/share/oem/bin/ec2-ssh-key
|
||||||
- name: ec2-cloudinit.service
|
- name: ec2-cloudinit.service
|
||||||
runtime: yes
|
runtime: yes
|
||||||
content: |
|
content: |
|
||||||
@ -32,21 +32,10 @@ coreos:
|
|||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
RemainAfterExit=no
|
RemainAfterExit=no
|
||||||
ExecStart=/usr/share/oem/usr/bin/coreos-c10n
|
ExecStart=/usr/share/oem/bin/coreos-c10n
|
||||||
- name: etcd.service
|
|
||||||
runtime: yes
|
|
||||||
content: |
|
|
||||||
[Unit]
|
|
||||||
Description=etcd with ec2 auto-bootstrap
|
|
||||||
Requires=ec2-c10n.service
|
|
||||||
After=ec2-c10n.service
|
|
||||||
|
|
||||||
[Service]
|
write_files:
|
||||||
User=etcd
|
- path: /etc/systemd/system/etcd.service.d/10-oem.conf
|
||||||
PermissionsStartOnly=true
|
contents: |
|
||||||
ExecStart=/usr/share/oem/usr/bin/etcd-bootstrap
|
[Service]
|
||||||
Restart=always
|
Environment=ETCD_PEER_ELECTION_TIMEOUT=1200
|
||||||
RestartSec=10s
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
|
@ -9,8 +9,8 @@ depwarn() {
|
|||||||
C10N_ENDPOINT=https://core-api.appspot.com/v1/c10n/group
|
C10N_ENDPOINT=https://core-api.appspot.com/v1/c10n/group
|
||||||
META_URL="http://169.254.169.254/latest"
|
META_URL="http://169.254.169.254/latest"
|
||||||
|
|
||||||
BOOTSTRAP_PEERS="/var/run/etcd/bootstrap.config"
|
ETCD_SERVICE_D="/run/systemd/system/etcd.service.d"
|
||||||
BOOTSTRAP_DISCOVERY="/var/run/etcd/bootstrap.disco"
|
mkdir -p $ETCD_SERVICE_D
|
||||||
|
|
||||||
/usr/bin/block-until-url $META_URL
|
/usr/bin/block-until-url $META_URL
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ if head -n 1 $TMP | grep -q '^#!'; then
|
|||||||
START_FLEET=1
|
START_FLEET=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If user-data is a cloud-config, hand it off to the new hotness
|
# If user-data is a cloud-config, do not do c10n
|
||||||
elif head -n 1 $TMP | grep -q '^#cloud-config'; then
|
elif head -n 1 $TMP | grep -q '^#cloud-config'; then
|
||||||
# If an etcd discovery URL was found, we can assume the new hotness
|
# If an etcd discovery URL was found, we can assume the new hotness
|
||||||
# will handle bootstrapping, allowing us to clear the c10n token
|
# will handle bootstrapping, allowing us to clear the c10n token
|
||||||
@ -87,7 +87,8 @@ fi
|
|||||||
# After all that, if a script happened to set the discovery URL, write it to disk for etcd-bootstrap
|
# After all that, if a script happened to set the discovery URL, write it to disk for etcd-bootstrap
|
||||||
if [ -n "${ETCD_DISCOVERY_URL}" ]; then
|
if [ -n "${ETCD_DISCOVERY_URL}" ]; then
|
||||||
echo "Using '${ETCD_DISCOVERY_URL}' as etcd discovery url"
|
echo "Using '${ETCD_DISCOVERY_URL}' as etcd discovery url"
|
||||||
echo "${ETCD_DISCOVERY_URL}" > $BOOTSTRAP_DISCOVERY
|
echo "[Service]
|
||||||
|
Environment=ETCD_DISCOVERY=${ETCD_DISCOVERY}" > ${ETCD_SERVICE_D}/11-c10n.conf
|
||||||
# ...otherwise, we treat the provided user-data as a legacy c10n URL
|
# ...otherwise, we treat the provided user-data as a legacy c10n URL
|
||||||
elif [ -n "${C10N_TOKEN}" ]; then
|
elif [ -n "${C10N_TOKEN}" ]; then
|
||||||
depwarn "Bootstrapping etcd with the c10n service is deprecated."
|
depwarn "Bootstrapping etcd with the c10n service is deprecated."
|
||||||
@ -98,7 +99,10 @@ elif [ -n "${C10N_TOKEN}" ]; then
|
|||||||
/usr/bin/block-until-url $C10N_ENDPOINT
|
/usr/bin/block-until-url $C10N_ENDPOINT
|
||||||
|
|
||||||
IP=$(curl -s $META_URL/meta-data/local-ipv4)
|
IP=$(curl -s $META_URL/meta-data/local-ipv4)
|
||||||
curl -s $C10N_ENDPOINT -d "c10n_url=$C10N_TOKEN" -d"ip_list=$IP" > $BOOTSTRAP_PEERS
|
# XXX: change to append a valid ETCD_PEERS to /usr/share/oem/etcd.env
|
||||||
|
ETCD_PEERS=$(curl -s $C10N_ENDPOINT -d "c10n_url=$C10N_TOKEN" -d"ip_list=$IP")
|
||||||
|
echo "[Service]
|
||||||
|
Environment=ETCD_PEERS=${ETCD_PEERS}" > ${ETCD_SERVICE_D}/12-c10n.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$START_FLEET" = "1" ]; then
|
if [ "$START_FLEET" = "1" ]; then
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash +x
|
#!/bin/bash
|
||||||
|
|
||||||
ENV=$1
|
ENV=$1
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ IUSE=""
|
|||||||
S="${WORKDIR}"
|
S="${WORKDIR}"
|
||||||
|
|
||||||
src_install() {
|
src_install() {
|
||||||
into "/usr"
|
into "/"
|
||||||
dobin ${FILESDIR}/ec2-ssh-key
|
dobin ${FILESDIR}/ec2-ssh-key
|
||||||
dobin ${FILESDIR}/coreos-setup-environment
|
dobin ${FILESDIR}/coreos-setup-environment
|
||||||
dobin ${FILESDIR}/coreos-c10n
|
dobin ${FILESDIR}/coreos-c10n
|
||||||
|
1
sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r6.ebuild
vendored
Symbolic link
1
sdk_container/src/third_party/coreos-overlay/dev-db/etcd/etcd-0.3.0-r6.ebuild
vendored
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
etcd-9999.ebuild
|
@ -9,16 +9,21 @@ EAPI=4
|
|||||||
CROS_WORKON_PROJECT="coreos/etcd"
|
CROS_WORKON_PROJECT="coreos/etcd"
|
||||||
CROS_WORKON_LOCALNAME="etcd"
|
CROS_WORKON_LOCALNAME="etcd"
|
||||||
CROS_WORKON_REPO="git://github.com"
|
CROS_WORKON_REPO="git://github.com"
|
||||||
CROS_WORKON_COMMIT="040c1f591efa735e24e794d5084ad07782123e3c" # v0.3.0 + v1 API fix
|
|
||||||
inherit toolchain-funcs cros-workon systemd
|
inherit toolchain-funcs cros-workon systemd
|
||||||
|
|
||||||
|
if [[ "${PV}" == 9999 ]]; then
|
||||||
|
KEYWORDS="~amd64"
|
||||||
|
else
|
||||||
|
CROS_WORKON_COMMIT="040c1f591efa735e24e794d5084ad07782123e3c"
|
||||||
|
KEYWORDS="amd64"
|
||||||
|
fi
|
||||||
|
|
||||||
DESCRIPTION="etcd"
|
DESCRIPTION="etcd"
|
||||||
HOMEPAGE="https://github.com/coreos/etcd"
|
HOMEPAGE="https://github.com/coreos/etcd"
|
||||||
SRC_URI=""
|
SRC_URI=""
|
||||||
|
|
||||||
LICENSE="Apache-2.0"
|
LICENSE="Apache-2.0"
|
||||||
SLOT="0"
|
SLOT="0"
|
||||||
KEYWORDS="amd64 x86"
|
|
||||||
IUSE=""
|
IUSE=""
|
||||||
|
|
||||||
DEPEND=">=dev-lang/go-1.2"
|
DEPEND=">=dev-lang/go-1.2"
|
@ -1,35 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
|
||||||
# Copyright (c) 2013 CoreOS, Inc.. All rights reserved.
|
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
|
||||||
# $Header:$
|
|
||||||
#
|
|
||||||
|
|
||||||
EAPI=4
|
|
||||||
CROS_WORKON_PROJECT="coreos/etcd"
|
|
||||||
CROS_WORKON_LOCALNAME="etcd"
|
|
||||||
CROS_WORKON_REPO="git://github.com"
|
|
||||||
inherit toolchain-funcs cros-workon systemd
|
|
||||||
|
|
||||||
DESCRIPTION="etcd"
|
|
||||||
HOMEPAGE="https://github.com/coreos/etcd"
|
|
||||||
SRC_URI=""
|
|
||||||
|
|
||||||
LICENSE="Apache-2.0"
|
|
||||||
SLOT="0"
|
|
||||||
KEYWORDS="~amd64"
|
|
||||||
IUSE=""
|
|
||||||
|
|
||||||
DEPEND=">=dev-lang/go-1.2"
|
|
||||||
|
|
||||||
src_compile() {
|
|
||||||
./build
|
|
||||||
}
|
|
||||||
|
|
||||||
src_install() {
|
|
||||||
dobin ${S}/bin/${PN}
|
|
||||||
|
|
||||||
systemd_dounit "${FILESDIR}"/${PN}.service
|
|
||||||
systemd_enable_service multi-user.target ${PN}.service
|
|
||||||
systemd_dotmpfilesd "${FILESDIR}"/${PN}.conf
|
|
||||||
}
|
|
@ -1,19 +1,14 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=etcd
|
Description=etcd
|
||||||
RequiresMountsFor=/usr/share/oem
|
# this will setup cloudinit and user envs
|
||||||
# oem will setup etcd for auto bootstrapping
|
Wants=coreos-cloudinit-oem.service
|
||||||
ConditionPathExists=!/usr/share/oem/cloud-config.yml
|
After=coreos-cloudinit-oem.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=etcd
|
User=etcd
|
||||||
PermissionsStartOnly=true
|
PermissionsStartOnly=true
|
||||||
# Default, this will be overwritten with a cloud-config
|
Environment=ETCD_DATA_DIR=/var/lib/etcd ETCD_NAME=default
|
||||||
ExecStart=/usr/bin/etcd -f -data-dir /var/lib/etcd -bind-addr 0.0.0.0 -n default
|
ExecStart=/usr/bin/etcd
|
||||||
|
|
||||||
Restart=always
|
|
||||||
# Set a longish timeout in case this machine isn't behaving
|
|
||||||
# nicely and bothering the rest of the cluster
|
|
||||||
RestartSec=10s
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
Loading…
Reference in New Issue
Block a user