If you wanted to dive into the world of managing Kubernetes at scale, Rancher is a great solution. But how and where do you get started? What if I told you there was a ridiculously quick way to get started with rancher? And by ridiculously quick I mean in under a minute. Here we go!
I’ve been a Mac person for about 20 years but given the corporate prevalence of Windows (and some cases Linux) I needed a way to standardize how I develop and run code. The best solution I’ve found so far for local development is multipass from Canonical, the folks that brought you Ubuntu. It is the fastest and most seamless way to run Ubuntu VMs on any operating system. Create, run, manage, and destroy VMs at will with only a few commands. Naturally, multipass was my first option for a local Rancher instance.
Multipass and Docker
I will not go into multipass in this blog post, but this handy snippet is what I use for pretty much all new VMs. The reason I keep this handy (I even have a macro for it) is almost everything I do these days is based on Docker. I use --cloud-init
to install docker during creation and I’m off to the races
multipass launch --cloud-init - --disk 20G --mem 4G --cpus 2 --name docker-rancher <<EOF
groups:
- docker
snap:
commands:
- [install, docker]
runcmd:
- adduser ubuntu docker
EOF
Run that command in your terminal and you’ll have a VM with Docker installed in under a minute.
multipass shell docker-rancher
to open the VMs shell.
Installing Rancher
Installing rancher is just as easy following “Getting Started with Rancher in 2 Easy Steps” from their official page. Step 1 is what we have done above, “prepare a Linux Host”
Step 2 is what we’ll execute in the VM. Since we added a docker user to our VM, we do not need to run docker with elevated privileges (e.g. sudo)
docker run --privileged -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher
Execute that command and a few seconds later you have a fully functioning rancher instance in a local VM. It does not get much easier than that!
Learning Docker
If you’re looking to get started with Docker locally, use the same snippet! The Rancher part is the only thing specific to this effort. If you’re looking to get started with Docker in general, check out my Getting Started with Docker post.