关注微信公众号
第一手干货与资讯
加入官方微信群
获取免费技术支持
I spend a large amount of my time helping clients implement Rancher successfully. As Rancher is involved in just about every vertical, I come across a large number of different infrastructure configurations, including (but not limited to!) air-gapped, proxied, SSL, HA Rancher Server, and non-HA Rancher Server.
What I wanted was a way to quickly emulate an environment to allow me to more closely test or replicate an issue. Now this could be done in a number of ways, but the solution I wanted had to meet the following criteria:
To fulfill the first two criteria, I needed a hypervisor (preferably free) that could run on all platforms locally. Having had a reasonable amount of experience with VirtualBox (and it meeting my preferably free criterion), I decided to use it. The third criterion was to allow me to emulate environments locally that had the following configurations:
To meet the fourth criterion to minimise bandwidth, I decided to run a registry mirror. It allowed me to destroy the setup and start afresh quickly as all the VMs had Docker engine set to pull via the mirror. Not only does it save bandwidth, but it also significantly speeds up rebuilds. Files for the mirror persist to the local disk to preserve them between rebuilds. For the final criterion of easy configuration, I decided that I was going to use Vagrant. For those reading who haven’t used Vagrant:
After you download Vagrant, you can specify that it consumes its config from a separate file. For this setup, all configurable options are externalized into a config.yaml file that is parsed at startup. This means that you can configure and use it without having to have a deep, technical understanding of Vagrant. I also added an NFS server to the solution, running on the master node so that services could be tested with persistent storage. So, what does the final solution look like? The master node runs a bunch of supporting services like MYSQL and HAProxy to help all of this hang together. In true Docker style, all of these supporting services are containerised!
To run this solution, the setup will create a minimum of three VMs. There is a master, a minimum of one Rancher Server, and one node. Below is an example of the config.yaml file with the main parts that you will change highlighted: You can find more detail on the config options in our repository for this setup.
For those of you wanting a Quick Start, you need the following software installed:
Then, it is as simple as dropping to a command prompt and running the following commands:
git clone https://github.com/rancher/vagrant cd vagrant vagrant up
Rancher Server will start running Cattle with three nodes. This Quick Start also supports Rancher 2.0, so if you want to check out the Tech Preview with the minimum of effort, run:
git clone https://github.com/rancher/vagrant cd vagrant git checkout 2.0 vagrant up
Thanks to my colleague James, for helping me enhance this solution to what it has become.
Chris Urwin works as a field engineer for Rancher Labs based out of the UK. He spends his days helping our enterprise clients get the most out of Rancher, and his nights wishing he had more hair on his head!