{"id":698,"date":"2018-10-26T07:39:38","date_gmt":"2018-10-26T07:39:38","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw93\/?p=698"},"modified":"2018-10-26T07:42:33","modified_gmt":"2018-10-26T07:42:33","slug":"using-vagrant-to-emulate-rancher-environments","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/10\/26\/using-vagrant-to-emulate-rancher-environments\/","title":{"rendered":"Using Vagrant to Emulate Rancher Environments"},"content":{"rendered":"<p>I spend a large amount of my time helping clients implement Rancher<br \/>\nsuccessfully. As Rancher is involved in just about every vertical, I<br \/>\ncome across a large number of different infrastructure configurations,<br \/>\nincluding (but not limited to!) air-gapped, proxied, SSL, HA Rancher<br \/>\nServer, and non-HA Rancher Server.<\/p>\n<h2>Scenario &amp; Criteria<\/h2>\n<p>What I wanted was a way to quickly emulate an environment to allow me to<br \/>\nmore closely test or replicate an issue. Now this could be done in a<br \/>\nnumber of ways, but the solution I wanted had to meet the following<br \/>\ncriteria:<\/p>\n<ul>\n<li>Run locally \u2014 Yes, it can be done in the cloud, but running<br \/>\nservices in the cloud costs money, so I wanted to keep the cost<br \/>\ndown.<\/li>\n<li>Be local host OS agnostic \u2014 So others can use it, I didn\u2019t<br \/>\nwant to tie it to Windows, MacOS or Linux.<\/li>\n<li>Emulate multiple infrastructure scenarios \u2014 As in the criteria<br \/>\nabove, but I must also be able to use it as a basis for doing local<br \/>\napplication development and testing of containers.<\/li>\n<li>Minimise bandwidth<\/li>\n<li>Be easy to configure \u2014 So that anyone can use it.<\/li>\n<\/ul>\n<h2>The Solution<\/h2>\n<p>To fulfill the first two criteria, I needed a hypervisor (preferably<br \/>\nfree) that could run on all platforms locally. Having had a reasonable<br \/>\namount of experience with<br \/>\n<a href=\"https:\/\/www.virtualbox.org\/wiki\/Downloads\">VirtualBox<\/a> (and it meeting<br \/>\nmy preferably free criterion), I decided to use it. The third criterion<br \/>\nwas to allow me to emulate environments locally that had the following<br \/>\nconfigurations:<\/p>\n<ul>\n<li>Air gap \u2014 Where there was no connection to the internet to<br \/>\ninstall Rancher Server and nodes<\/li>\n<li>Proxied \u2014 Where the Internet access was via a proxy server<\/li>\n<li>SSL \u2014 Where the connection to the Rancher Server SSL<br \/>\nterminated<\/li>\n<li>HA \u2014 The ability to stand up Rancher Server in a HA<br \/>\nconfiguration with an externalized database and a configurable<br \/>\nnumber of nodes<\/li>\n<\/ul>\n<p>To meet the fourth criterion to minimise bandwidth, I decided to run a<br \/>\nregistry mirror. It allowed me to destroy the setup and start afresh<br \/>\nquickly as all the VMs had Docker engine set to pull via the mirror. Not<br \/>\nonly does it save bandwidth, but it also significantly speeds up<br \/>\nrebuilds. Files for the mirror persist to the local disk to preserve<br \/>\nthem between rebuilds. For the final criterion of easy configuration, I<br \/>\ndecided that I was going to use Vagrant. For those reading who haven\u2019t<br \/>\nused Vagrant:<\/p>\n<ul>\n<li>It\u2019s open-source software that helps you build and maintain<br \/>\nportable, virtual software development environments.<\/li>\n<li>It provides the same, easy workflow regardless of your role as a<br \/>\ndeveloper, operator, or designer. It leverages a declarative<br \/>\nconfiguration file which describes all your software requirements,<br \/>\npackages, operating system configuration, users, and more.<\/li>\n<li>It works on Mac, Linux, Windows, and more. Remote development<br \/>\nenvironments force users to give up their favorite editors and<br \/>\nprograms. Vagrant works with tools on your local system with which<br \/>\nyou\u2019re already familiar.<\/li>\n<\/ul>\n<p>After you <a href=\"https:\/\/www.vagrantup.com\/\">download Vagrant<\/a>, you can<br \/>\nspecify that it consumes its config from a separate file. For this<br \/>\nsetup, all configurable options are externalized into a config.yaml<br \/>\nfile that is parsed at startup. This means that you can configure and<br \/>\nuse it without having to have a deep, technical understanding of<br \/>\nVagrant. I also added an NFS server to the solution, running on the<br \/>\nmaster node so that services could be tested with persistent storage.<br \/>\nSo, what does the final solution look like?<br \/>\n<a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/11\/06070805\/localranchervagrant.png\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/11\/06070805\/localranchervagrant-1024x253.png\" alt=\"\" \/><\/a><br \/>\nThe master node runs a bunch of supporting services like MYSQL and<br \/>\nHAProxy to help all of this hang together. In true Docker style, all of<br \/>\nthese supporting services are containerised!<\/p>\n<h2>Minimum Setup<\/h2>\n<p>To run this solution, the setup will create a minimum of three VMs.<br \/>\nThere is a master, a minimum of one Rancher Server, and one node. Below<br \/>\nis an example of the config.yaml file with the main parts that you<br \/>\nwill change highlighted:<br \/>\n<a href=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/10\/06093755\/Vagrant-config.jpg\"><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/10\/06093755\/Vagrant-config-761x1024.jpg\" alt=\"\" \/><\/a><br \/>\nYou can find more detail on the config options in our <a href=\"https:\/\/github.com\/rancher\/vagrant\">repository for<br \/>\nthis setup<\/a>.<\/p>\n<h2>Quick Start<\/h2>\n<p>For those of you wanting a Quick Start, you need the following software<br \/>\ninstalled:<\/p>\n<ul>\n<li>VirtualBox \u2014 If you don\u2019t already have it installed, you can<br \/>\n<a href=\"https:\/\/www.virtualbox.org\/wiki\/Downloads\">download VirtualBox<br \/>\nhere<\/a>.<\/li>\n<li>Vagrant \u2014 <a href=\"https:\/\/www.vagrantup.com\/downloads.html\">Download it<br \/>\nhere<\/a>.<\/li>\n<li>Git \u2014 If you don\u2019t have a Git client for version control, you<br \/>\ncan <a href=\"https:\/\/git-scm.com\/downloads\">download one here<\/a>.<\/li>\n<\/ul>\n<p>Then, it is as simple as dropping to a command prompt and running the<br \/>\nfollowing commands:<\/p>\n<p>git clone https:\/\/github.com\/rancher\/vagrant<br \/>\ncd vagrant<br \/>\nvagrant up<\/p>\n<p>Rancher Server will start running Cattle with three nodes. This Quick<br \/>\nStart also supports <a href=\"http:\/\/rancher.com\/rancher2-0\/\">Rancher 2.0<\/a>, so if<br \/>\nyou want to check out the Tech Preview with the minimum of effort, run:<\/p>\n<p>git clone https:\/\/github.com\/rancher\/vagrant<br \/>\ncd vagrant<br \/>\ngit checkout 2.0<br \/>\nvagrant up<\/p>\n<p>Thanks to my colleague James, for helping me enhance this solution to<br \/>\nwhat it has become.<\/p>\n<h3>About the Author<\/h3>\n<p><img decoding=\"async\" src=\"http:\/\/cdn.rancher.com\/wp-content\/uploads\/2017\/11\/21103711\/ChrisUrwin-300x286.jpg\" alt=\"\" \/><\/p>\n<p>Chris Urwin works<br \/>\nas a field engineer for Rancher Labs based out of the UK. He spends his<br \/>\ndays helping our enterprise clients get the most out of Rancher, and his<br \/>\nnights wishing he had more hair on his head!<\/p>\n<p><a href=\"https:\/\/rancher.com\/rancher-vagrant\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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. Scenario &amp; Criteria What I wanted was a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw93\/index.php\/2018\/10\/26\/using-vagrant-to-emulate-rancher-environments\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using Vagrant to Emulate Rancher Environments&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-698","post","type-post","status-publish","format-standard","hentry","category-kubernetes"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/698","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/comments?post=698"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/698\/revisions"}],"predecessor-version":[{"id":703,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/698\/revisions\/703"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/media?parent=698"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/categories?post=698"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/tags?post=698"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}