-
Notifications
You must be signed in to change notification settings - Fork 18
etcd3 #286
etcd3 #286
Changes from all commits
bca28fa
42bc200
02f65e1
5925c83
ecbd282
f8b1e69
372b7d3
c6d664c
0052cd4
95721e4
1aa0668
b900c10
d7ad830
0b805d1
473d527
515ce4b
dd30793
b8a1134
2f5fa44
62c9592
a722b5c
83e86a0
5115a8b
4c553a8
738582b
ee01273
a84ea72
6bfe435
8fa291f
5262773
62cbd53
aae1f8d
bd48451
c24e484
9016853
023505b
adb3a7a
1d6c3a7
c9e3231
1dee8f8
eb4972b
b730aa3
a234c6c
3fb3817
00e4045
092d61f
7cdb6b1
713d441
8c80eef
925dc17
bec3770
7d97789
3135aa9
0799cc3
ca0fd82
a6c5f4d
c9e8832
b7f5c4d
e6834af
3478ef6
8f0168a
f607dc9
1159a90
a3c669e
8196fb6
182dff9
5a36748
2634907
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ FROM planet/base | |
ENV GOPATH /gopath | ||
ENV GOROOT /opt/go | ||
ENV PATH $PATH:$GOPATH/bin:$GOROOT/bin | ||
ENV GOVERSION 1.8.3 | ||
ENV GOVERSION 1.10.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you need Also, do you know if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Etcd requires go 1.9, but I bumped to 1.10 since I was updating the version anyways: etcd-io/etcd#8548 (comment) As for an umbrella binary, I don't know, I was sticking with the full version, as I suspect that's less likely for an upstream change to affect us. |
||
|
||
# Have our own /etc/passwd with users populated from 990 to 1000 | ||
COPY passwd /etc/passwd | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This systemd drop in file, will change the etcd unit to run a gateway | ||
# instead of the etcd service | ||
|
||
[Service] | ||
ExecStart= | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra ExecStart? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to reset the previous value (here is a faint hint at resetting the values of a list attribute before setting a new one - look at the end of the document). |
||
ExecStart=/usr/bin/etcd gateway start \ | ||
--endpoints=${PLANET_ETCD_GW_ENDPOINTS} \ | ||
--listen-addr=0.0.0.0:2379 \ | ||
--trusted-ca-file=/var/state/root.cert |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[Unit] | ||
Description=Temporary Etcd Service used for upgrades | ||
Conflicts=etcd.service | ||
|
||
# This works by launching etcd, but bound to a non-default loopback interface. | ||
# This is to prevent etcd from being used, while it is being upgraded, and the | ||
# database is inconsistent | ||
|
||
[Service] | ||
Restart=always | ||
RestartSec=5 | ||
StartLimitInterval=3600 | ||
StartLimitBurst=720 | ||
Type=notify | ||
TimeoutStartSec=0 | ||
EnvironmentFile=/etc/container-environment | ||
EnvironmentFile=-/ext/etcd/etcd-version.txt | ||
ExecStartPre=/usr/bin/planet etcd init | ||
ExecStart=/usr/bin/etcd \ | ||
--name=${PLANET_ETCD_MEMBER_NAME} \ | ||
--data-dir=/ext/etcd/${PLANET_ETCD_VERSION} \ | ||
--initial-advertise-peer-urls=https://${PLANET_PUBLIC_IP}:2380 \ | ||
--advertise-client-urls=https://127.0.0.2:2379,https://127.0.0.2:4001 \ | ||
--listen-client-urls=https://127.0.0.2:2379,https://127.0.0.2:4001 \ | ||
--listen-peer-urls=https://${PLANET_PUBLIC_IP}:2380,https://${PLANET_PUBLIC_IP}:7001 \ | ||
--cert-file=/var/state/etcd.cert \ | ||
--key-file=/var/state/etcd.key \ | ||
--trusted-ca-file=/var/state/root.cert \ | ||
--client-cert-auth \ | ||
--peer-cert-file=/var/state/etcd.cert \ | ||
--peer-key-file=/var/state/etcd.key \ | ||
--peer-trusted-ca-file=/var/state/root.cert \ | ||
--peer-client-cert-auth $ETCD_OPTS \ | ||
--initial-cluster-state new | ||
User=planet | ||
Group=planet | ||
PermissionsStartOnly=true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,35 @@ | ||
.PHONY: all | ||
|
||
ARCH := amd64 | ||
TARGET := etcd-$(ETCD_VER)-linux-$(ARCH) | ||
TARGET_TARBALL := $(TARGET).tar.gz | ||
|
||
DOWNLOAD:=$(ASSETDIR)/$(TARGET_TARBALL) | ||
|
||
all: $(DOWNLOAD) | ||
@echo "\n---> Building etcd:\n" | ||
cd $(ASSETDIR) && tar -xzf $(ASSETDIR)/$(TARGET_TARBALL) | ||
mkdir -p $(ROOTFS)/var/etcd | ||
cp -afv $(ASSETDIR)/$(TARGET)/etcd $(ROOTFS)/usr/bin | ||
cp -afv $(ASSETDIR)/$(TARGET)/etcdctl $(ROOTFS)/usr/bin | ||
all: $(ETCD_VER) | ||
@echo -e "\n---> Building etcd:\n" | ||
|
||
@echo -e "\n---> Setup etcd services:\n" | ||
cd $(ASSETDIR) | ||
cp -afv ./etcd.service $(ROOTFS)/lib/systemd/system/ | ||
ln -sf /lib/systemd/system/etcd.service $(ROOTFS)/lib/systemd/system/multi-user.target.wants/ | ||
cp -afv ./etcd-upgrade.service $(ROOTFS)/lib/systemd/system/ | ||
cp -afv ./etcd-gateway.dropin $(ROOTFS)/lib/systemd/system/ | ||
cp -afv ./etcdctl3 $(ROOTFS)/usr/bin/etcdctl3 | ||
chmod +x $(ROOTFS)/usr/bin/etcdctl3 | ||
ln -sf /lib/systemd/system/etcd.service $(ROOTFS)/lib/systemd/system/multi-user.target.wants/ | ||
|
||
# mask the etcd-upgrade service so that it can only be run if intentionally unmasked | ||
ln -sf /dev/null $(ROOTFS)/etc/systemd/system/etcd-upgrade.service | ||
|
||
# Write to the release file to indicate the latest release | ||
echo PLANET_ETCD_VERSION=$(ETCD_LATEST_VER) >> $(ROOTFS)/etc/planet-release | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is appending to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, right now it's only for etcd, but strictly speaking, if we were to embed version information for other dependencies, we could also include additional version information. |
||
|
||
.PHONY: $(ETCD_VER) | ||
$(ETCD_VER): | ||
@echo -e "\n---> $@ - Downloading etcd\n" | ||
curl -L https://github.com/coreos/etcd/releases/download/$@/etcd-$@-linux-$(ARCH).tar.gz \ | ||
-o $(ASSETDIR)/$@.tar.gz; | ||
|
||
@echo -e "\n---> $@ - Extracting etcd\n" | ||
cd $(ASSETDIR) | ||
tar -xzf $(ASSETDIR)/$@.tar.gz | ||
|
||
$(DOWNLOAD): | ||
curl -L https://github.com/coreos/etcd/releases/download/$(ETCD_VER)/$(TARGET_TARBALL) -o $(DOWNLOAD) | ||
cp -afv etcd-$@-linux-$(ARCH)/etcd $(ROOTFS)/usr/bin/etcd-$@ | ||
cp -afv etcd-$@-linux-$(ARCH)/etcdctl $(ROOTFS)/usr/bin/etcdctl-$@ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
# | ||
# This is a helper script, to make it easier to access the etcd3 datastore | ||
# | ||
|
||
ETCDCTL_API=3 ETCDCTL_CERT_FILE="" ETCDCTL_KEY_FILE="" ETCDCTL_CA_FILE="" ETCDCTL_PEERS="" \ | ||
/usr/bin/etcdctl --key /var/state/etcd.key --cert /var/state/etcd.cert --cacert /var/state/root.cert "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd swap the variable definitions to make it less error-prone:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I would embed $(ETCD_LATEST_VER) in ETCD_VER, to me it adds some amount of risks, that if someone say bumps ETCD to v3.3.5, that they may forget to add it to the ETCD_VER list, everything would work but upgrades from that version may not.
The way it is now, if someone bumps ETCD_LATEST_VER to v3.3.5, but forgets to update ETCD_VER, the new release will clearly not work.