cowboy-server
Configuration files for a RancherOS deployment
NOTE: I ended up abandoning RancherOS, so this content can be considered obsolete and abandoned.
Installing RancherOS
Links
Create the Cloud-Config file
First, we need a Cloud-Config file, mostly to bring in the SSH public key(s) for password-less authentication.
-
Create a
cloud-config.yml
file with these lines:#cloud-config ssh_authorized_keys:
-
For each workstation that you'll want to use to connect to the server via SSH:
-
Create SSH key:
ssh-keygen -f ~/.ssh/cowboy_rsa -C $COMPUTERNAME@cowboy
-
Add the following to the workstation's
~/.ssh/config
file (notice the second line is indented by 2 spaces):Host cowboy IdentityFile ~/.ssh/cowboy_rsa
-
Copy the contents of the
/.ssh/cowboy_rsa.pub
file and paste it in on a new line in thecloud-config.yml
file, prefixing with 2 spaces, a hyphen, and a space. Example:- ssh-rsa AAA...
-
-
Configure the host name by inserting this as the 2nd line of
cloud-config.yml
:hostname: cowboy
Now we have a cloud-config.yml
that looks suspiciously like the one in this repository.
Configure a DHCP reservation
This depends heavily on your home network, but most consumer routers allow you to reserve an IP address for a given network adapter, keying off of its MAC address.
For the purposes of a running example, I will be using 192.0.2.162
(taken from RFC 5737: IPv4 Address Blocks Reserved for Documentation
) as the IP address I've reserved for the server.
HOSTS
file
Edit your You'll want to do this on every workstation you'll be using to access your Rancher server.
On Windows, it's under C:\Windows\System32\drivers\etc\hosts
and you'll need to use an editor running in elevated (administrator) mode.
-
Append the following line:
192.0.2.162 cowboy
...you'll notice that's the IP address we reserved in the previous section.
Boot the RancherOS installer
You can download the rancheros.iso
file from the RancherOS releases page. I configured a USB storage device with it using UNetbootin.
-
Boot from the USB storage device.
-
Record what storage device is attached where; both of these commands will give you information about what storage devices are connected, how big they are and what partitions might already exist on them:
sudo fdisk -l sudo parted -l
...this will inform what the destination parameter (
-d
) will take as a value for the upcomingros install
command. -
Install! You'll notice that the URL that is provided to the
-c
parameter is that of the file from this repository, which needs to be retrievable anonymously.sudo ros install -c https://raw.githubusercontent.com/olivierdagenais/cowboy-server/main/cloud-config.yml -d /dev/sda
If you are installing from USB-based storage and it fails right away with:
ERRO[0000] Failed to get boot iso: stat /dev/sr0: no such file or directory There is no boot iso drive, terminate the task FATA[0000] Failed to run install err="stat /dev/sr0: no such file or directory"
...then you might be hitting #2241 (affects version 1.5.0), so try this workaround:
sudo mkdir /dev/sr0
...and run the install command again.
You'll be prompted to install and again to reboot.
-
Connect via SSH using one of your workstations:
ssh rancher@cowboy
...unfortunately, as much as I tried to get
agetty
to include the public key fingerprints in the TTYs, I was not able to and thus you'll have to trust that your first connection is safe and accept the key fingerprint that's presented.
Set up ZFS
-
Install the ZFS service as per Using ZFS:
-
Download a container to compile ZFS for Linux:
sudo ros service enable zfs
...this will print something like:
Pulling zfs (docker.io/rancher/os-zfs:v0.7.13-1)... (...)
...and take a minute or three.
-
Install the kernel headers, download ZFS on Linux, build & install it:
sudo ros service up zfs
...wait another few minutes.
-
-
Configure first ZFS pool, with inspiration from ZFS Concepts and Tutorial:
-
Cheat-sheet of commands to query the state while performing the following operations:
sudo zpool list sudo zpool status sudo zfs list
-
Create "internal" pool of type
raidz1
(needs 3 disks):sudo zpool create -m /mnt/internal internal raidz1 /dev/sdb /dev/sdc /dev/sdd
-
Stop Docker and delete its old/current folder:
sudo system-docker stop docker sudo rm -rf /var/lib/docker/*
-
Create a file system for Docker:
sudo zfs create internal/docker sudo zfs list -o name,mountpoint,mounted
-
Configure Docker for ZFS:
sudo ros config set rancher.docker.storage_driver 'zfs'
-
Configure Docker to use the new mount point:
sudo ros config set rancher.docker.graph /mnt/internal/docker
-
Start Docker:
sudo system-docker start docker
-
Confirm it's working:
docker info
... you should see something like:
Storage Driver: zfs Zpool: internal Zpool Health: ONLINE Parent Dataset: internal/docker Space Used By Parent: 53196
-
-
Configure second ZFS pool:
-
Create "external" pool of type
mirror
:sudo zpool create -m /mnt/external external mirror /dev/sde /dev/sdf
-
Confirm it's working:
sudo touch /mnt/external/success ls -l /mnt/external
-
Set up Rancher Server
Now that we have RancherOS running, let's deploy the web-based UI from our workstation.
Links
From an SSH prompt
-
Install the
rancher-server
servicesudo ros service enable rancher-server
-
Start the
rancher-server
service:sudo ros service up rancher-server
-
Confirm the service is listening:
netstat -l -t -n
...this will print something like:
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 :::22 :::* LISTEN tcp 0 0 :::8080 :::* LISTEN
...notice the
:::8080
?
From a web browser
- Navigate to http://cowboy:8080 and you should be running as
admin
as there is no access control on by default. - You'll be asked if you want to enable anonymous collection of data. That's up to you.
- It turns out there are no hosts configured, either, which is likely being brought to your attention in a banner at the top. Click Add a host
- Select Custom
- The only field I had to fill in was the public IP because I'm adding the RancherOS server as a host. Keeping with the example, that would be
192.0.2.162
. - Click the Copy to Clipboard link near step 5.
Back to the SSH prompt
-
Paste the command you copied in the previous step. Mine looked like this:
sudo docker run -e CATTLE_AGENT_IP="192.0.2.162" --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.11 http://cowboy:8080/v1/scripts/VERY_LONG_KEY
-
Wait a few minutes
Back to the web browser
If we now go to Infrastructure > Hosts, we should see a single host and instances of "starting" will eventually change to displaying an IP address.