<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Wulf-Thilo Schreiter on Medium]]></title>
        <description><![CDATA[Stories by Wulf-Thilo Schreiter on Medium]]></description>
        <link>https://medium.com/@wt.schreiter?source=rss-9f9da02f0845------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qJtWnjx8sPZ02DaUTvrXng.jpeg</url>
            <title>Stories by Wulf-Thilo Schreiter on Medium</title>
            <link>https://medium.com/@wt.schreiter?source=rss-9f9da02f0845------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 00:48:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wt.schreiter/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Boosting up your Rancher and build infrastructure as code with cattlectl]]></title>
            <link>https://medium.com/bitgrip/boosting-up-your-rancher-and-build-infrastructure-as-code-with-cattlectl-66ef7ea920eb?source=rss-9f9da02f0845------2</link>
            <guid isPermaLink="false">https://medium.com/p/66ef7ea920eb</guid>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[bitgrip]]></category>
            <category><![CDATA[eisern]]></category>
            <category><![CDATA[rancher]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Wulf-Thilo Schreiter]]></dc:creator>
            <pubDate>Mon, 25 Feb 2019 09:48:49 GMT</pubDate>
            <atom:updated>2019-02-25T09:48:49.758Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bUHCrRNRju-bqivw4DhVAQ.jpeg" /></figure><p>Rancher is great in managing all your Kubernetes clusters. With <a href="https://github.com/bitgrip/cattlectl">cattlectl</a> you now have the power to manage your Rancher projects as code.</p><p>When I first came along Rancher I asked a friend if he had any experience using it. His answer was surprising at first:</p><blockquote>“Rancher is great for creating and managing Kubernetes clusters but I have no clue how to automate it.”</blockquote><p>Actually, we were looking for a platform to manage all the Kubernetes clusters for the different environments of our customer. So Rancher was a natural fit and we started to find a way to automate it.</p><h3>A journey to automation</h3><p>Reading the documentation we came across the <a href="https://github.com/rancher/cli">rancher cli</a> which is shipped with Rancher. That sounds like a good way to automate our projects.</p><p>Using rancher at the command line enables you to do direct CRUD on projects, namespaces, apps, … It also enables you to query for running workload on your projects.</p><p><strong>But …</strong></p><p>Far from enabling us to manage all the required Rancher resources. There are no storage classes, no docker credentials, no … Also the commands on the rancher command line are not idempotent which forces you to do that in your automation scripts.</p><p>Please don’t get me wrong. The rancher command line is very helpful for simple adjustments and task which are not repeated. It’s just not targeting any automation.</p><p><strong>Other possibilities …</strong></p><p>Rancher comes with a powerful REST API which enables you to do everything you can do in the UI by setting up curl scripts or creating <a href="https://www.getpostman.com/">Postman </a>collections. <br>Do you know any developer happy with such an automation? I don’t.</p><h3>Don’t expect others to do what you are not willing to do on your own.</h3><p>After we decided to create an automation tool for Rancher we started to look for the what and how.</p><p>The “what” was simple: <em>Let’s have the functionality provided by kubectl but for Rancher. Start by having the functionality of </em><em>apply.</em></p><p>Regarding the “how” we got some help by the fact that Rancher is providing a <a href="https://github.com/rancher/types">complete API client</a> written in go.</p><p>So we started to develop <a href="https://github.com/bitgrip/cattlectl">cattlectl</a>. The current version is <a href="https://github.com/bitgrip/cattlectl/releases/tag/v1.0.0">1.0.0</a> .<br>It comes with a DSL to describe Rancher resources, which is currently supporting project descriptors to converge all resources needed by a<br>Rancher project.</p><h3>Let’s do a simple project to verify if we really have infrastructure as code.</h3><p>We are going to set up a Wordpress installation using thewordpress chart from the <a href="https://github.com/rancher/charts">Rancher 2 Catalog</a>. The installation shall have a Rancher 2 project my-wordpress-blog with a namespace my-wordbress-blog-web and of course do the wordpress app itself.</p><p>To set up our cattlectl environment we have to download the latest release of cattlectl from <a href="https://github.com/bitgrip/cattlectl/releases">https://github.com/bitgrip/cattlectl/releases</a>. And create a configuration file ~/.cattlectl.yaml with the access data for our Rancher.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/49fdf982e6c81f12ea414379e833b7a0/href">https://medium.com/media/49fdf982e6c81f12ea414379e833b7a0/href</a></iframe><p>Now we have configured cattlectl how to talk with the Rancher API. If we want to change the used cluster we can set the environment variable RANCHER_CLUSTER_NAME or change the value of rancher.cluster_name in the ~/.cattlectl.yaml.</p><p>We are following the concept of “convention over configuration” for cattlectl which means that the command apply expects a file project.yaml and an optional file values.yaml in the current directory. We could point cattlectl to other files, but we will stick to the convention for this article.</p><p>values.yaml is providing default values to be used for template expressions in project.yaml.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/487d9117e7401c7b74d7b5dc51e9c92f/href">https://medium.com/media/487d9117e7401c7b74d7b5dc51e9c92f/href</a></iframe><p>All this values have corresponding environment variables to change the values. E.g.: wordpress.username has the corresponding environment variable WORDPRESS_USERNAME.</p><p>Now we can create the project descriptor project.yaml. We want to build the attributes:</p><ul><li>project name: my-wordpress-blog</li><li>one namespace: my-wordpress-blog-web</li><li>one app: blog-wordpress</li></ul><p>We can use <a href="https://golang.org/pkg/text/template/">golang template</a> expressions to use the values from values.yaml.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7aaf81b8dc6e32d839c34a560b371f80/href">https://medium.com/media/7aaf81b8dc6e32d839c34a560b371f80/href</a></iframe><p>We will care for the ingress configuration in a second step. For now, we want to have the mariadb and wordpress services up and running.</p><p>This is now simply done by applying our project descriptor using cattlectl apply .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e862f0a562cfa318fb82c566e725a257/href">https://medium.com/media/e862f0a562cfa318fb82c566e725a257/href</a></iframe><p>We now have a new project my-wordpress-blog in our cluster. If we open the “Catalog Apps” tab of this project we see our created app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*HmeqP0eY0ydl7gU76ZSnkg.png" /></figure><p>This app does not have any public access URL and is not a very high value for a user. But it has already two deployments. One is the MariaDB serving as database backend and the wordpress deployment configured to use the MariaDB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*BfldzqSpurm8790IRkZe0Q.png" /></figure><p>Next step is to enable the ingress to the wordpress service reachable on a xip.io hostname.<br>By default Rancher is configured to generate xip.io conforming ingress hostnames if the ingress.host[*].name is xip.io. For our project, the generated hostname will be xip.io-blog-wordpress.my-wordpress-blog-web.XXX.XXX.XXX.XXX.xip.io where XXX.XXX.XXX.XXX will be the IP used by Rancher to access your cluster.</p><p>To activate ingress we need to uncomment these two lines in our project.yaml.</p><pre>    ingress.enabled: true<br>    &#39;ingress.hosts[0].name&#39;: xip.io</pre><p>And run again cattlectl apply.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/681efc5d8f7acd46f6fe03e75d889d3c/href">https://medium.com/media/681efc5d8f7acd46f6fe03e75d889d3c/href</a></iframe><p>As visible from the log there is no new project or namespace created but an upgrade for the app blog-wordpress performed.</p><p>If we check the “Catalog Apps” page again we’ll see an access point 80/http for our app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0LxC3EVLId09v4GHF5ekdA.png" /></figure><p>If we follow that link we’ll be presented with the default landing page of our new wordpress installation.</p><h3>Where to go from here?</h3><p>You are welcome to read our <a href="https://github.com/bitgrip/cattlectl">documentation on GitHub</a>.</p><p>We already deliver cattlectl as command line tools for Linux and Mac OS but we do not check if it is also working on Windows.</p><p>For CI scenarios we do provide a docker image <a href="https://hub.docker.com/r/bitgrip/cattlectl">bitgrip/cattlectl</a> and do use it in our own pipelines.</p><p>We plan to create a set of different usage examples with commonly used CI servers. E.g.:</p><ul><li>Jenkins</li><li>Travis CI</li><li>GitLap CI</li></ul><p>We plan to support more descriptor types and want to work on the completion to the Rancher model. E.g.: Manage Catalogs or Clusters using descriptors.</p><p>If you have any issues or feature request to the tool or its documentation feel free to <a href="https://github.com/bitgrip/cattlectl/issues">drop us a line</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66ef7ea920eb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bitgrip/boosting-up-your-rancher-and-build-infrastructure-as-code-with-cattlectl-66ef7ea920eb">Boosting up your Rancher and build infrastructure as code with cattlectl</a> was originally published in <a href="https://medium.com/bitgrip">Bitgrip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>