configure flannel via systemd unit
send flannel json to etcd via systemd unit rather than cloud-init script
This commit is contained in:
parent
4e1b7aebd1
commit
ef48d08f20
46
fragments/flannel-config.service.yaml
Normal file
46
fragments/flannel-config.service.yaml
Normal file
@ -0,0 +1,46 @@
|
||||
#cloud-config
|
||||
merge_how: dict(recurse_array)+list(append)
|
||||
write_files:
|
||||
- path: /usr/local/bin/flannel-config
|
||||
owner: "root:root"
|
||||
permissions: "0755"
|
||||
content: |
|
||||
#!/bin/sh
|
||||
|
||||
: ${FLANNEL_JSON:=/etc/sysconfig/flannel-network.json}
|
||||
|
||||
if ! [ -f "$FLANNEL_JSON" ]; then
|
||||
echo "ERROR: missing network configuration file" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [ "$FLANNEL_ETCD" ] && [ "$FLANNEL_ETCD_KEY" ]; then
|
||||
echo "ERROR: missing required configuration" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "creating flanneld config in etcd"
|
||||
while ! curl -sf -L $FLANNEL_ETCD/v2/keys${FLANNEL_ETCD_KEY}/config \
|
||||
-X PUT --data-urlencode value@${FLANNEL_JSON}; do
|
||||
echo "waiting for etcd"
|
||||
sleep 1
|
||||
done
|
||||
- path: /etc/systemd/system/flannel-config.service
|
||||
owner: "root:root"
|
||||
permissions: "0644"
|
||||
content: |
|
||||
[Unit]
|
||||
After=etcd.service
|
||||
Requires=etcd.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
EnvironmentFile=/etc/sysconfig/flanneld
|
||||
ExecStart=/usr/local/bin/flannel-config
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
runcmd:
|
||||
- systemctl enable flannel-config
|
||||
- systemctl start --no-block flannel-config
|
||||
|
@ -30,15 +30,3 @@ cat >> $FLANNEL_JSON <<EOF
|
||||
}
|
||||
EOF
|
||||
|
||||
# wait for etcd to become active (we will need it to push the flanneld config)
|
||||
while ! curl -sf -o /dev/null $FLANNEL_ETCD/v2/keys/; do
|
||||
echo "waiting for etcd"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# put the flannel config in etcd
|
||||
echo "creating flanneld config in etcd"
|
||||
curl -sf -L $FLANNEL_ETCD/v2/keys/coreos.com/network/config \
|
||||
-X PUT \
|
||||
--data-urlencode value@/etc/sysconfig/flannel-network.json
|
||||
|
@ -195,11 +195,17 @@ resources:
|
||||
group: ungrouped
|
||||
config: {get_file: fragments/configure-kubernetes-master.sh}
|
||||
|
||||
configure_flannel:
|
||||
write_flannel_config:
|
||||
type: "OS::Heat::SoftwareConfig"
|
||||
properties:
|
||||
group: ungrouped
|
||||
config: {get_file: fragments/configure-flannel.sh}
|
||||
config: {get_file: fragments/write-flannel-config.sh}
|
||||
|
||||
flannel_config_service:
|
||||
type: "OS::Heat::SoftwareConfig"
|
||||
properties:
|
||||
group: ungrouped
|
||||
config: {get_file: fragments/flannel-config.service.yaml}
|
||||
|
||||
enable_services:
|
||||
type: "OS::Heat::SoftwareConfig"
|
||||
@ -240,7 +246,8 @@ resources:
|
||||
- config: {get_resource: kube_user}
|
||||
- config: {get_resource: configure_kubernetes}
|
||||
- config: {get_resource: enable_services}
|
||||
- config: {get_resource: configure_flannel}
|
||||
- config: {get_resource: write_flannel_config}
|
||||
- config: {get_resource: flannel_config_service}
|
||||
- config: {get_resource: kube_examples}
|
||||
- config: {get_resource: cfn_signal}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user