packet: fix wrong etcd settings
The rkt-based etcd-member service that is part of Flatcar used a unit
drop-in	file but the new etcd service uses an environment file and
requires the folder to be set up with certain permissions.
MODIFY
assets/terraform-modules/packet/flatcar-linux/kubernetes/cl/controller.yaml.tmpl
assets/terraform-modules/packet/flatcar-linux/kubernetes/cl/controller.yaml.tmpl
@@ -47,7 +47,7 @@ systemd:
[Unit]
Description=Wait for DNS entries
Wants=systemd-resolved.service
- Before=kubelet.service etcd-member.service bootkube.service
+ Before=kubelet.service etcd.service bootkube.service
[Service]
Restart=on-failure
RestartSec=5s
@@ -55,16 +55,16 @@ systemd:
RemainAfterExit=true
ExecStart=/bin/sh -c 'while ! /usr/bin/grep '^[^#[:space:]]' /etc/resolv.conf > /dev/null; do sleep 1; done; /opt/wait-for-dns ${dns_zone} ${cluster_name}-private 3600'
[Install]
- RequiredBy=kubelet.service etcd-member.service bootkube.service
+ RequiredBy=kubelet.service etcd.service bootkube.service
- name: create-etcd-config.service
# This service will extract value of private interface from the env var file `/run/metadata/flatcar`.
# And then assign it to the variables that which will be stored in file `/etc/kubernetes/etcd.config`,
- # this file is sourced by etcd-member service.
+ # this file is sourced by etcd service.
enable: true
contents: |
[Unit]
Description=Create a etcd env file to be used by etcd to listen on private interface
- Before=etcd-member.service
+ Before=etcd.service
Requires=coreos-metadata.service
After=coreos-metadata.service
[Service]
@@ -73,7 +73,7 @@ systemd:
RemainAfterExit=true
ExecStart=/bin/sh -c 'echo "ETCD_LISTEN_CLIENT_URLS=https://$COREOS_PACKET_IPV4_PRIVATE_0:2379" > /etc/kubernetes/etcd.config && echo "ETCD_LISTEN_PEER_URLS=https://$COREOS_PACKET_IPV4_PRIVATE_0:2380" >> /etc/kubernetes/etcd.config && echo "ETCD_LISTEN_METRICS_URLS=http://$COREOS_PACKET_IPV4_PRIVATE_0:2381" >> /etc/kubernetes/etcd.config'
[Install]
- RequiredBy=etcd-member.service
+ RequiredBy=etcd.service
- name: coreos-metadata.service
enable: true
contents: |
@@ -265,7 +265,7 @@ storage:
# Rejoin a cluster as fresh node when etcd cannot join
# (e.g., after repovisioning, crashing or node being down).
# Set ExecStopPost=-/opt/etcd-rejoin to run when etcd failed and
- # use env vars of etcd-member.service.
+ # use env vars of etcd.service.
# Skip if not provisioned
if [ ! -d "/etc/ssl/etcd/" ]; then exit 0; fi
# or got stopped.
@@ -297,13 +297,14 @@ storage:
etcdctl member add "$ETCD_NAME" --peer-urls="$ETCD_INITIAL_ADVERTISE_PEER_URLS" $ARGS
# Join fresh without state
mv /var/lib/etcd "/var/lib/etcd-bkp-$(date +%s)" || true
- if [ -z "$(grep ETCD_INITIAL_CLUSTER_STATE=existing /etc/systemd/system/etcd-member.service.d/40-etcd-cluster.conf)" ]; then
- echo 'Environment="ETCD_INITIAL_CLUSTER_STATE=existing"' >> /etc/systemd/system/etcd-member.service.d/40-etcd-cluster.conf
+ install -m 700 -o etcd -g etcd -d /var/lib/etcd
+ if [ -z "$(grep ETCD_INITIAL_CLUSTER_STATE=existing /etc/kubernetes/etcd.env)" ]; then
+ echo ETCD_INITIAL_CLUSTER_STATE=existing >> /etc/kubernetes/etcd.env
# Apply change
systemctl daemon-reload
fi
# Restart unit (yes, within itself)
- systemctl restart etcd-member &
+ systemctl restart etcd &
- path: /var/lib/iptables/rules-save
filesystem: root
mode: 0644

packet: fix wrong etcd settings

The rkt-based etcd-member service that is part of Flatcar used a unit
drop-in	file but the new etcd service uses an environment file and
requires the folder to be set up with certain permissions.