<?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 zacanbot on Medium]]></title>
        <description><![CDATA[Stories by zacanbot on Medium]]></description>
        <link>https://medium.com/@zacanbot?source=rss-d5e1d2453f63------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DEsWRDnC6IHZH5hxkCUaHg.png</url>
            <title>Stories by zacanbot on Medium</title>
            <link>https://medium.com/@zacanbot?source=rss-d5e1d2453f63------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 08:00:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zacanbot/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[Kubernetes with Rancher on OpenStack]]></title>
            <link>https://medium.com/@zacanbot/kubernetes-with-rancher-on-openstack-f4bfb7985869?source=rss-d5e1d2453f63------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4bfb7985869</guid>
            <dc:creator><![CDATA[zacanbot]]></dc:creator>
            <pubDate>Mon, 13 Jul 2020 21:25:46 GMT</pubDate>
            <atom:updated>2021-11-12T14:07:19.837Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Rancher and friends" src="https://cdn-images-1.medium.com/max/988/1*yfQG1DofIJtb0ayE3_IYGw.png" /></figure><p><em>This article is outdated now with new versions of Rancher and the OpenStack Cinder CSI driver. Please refer to the official Rancher documentation.</em></p><p>Firstly, I would like to say thanks to <a href="https://medium.com/u/15de2ad110ce">Christian Frank</a> with his article <a href="https://medium.com/@chfrank_cgn/creating-a-kubernetes-cluster-on-openstack-with-rancher-6f15010cf31e">here</a> and also to the very nice write-up <a href="https://blog.vkhitrin.com/deploying-rancher-on-openstack/">here</a> on <em>vkhitrin.com</em> that started me on my journey to create a Kubernetes cluster on OpenStack-provided infrastructure. I also found the official Rancher documentation to be very concise and useful although somewhat sparse and challenging. In this article, I will report on my experience and the steps required to create an operational cluster that is integrated with the Cinder storage provider of OpenStack. The article assumes some basic Kubernetes and OpenStack knowledge.</p><h4>Why OpenStack and Rancher?</h4><p><a href="https://www.openstack.org/software/">OpenStack</a> is still a very popular open source cloud operating system provider used by many ISPs around the world, including <a href="https://www.computecanada.ca/">Compute Canada</a>, from where our infrastructure is provided. Many people also run OpenStack on bare metal servers to virtualize their own hardware resources.</p><p><a href="https://rancher.com/">Rancher</a> provides Kubernetes-as-a-service and provides an all-in-one solution to manage Kubernetes clusters. Their software is also free and open source and provides an amazing set of features on top of their own Kubernetes distro called Rancher Kubernetes Engine (RKE). The features I’m describing in this article were available in v2.4.3 of Rancher.</p><h4>From Start to Finish</h4><p>It is recommended that you obtain a wildcard certificate for your domain so that you can route traffic to IP addresses in your infrastructure. Let’s use <em>example.com </em>for our example setup. This article also assumes that you already have an OpenStack account that can connect to OpenStack’s Horizon web interface and have access to sufficient resources in OpenStack to run Rancher and your Kubernetes cluster. The instructions here are created for Ubuntu 18.04 images but you can serve any Linux distro from OpenStack and adapt the commands to your distro’s environment.</p><ol><li>Provision a VM for Rancher</li><li>Install K3s and MySQL</li><li>Install Rancher</li><li>Set up OpenStack integration</li><li>Create your Kubernetes cluster</li><li>Configure OpenStack Cinder storage</li></ol><h4>Getting Rancher up and running</h4><p>Create a publicly accessible VM in OpenStack that you can use to just run Rancher on. I recommend at least 8GB of RAM and 2 CPU cores. You need to expose SSH, HTTP and HTTPS ports in your security groups. You now have an option to install Rancher the easy way, or the flexible way. For production environments I recommend the latter but let’s start with the easy way.</p><p>SSH into your VM and install Docker by following the official instructions <a href="https://docs.docker.com/engine/install/ubuntu/">here</a> or just use these steps:</p><pre>sudo apt-get update<br>sudo apt-get -y install apt-transport-https \<br>    ca-certificates \<br>    curl \<br>    gnupg-agent \<br>    software-properties-common<br>sudo curl -fsSL <a href="https://download.docker.com/linux/ubuntu/gpg">https://download.docker.com/linux/ubuntu/gpg</a> | sudo apt-key add -<br>sudo add-apt-repository &quot;deb [arch=amd64] <a href="https://download.docker.com/linux/ubuntu">https://download.docker.com/linux/ubuntu</a> $(lsb_release -cs) stable&quot;<br>sudo apt-get update<br>sudo apt-get -y install docker-ce docker-ce-cli containerd.io<br>sudo usermod -G docker -a ubuntu</pre><p>Now simply run the following to spin up a Rancher container:</p><pre>docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --name=rancher-server rancher/rancher:latest --acme-domain rancher.example.com</pre><p>This is all you need! Make sure that <em>rancher.example.com</em> resolves to the VM’s IP address. It might be useful to tail logs in the container if you want to debug Rancher operations: docker logs rancher-server --since 10m -f</p><p>I would recommend that you look at the following steps if you’re considering setting up a production environment or want to promote your installation to production in the future. It involves setting up a Kubernetes cluster and installing Rancher into that cluster. Even though we will only do it on one node right now, it will be a simple upgrade to extend our Rancher cluster to three nodes for an HA (High Availability) environment.</p><p>You also have the option to store your cluster data in a MySQL database instead of the built-in distributed <em>etcd</em> solution. I will guide you through a local MySQL install here but keep in mind that you want a mirrored/replicated database if you want an HA setup.</p><pre>sudo apt-get install mysql-server</pre><p>Now we’ll install K3s, a very light-weight and performant Kubernetes distro from the Rancher folks that will host our Rancher application.</p><pre>sudo curl -sfL <a href="https://get.k3s.io/">https://get.k3s.io</a> | sh -s - server --datastore-endpoint=&quot;mysql://&quot; --flannel-backend host-gw</pre><p>The <em>datastore-endpoint</em> option tells K3s to use our local MySQL installation instead of the default <em>etcd</em> database, and that last option changes the default Flannel network from VXLAN to host-gw. As the names imply, that tells Flannel to set up layer 2 routing table entries for IPs and subnets instead of using a virtual VXLAN interface.</p><p>Copy the <em>kubeConfig</em> file, install Helm, add the Rancher and Jetstack repositories, and make sure your Kubernetes cluster is running and available.</p><pre>sudo cp /etc/rancher/k3s/k3s.yaml .kube/config<br>curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash<br>sudo helm repo add rancher-latest <a href="https://releases.rancher.com/server-charts/latest">https://releases.rancher.com/server-charts/latest</a><br>sudo helm repo add jetstack <a href="https://charts.jetstack.io/">https://charts.jetstack.io</a><br>sudo helm repo update<br>sudo kubectl create namespace cattle-system<br>sudo kubectl create namespace cert-manager<br>sudo kubectl get all --all-namespaces</pre><p>Install cert-manager and ensure it is ready.</p><pre>sudo kubectl apply --validate=false -f <a href="https://github.com/jetstack/cert-manager/releases/download/v0.15.0/cert-manager.crds.yaml">https://github.com/jetstack/cert-manager/releases/download/v0.15.0/cert-manager.crds.yaml</a><br>sudo helm install cert-manager jetstack/cert-manager --namespace cert-manager --version v0.15.0<br>sudo kubectl -n cert-manager rollout status deploy/cert-manager</pre><p>Now install Rancher and follow its rollout.</p><pre>sudo helm install rancher rancher-latest/rancher \<br>    --namespace cattle-system \<br>    --set hostname=rancher.example.com \<br>    --set ingress.tls.source=letsEncrypt \<br>    --set <a href="/service/mailto:letsEncrypt.email=zacanbot@gmail.com">letsEncrypt.email=me@example.com</a><br>sudo kubectl -n cattle-system rollout status deploy/rancher</pre><p>It is important to note what install parameters you pass to the Helm install command. You will need to use the exact same parameters when upgrading Rancher in the future. Just use <em>helm upgrade </em>instead of <em>helm install </em>after updating the Helm repo to upgrade in the future.</p><p>The Helm chart will create 3 replicas by default but if you’re on a single node, you can scale the deployment down with this command:</p><pre>sudo kubectl -n cattle-system scale --replicas 1 deploy/rancher</pre><p>Here is a useful kubectl command to tail the Rancher logs. It has helped me to debug when things went wrong during Rancher operations.</p><pre>sudo kubectl -n cattle-system logs -l app=rancher -f</pre><p>Go to <a href="https://rancher.example.com/">https://rancher.example.com</a> and log in and set the base URL by following the prompts. Congratulations, you now have a very capable Kubernetes management platform at your disposal! Let’s connect this to our OpenStack infrastructure.</p><h4>Getting OpenStack parameters</h4><p>Before we can start creating clusters and configuring nodes, we will need to gather specific information about our OpenStack environment to enable the integration with Rancher. We’ll need the following information:</p><ul><li>OpenStack username and password</li><li>User domain name</li><li>Project ID</li><li>Authentication URL</li><li>Router ID</li><li>Public Network ID</li><li>Private Network ID</li><li>Private Subnet ID</li><li>OpenStack Flavor Name</li><li>VM image name</li></ul><p>I’ll guide you through the process to get this information. The first step is to log into the Horizon web portal of your OpenStack provider (referred to as the OpenStack dashboard by many) and go to your project page. On the top right in the user drop-down menu you’ll be able to download your RC file v3. This file contains the OS_AUTH_URL, OS_PROJECT_ID, and OS_USER_DOMAIN_NAME.</p><p>Use the Project menu on the left and navigate to <em>Network </em>&gt; <em>Routers </em>and click on your router in the list. The ID on top is your Router ID and you’ll also be able to see the Public Network ID on this page under <em>External Gateway</em> divider. Record both IDs. Now go to <em>Network </em>&gt; <em>Networks </em>and click on your private network in the list (i.e. not the public one we just saw under <em>External Gateway</em> with the router). Record the Private Network ID. Now click on the <em>Subnet </em>tab and click on the subnet. The ID field on the top is the Private Subnet ID we are looking for.</p><p>To see your available VM images and flavors, go to <em>Compute </em>&gt; <em>Instances </em>and hit the <em>Launch Instance</em> button. Check the available images under the <em>Source</em> menu and flavors under the <em>Flavor</em> menu on the left of the <em>Launch Instance </em>form. Choose the flavor and source image you want to use for your Kubernetes nodes. You want to have images with enough ephemeral storage to install Kubernetes and PODs keeping in mind that actual data use through persistent volume claims will be mounted elsewhere.</p><h4>Create Security Groups</h4><p>Create a new security group called <em>k8s-node</em> with the following ports opened on the private network, so that nodes can talk to each other and to the Rancher server (which for us is also on the same subnet):</p><ul><li>ssh, http and https</li><li>2376 Docker TLS</li><li>2379 etcd</li><li>2380 etcd peer communication</li><li>6443 Kubernetes API</li><li>8472 Flannel VXLAN</li><li>10250 Kubelet</li><li>30000–32767 Nodeport port range</li></ul><p>You will also need to expose the Kubernetes API (6443) publicly on your master node or wherever your load balancer is. Please have a look <a href="https://rancher.com/docs/rancher/v2.x/en/installation/requirements/ports/">here</a> for a detailed description of port requirements.</p><h4>Setting up Rancher</h4><p>Log into your Rancher portal and go to the <em>Settings </em>menu and then select the <em>Features Flag</em> tab. Activate the <em>unsupported-storage-drivers </em>feature. This will enable the OpenStack storage class as an option. Also go to the <em>Tools</em> menu and select the <em>Node Drivers</em> tab. Activate the OpenStack node driver.</p><p>The next step is to create one or more node templates to specify the node parameters when you create nodes for your cluster. These templates are saved against your user account and are available for all your clusters. Click on your user icon in the top right and select the <em>Node Templates</em> option. Click <em>Add Template </em>and select the <em>OpenStack</em> box. You’ll be presented with a form with many parameters but you need only enter the following fields (substitute the values as necessary).</p><pre>&quot;authUrl&quot;: &quot;<a href="https://arbutus.cloud.computecanada.ca:5000/v3">https://os.example.com:5000/v3</a>&quot;,<br>&quot;domainName&quot;: &quot;MYOSDOMAIN&quot;, # Identity v3 Domain Name<br>&quot;flavorName&quot;: &quot;c8-60gb-186&quot;,<br>&quot;imageName&quot;: &quot;Ubuntu-18.04.3-Bionic-x64-2020-01&quot;,<br>&quot;netId&quot;: &quot;af61b790...6f8c99e6f&quot;, #Private Network<br>&quot;password&quot;: &quot;myOpenStackPwd&quot;<br>&quot;secGroups&quot;: &quot;default,k8s-node,k8s-master&quot;,<br>&quot;sshPort&quot;: &quot;22&quot;,<br>&quot;sshUser&quot;: &quot;ubuntu&quot;,<br>&quot;tenantId&quot;: &quot;91cef5...f09f9a9bf7&quot;,<br>&quot;username&quot;: &quot;myOpenStackUser&quot;</pre><p>Give your template a name and hit the <em>Create</em> button. We’re now ready to create our cluster.</p><h4>Create your RKE Cluster with Rancher</h4><p>I would recommend at this stage to open a terminal to the machine where Rancher is installed and use the command I specified above under the Rancher installation to tail the Rancher logs. Any problems during the cluster install will be highlighted in these logs. Also, it is cool to see what is actually involved when Rancher starts doing its magic to spin up a cluster!</p><p>Click on <em>Global</em> in the menu bar to go back to the home screen and then click the <em>Add Cluster</em> button on the top right. Select the OpenStack box under <em>New nodes in an infrastructure provider</em>. Give your cluster a name, your node pool a name prefix (Rancher will append a counter after this name), and select the node template in the dropdown box that you saved in your profile earlier. Also tick all three roles: <em>etcd, Control Plane, </em>and <em>Worker. </em>Then click the <em>Edit as YAML </em>to the right of <em>Cluster Options.</em></p><p>This is where we tell Rancher how to integrate with OpenStack. Replace the <em>rancher_kubernetes_engine_config</em> element:</p><pre>...<br>rancher_kubernetes_engine_config:<br>  ignore_docker_version: true<br>  addon_job_timeout: 30<br>  authentication:<br>    strategy: x509<br>    sans:<br>      - 200.10.20.100 # Your load balancer IP<br>      - alpha.example.com # Your public DNS name<br>  cloud_provider:<br>    name: &quot;openstack&quot;<br>    openstackCloudProvider: <br>      global: <br>        auth-url: &#39;<a href="https://os.example.com.ca:5000/v3&#39;">https://os.example.com.ca:5000/v3&#39;</a> # Auth URL<br>        domain-name: MYOSDOMAIN # Identity v3 Domain Name<br>        tenant-id: 91cef58...f9a9bf7 # Project ID<br>        username: &#39;myOSuser&#39;<br>        password: &#39;myOSpassword&#39;<br>      block_storage:<br>        bs-version: v2<br>        ignore-volume-az: true<br>        trust-device-path: false<br>      load_balancer:<br>        lb-version: v2<br>        floating-network-id: 6621...a881e # Public Network (LB)<br>        subnet-id: 0d49...f232017 # Private Subnet<br>        use-octavia: true<br>      route:<br>        router-id: 515bde...1470876f4<br>...</pre><p>Before we continue, let’s discuss a few notes on the configuration options above. The <em>sans </em>option under Authentication is critical for the K8s certificate authority to create certificates that potential clients will trust. Add all (or at least one) endpoint that you will use to connect to your cluster there or some clients might not trust the CA (gitlab.com is one such an example).</p><p>If you are going to do your own load balancing or you don’t have access to the OpenStack load balancer configuration, then completely leave out the <em>load_balancer </em>and <em>route </em>blocks. This will allow you to configure <a href="https://metallb.universe.tf/">MetalLB</a> or a similar load balancer in your cluster. However, if you do want to use the OpenStack LB, then you have to specify at least the <em>subnet-id</em> for the <em>load_balancer</em> option and also the <em>router-id</em> like I did above. You may also specify the <em>floating-network-id</em>, which is the network on which the LB will be dishing out IP addresses.</p><p>Now hit the <em>Create </em>button on the bottom and watch the Rancher log tail for ~10 minutes to see what Rancher does to create the new cluster in your OpenStack infrastructure. If you don’t have OpenStack load balancing enabled, you can manually go and set the public IP (the one specified above under <em>authentication/sans</em>) on the node in the OpenStack Horizon portal as soon as Rancher spins it up.</p><h4>Configuring OpenStack Cinder volumes</h4><p>Once the configuration is complete, click on the cluster in the Rancher portal Clusters page. Navigate to <em>Storage</em>&gt;<em>Storage Classes</em>. Click on <em>Add Class</em> and choose <em>OpenStack Cinder Volume</em> as <em>Provisioner </em>for your storage class. I also had to specify the <em>Availability Zone</em> manually to <em>nova</em>. Also remember to set this class as the default storage class once it is available by clicking on the menu dots to the right of the storage class.</p><p>If you did not enable experimental features for your Rancher installation, the Cinder driver won’t be available but you can still add the storage class manually by using the <em>Import YAML</em> button and the following definition:</p><pre>apiVersion: storage.k8s.io/v1<br>kind: StorageClass<br>metadata:<br>  name: cinder<br>provisioner: kubernetes.io/cinder<br>reclaimPolicy: Delete<br>parameters:<br>  availability: nova<br>allowVolumeExpansion: true</pre><h4>Final Thoughts</h4><p>Your cluster is ready now to start serving some workloads. Rancher can now spin up more nodes and your cluster can automatically create Cinder volumes for pods’ persistent volume claims — no need to go into the OpenStack dashboard anymore. I did not cover Ingress and load balancing here but I plan to do that in a next article along with GitLab integration as there are some caveats with OpenStack configurations that don’t have access to the OpenStack load balancing service.</p><p>Rancher introduces a new concept that is not part of Kubernetes called <a href="https://rancher.com/docs/rancher/v2.x/en/project-admin/">projects</a> to manage Kubernetes workloads. It is important to understand <em>projects </em>to use Rancher to its full potential. I urge you to read up, and also to experiment: the Rancher tool is very intuitive and most features can be discovered by exploring the interface.</p><p>Enjoy the flexibility and ease of use of the Rancher Kubernetes cluster management goodies on your OpenStack infrastructure!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4bfb7985869" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>