From 46c481397287b3598f01eea90d805967ab7b0dcb Mon Sep 17 00:00:00 2001 From: Lisa Seelye Date: Sat, 16 Jul 2016 14:39:36 -0400 Subject: [PATCH] Streamline the etcd.service creation With this, the need for `mv` and `sed` is eliminated, the only casualty is escaping the `\` in the heredoc and odd `"`. Perhaps the tradeoff is worth it. --- docs/03-etcd.md | 63 ++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/docs/03-etcd.md b/docs/03-etcd.md index 1fb9e2b..9931ce4 100644 --- a/docs/03-etcd.md +++ b/docs/03-etcd.md @@ -60,36 +60,6 @@ sudo mkdir -p /var/lib/etcd Create the etcd systemd unit file: -``` -cat > etcd.service <<"EOF" -[Unit] -Description=etcd -Documentation=https://github.com/coreos - -[Service] -ExecStart=/usr/bin/etcd --name ETCD_NAME \ - --cert-file=/etc/etcd/kubernetes.pem \ - --key-file=/etc/etcd/kubernetes-key.pem \ - --peer-cert-file=/etc/etcd/kubernetes.pem \ - --peer-key-file=/etc/etcd/kubernetes-key.pem \ - --trusted-ca-file=/etc/etcd/ca.pem \ - --peer-trusted-ca-file=/etc/etcd/ca.pem \ - --initial-advertise-peer-urls https://INTERNAL_IP:2380 \ - --listen-peer-urls https://INTERNAL_IP:2380 \ - --listen-client-urls https://INTERNAL_IP:2379,http://127.0.0.1:2379 \ - --advertise-client-urls https://INTERNAL_IP:2379 \ - --initial-cluster-token etcd-cluster-0 \ - --initial-cluster etcd0=https://10.240.0.10:2380,etcd1=https://10.240.0.11:2380,etcd2=https://10.240.0.12:2380 \ - --initial-cluster-state new \ - --data-dir=/var/lib/etcd -Restart=on-failure -RestartSec=5 - -[Install] -WantedBy=multi-user.target -EOF -``` - ``` export INTERNAL_IP=$(curl -s -H "Metadata-Flavor: Google" \ http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip) @@ -99,16 +69,35 @@ export INTERNAL_IP=$(curl -s -H "Metadata-Flavor: Google" \ export ETCD_NAME=$(hostname -s) ``` -``` -sed -i s/INTERNAL_IP/$INTERNAL_IP/g etcd.service -``` ``` -sed -i s/ETCD_NAME/$ETCD_NAME/g etcd.service -``` +sudo sh "cat > /etc/systemd/system/etcd.service <