In order to configure my Auto Scaling Group as I mentioned here, I needed a base AMI. When it comes to imaging, there is a lot of debate over whether it is better to “bake” what you need into the image or to “bootstrap” when your image is launching. I am not going to debate that here. But I will indicate what I baked in to my AMI vs what I am bootstrapping.
Baked Into the Image
- Started with an existing AMI for Ubuntu 14
- Installed Docker
- Installed AWS CLI
- Installed the Docker Certificate for authenticating to the Docker Repository.
Script for Auto Scaling Group
In order to build your script you will need to know the link to the Rancher Agent install. You can get this by going to Infrastructure in you Rancher installation and click on add host.
Then look in section 5 of that screen. Copy that script. You will add it to your Launch Configuration script.
Below is an example of the script I ended up with. Items I included:
- Change SSH port to 2222
- Install the rancher agent. (Note that I added the –e CATTLE_HOST_LABELS=RancherPool=yes section to the script. This will add a label to the host indicating that this is a RancherPool. I have another “pool” that is dedicated to my Graylog Server. So that section would be different for those hosts.)
- Mount the GlusterFS File share. I am using this for persistent data for my containers.
- Login to the Docker Registry. (I am not actually 100% sure this is needed, but I assume after the instance is launched, Rancher is going to begin pushing docker containers and I wanted to be sure that they would not fail to launch.
NOTE: Replace line 6 with your agent install script. Remember to add the Host Label section.