Skip to content

Commit

Permalink
Update start script to wait for ipamd health
Browse files Browse the repository at this point in the history
Wait for the ipamd health check to be SERVING before copying in the CNI
binary and config file. #282
  • Loading branch information
Claes Mogren authored and mogren committed Aug 1, 2019
1 parent 31821f9 commit 79fd64a
Showing 1 changed file with 39 additions and 11 deletions.
50 changes: 39 additions & 11 deletions scripts/install-aws.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
#!/usr/bin/env bash
echo "===== Starting installing AWS-CNI ========="
sed -i s/__VETHPREFIX__/${AWS_VPC_K8S_CNI_VETHPREFIX:-"eni"}/g /app/10-aws.conflist
cp /app/aws-cni /host/opt/cni/bin/
cp /app/portmap /host/opt/cni/bin/
cp /app/aws-cni-support.sh /host/opt/cni/bin/
cp /app/10-aws.conflist /host/etc/cni/net.d/

if [[ -f /host/etc/cni/net.d/aws.conf ]]; then

grpcHealthCheck () {
/app/grpc_health_probe -addr 127.0.0.1:50051
}

waitIPamDServing () {
until grpcHealthCheck; do
echo "Waiting for ipamd health check";
sleep 1;
done
}

main () {
# Remove old config files that might have been baked into older AMIs
if [[ -f /host/etc/cni/net.d/aws.conf ]]; then
rm /host/etc/cni/net.d/aws.conf
fi
fi

# Copy standard files
cp /app/aws-cni-support.sh /host/opt/cni/bin/
cp /app/portmap /host/opt/cni/bin/

echo "===== Starting amazon-k8s-agent ==========="
/app/aws-k8s-agent &

# Check ipamd health
echo "Checking if ipamd is serving"
waitIPamDServing

echo "===== Copying AWS CNI plugin and config ========="
sed -i s/__VETHPREFIX__/"${AWS_VPC_K8S_CNI_VETHPREFIX:-"eni"}"/g /app/10-aws.conflist
cp /app/aws-cni /host/opt/cni/bin/
cp /app/10-aws.conflist /host/etc/cni/net.d/

# Check that ipamd is healthy, exit if the check fails
while grpcHealthCheck; do
sleep 10;
done
}

echo "===== Starting amazon-k8s-agent ==========="
/app/aws-k8s-agent
main

0 comments on commit 79fd64a

Please sign in to comment.