Skip to content

Instantly share code, notes, and snippets.

@orlea orlea/userdata.sh
Last active Aug 30, 2019

Embed
What would you like to do?
EC2 SpotInstanceからdocker swarmに自動参加, EFSマウント
#!/bin/bash
apt update
DEBIAN_FRONTEND=noninteractive apt upgrade -yq
apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt update
apt install prometheus-node-exporter docker-ce docker-ce-cli containerd.io nfs-common -y
mkdir /mnt/efs
echo "<AWS-EFS-Address>:/ /mnt/efs nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport nofail 0 0" >> /etc/fstab
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport <AWS-EFS-Address>:/ /mnt/efs
docker swarm join --token <token> <manager-ip:port>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.