Rancher OS is a very lightweight Linux distribution built around Docker. The OS itself weighs in around 20MB. This tutorial will get you up and running with a persistent Rancher OS using all of the available disk space. Cloud-config instructions are not included in this doc.
- Create a new Custom PXE start up script and name it RancherOS.
- Paste in the script template below.
- Generate a new secure password and replace CHANGETHIS.
- Save the script.
- Deploy a new server using the ISO Custom option and select iPXE and your new RancherOS script from the dropdown.
- Wait several minutes for the installation to complete.
- Login with rancher@xxx.xxx.xxx.xxx and your new password.
- Setup is complete. At this point you can start configuring your rancher server or bootstrap it server to another rancher server.
Script template
#!ipxe
# Boots RancherOS in Ramdisk with persistent storage on disk /dev/vda
# Location of Kernel/Initrd images
set base-url http://releases.rancher.com/os/latest
kernel ${base-url}/vmlinuz rancher.state.dev=LABEL=RANCHER_STATE rancher.state.autoformat=[/dev/vda] rancher.password=CHANGETHIS
initrd ${base-url}/initrd
boot
Security note
While setting the rancher.password
kernel parameter works, the Rancher team advises not doing this in production. Kernel parameters will be readable by any container launched, including unprivileged ones. A better method would be to add an SSH key via cloud-config. Specifying a cloud-config file is done by adding a kernel parameter. An example of this parameter is shown below. You would need to replace the URL in the parameter to the location of your cloud-config file.
rancher.cloud_init.datasources=[url:http://example.com/cloud-config]
Here is an example cloud-config file template that includes SSH keys. This file is in YAML format. Replace the SSH keys in the template with one or more of your own keys.
#cloud-config
ssh_authorized_keys:
- ssh-rsa AAA...ZZZ example1@rancher
- ssh-rsa BBB...ZZZ example2@rancher
More information on using cloud-config with Rancher OS is provided in the official documentation.
Want to contribute?
You could earn up to $300 by adding new articles
Suggest an update
Request an article