KubeStack-GitOps Made Fast!

Nicholas Samuel
Geek Culture
Published in
5 min readJun 19, 2021

--

An Open Source GitOps Framework.

Image by Author

Introduction

With the increased reliance on Cloud Providers, deployment of services within containers is a big topic today. The process of maintaining containers can be cumbersome, and that is why we use container orchestrators like Kubernetes. AWS, Google, and Azure provide Kubernetes as a managed service but getting a fully functional cluster and creating a GitOps workflow behind it can be intense if done through coding.

If you’ve ever worked with Kubernetes, you must have encountered the challenges of deploying your app from scratch repeatedly. Although Helm charts tried to make it easier, they did not bring a perfect automation for this. It can be more comfortable if configurations stored in a Git repository are automatically deployed whenever a change is made to it. Thanks to KubeStack, a new open-source framework that will help Kubernetes (K8s) users to build infrastructure automation. In this article, I will be giving my honest opinion about this framework from what I’ve experienced when using it.

Understanding KubeStack

KubeStack is a GitOps framework that integrates Kustomize and Terraform to help teams building infrastructure automation for Kubernetes to enjoy the benefits of frameworks. The KubeStack framework natively integrates with the Terraform ecosystem. It maintains a number of Terraform modules and a Terraform provider for integrating Terraform and Kustomize.

KubeStack comes with a number of features that make it unique from other automation frameworks. Some of these features include high speed of application development, providing tested Terraform modules for reuse, and enabling a stable GitOps workflow for teams. Kubestack also integrates with the leading cloud providers like Azure, Google Cloud Platform, and AWS (Amazon Web Services). It comes with Terraform providers for the clouds to manage K8s clusters. These include AKS for Azure, GKE for Google, and EKS for Amazon.

Image Source: www.dev.to

KubeStack comes with an extensive documentation that guides you on how to install and use it. In the next section, I will be taking you through the process of installing KubeStack. I will also be sharing my experience when I tested Kubestack using the AWS Cloud Provider.

Installing KubeStack

Let me take you through the 3 steps required to install KubeStack:

Step 1: Develop Locally

This step is entirely local and does not need any cloud resources. It gives the developer an opportunity to try the configuration in a local environment to simulate the actual cloud configuration. This feature is one of the greatest elements in KubeStack. It can be very useful to you if you are working with multiple environments such as Dev, Prod, and QA.

When doing some provisioning tasks, you’ve to make a number of iterations before you can get it right. KubeStack’s local development environment enables you to iterate over the same results to be used in the production environment. What makes this feature even better is that it automatically updates as changes are made, and gives immediate feedback, without having to wait for CI/CD pipeline runs each time.

KubeStack’s local development environment also helps developers reduce their cloud costs as they don’t have to interact with the cloud provider to identify and fix misconfigurations. It also means that the developer won’t have to worry about errors that may occur when deploying changes to the cloud.

I set the local environment using the KinD (Kubernetes in Docker) technique where Kubernetes nodes run locally as Docker containers.

Image by Author

From the above image, it took me only 175 seconds to build my local configurations during the initial phase. Subsequent builds took much less time than the initial build.

Image by Author

This shows that KubeStack is a fast and efficient GitOps framework.

Step 2: Provision Infrastructure

If you are satisfied with Kubestack’s performance in the local development stage, you can move it to the cloud provider infrastructure of choice. You can choose AWS, Azure, or Google.

This step involves:

  1. Setting up authentication.
  2. Provisioning the remote state.
  3. Bootstrapping your infrastructure.
  4. Setting up DNS.

Kubestack comes with a special container that can be used for bootstrapping cloud infrastructures. The container also makes it easy to provide prerequisites like the cloud provider CLI tools.

In this step, you have to create a GitOps repository and set up authentication methods. Terraform requires a remote state to run CI/CD, hence, you must also set this. I created an AWS S3 bucket and configured Terraform to use it for remote state. I also created two workspaces namely ops and apps.

Image by Author

Once done with making the changes, you should exit the bootstrap container and commit them to git.

Step 3: Setup Automation

This step involves creating the automation process by adding the pipeline and implementing the GitOps workflow. The automation process involves:

  1. Pushing your repository.
  2. Setting up pipeline credentials.
  3. Adding the pipeline file.
  4. Following the GitOps process.

It was easy for me to follow the above 4 steps. I created a new repository and then pushed my local repository into it. I then set up the pipeline credentials using base64 and created the pipeline for the GitOps flow. It was easy for me to add, commit, and push the pipeline.

I finally managed to push the changes to the remote repository and the pipeline changes were shown after a pull request. It was easy and faster for me to deploy Kubernetes clusters in AWS.

The KubeStack documentation provided all the steps and commands required to set up KubeStack and my work was just to follow. The pipeline file was also provided.

KubeStack: Final Thoughts

I had a good experience using KubeStack. From local development to setting up automation, the process was easy and faster. The steps provided on KubeStack’s online documentation made it even easier for me. By setting up your repository to automatically trigger pipeline runs, you will save a lot of time that is required to perform deployments. I will recommend KubeStack to any individual working on Kubernetes projects. It will make your work easier and faster!

--

--