Skip to content

Obviate.io

To anticipate and prevent

  • Home
  • About Us
  • History
  • Privacy Policy
  • Toggle search form

User Data for automated RancherOS instances

Posted on 2016-04-27 By Jon No Comments on User Data for automated RancherOS instances

Rancher-Logo
Rancher-Logo

There are a lot of container management services poping up these days and right now Rancher is my choice in solutions (for the moment). One of the coolest accessories to go with this container ranch is RancherOS. The OS is purpose built to do nothing but Docker and, in fact, runs the few required system services in Docker as well. Comming in at a massive 27MB (For v0.4), it’s a perfect choice to run in AWS under something like spot instances and autoscaling. However, if you’re properly autoscaling — you need a way for your new hosts to join the RancherOS cluster… which is where user data (aka cloud-init) comes in.

rancher-create
rancher-create

The first step is to grab the command URL from your Rancher UI.

  • Login to Rancher
  • Infrastructure
  • Hosts
  • Add New
  • Custom
  • From step #5 on screen, grab the URL only. It looks something like: http://rancher.domain.tld/v1/scripts/F3somethingA6:14something00:S9something2Q

user-data
user-data

Now here’s where it gets really complicated. You’ll need to setup your spot instance requests or auto-scaling exactly as you normally do — but just add the following to the user data section (either via the UI or CLI):

#cloud-config
rancher:
  services:
    register:
  priviledged: true
  volumes:
  - /var/run/docker.sock:/var/run/docker.sock
  image: rancher/agent
  command: http://rancher.domain.tld/v1/scripts/F3somethingA6:14something00:S9something2Q

Now when the instances start, they should automatically register with your Rancher server. I’ve noticed it takes 5 minutes or so for the systems to register once they are fully started. Remember that the instances will show as running in AWS very quickly but that doesn’t mean RancherOS is actually ready to operate yet. On first boot it has to pull down all the system docker containers before it gets to pulling down and launching the agent.

via-api
via-api

For those that want to go full devops automation, asking the UI for a URL is sub-optimal. Fortunately anything you can do in the Rancher UI can be done via API. Access http://rancher.domain.tld/v1/registrationtokens and you’ll be able to pull down all details required for registration. The variables can then be easily passed into your automation solution of choice.

Remember: Treat your servers like cattle, not pets!

Containers Tags:Amazon Web Services, automation, AWS, AWS ECS, cli, Containers, DevOps, docker, k8s, kuberenetes, rancher, rancheros

Post navigation

Previous Post: A Kindle lover without a Kindle Oasis
Next Post: Good Bye Snowulf.com, Hello Obviate.io

More Related Articles

Welcome back! (To us) Site Maintenance
Roundup from AWS re:Invent Day 1 AWS
Super slick logging with PapertrailApp Cloud

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

April 2016
S M T W T F S
 12
3456789
10111213141516
17181920212223
24252627282930
« Mar   May »

Copyright © 2022 Obviate.io

Powered by PressBook Premium theme