DEV Community

Philipp Strube for Kubestack

Posted on

Localhost EKS development environments with EKS-D and Kubestack

Today Amazon announced EKS Distro, or EKS-D for short. A Kubernetes distribution making the same release artifacts used by Amazon EKS available to everyone.

This allows teams to use the exact same bits and pieces that power EKS, to build clusters for anything from integration tests to on-premise use-cases. As a launch partner, I got access to EKS-D in advance to integrate it into Kubestack’s local development environments.

Kubestack is about providing the best GitOps developer experience for Terraform and Kubernetes, from local development, all the way to production.

Because I believe platform engineers automating Kubernetes deserve the same great developer experience that application engineers building applications on top of Kubernetes already have.

To achieve this, the Kubestack framework integrates all the moving pieces from Terraform providers, to resources, and modules into a GitOps workflow ready for day-2 operations.

On top of the reliable automation to propose, validate and promote infrastructure changes, Kubestack is focused on giving platform teams a modern developer experience to iterate quickly using local development environments.

Now, whenever Kubestack simulates an EKS cluster locally, it uses EKS-D to do so. Let’s take a look at how Kubestack’s infrastructure automation from local development to production works.

Local Development

Imagine you’re tasked with provisioning the Prometheus operator to deploy a Prometheus instance and configuring it to scrape the metrics from your team’s application for each environment.

If you’re like me, it may take a few iterations to get the label and namespace selectors in the Prometheus resource just right and configure the RBAC for the Prometheus instance’s service account. Especially RBAC is notorious for taking a bit of trial and error for many folks to get right.

Using Kubestack’s local development environment, you can iterate on the exact same manifests that will later be used in production. The local development environment automatically updates as you make changes, and provides immediate feedback, without waiting minutes for CI/CD pipeline runs every time. It’s just like in the infamous XKCD comic, except it’s applying, not compiling.

applying, not compiling, but you get the idea

All you have to do to get started on this task is change into your checkout of the infrastructure repository and run one kbst CLI command. Then you’re all set to work on the Prometheus manifests.

$ kbst local apply
...
Switched to workspace "loc".
...
Apply complete! Resources: 14 added, 0 changed, 0 destroyed.
2020/11/18 12:55:53 #### Watching for changes
Enter fullscreen mode Exit fullscreen mode

The new EKS-D integration means the local environment is now even closer to the EKS production environment. And fewer differences between environments reduce the risk that promoting a change fails. This is also why Kubestack uses inheritance between environments. Differences are sometimes necessary, but configuration inheritance makes them explicit.

Environment Promotion

Eventually, I’ll have the monitoring setup working locally and it’s time to push my changes and ask for a peer-review. This is the first step where the Kubestack GitOps workflow kicks in.

There are two things to review to decide if you want to apply this change. Your code changes of course, and the terraform plan provided by Kubestack’s pipeline for every branch.

If the reviewers requires changes, you can push additional commits to the branch and the pipeline will run terraform plan again. When your team approved, merge the change into master.

This triggers the pipeline and applies the merged changes to the ops environment. A terraform plan is not enough to ensure that the changes will apply correctly. That’s why Kubestack uses the ops environment, to validate the configuration change against real cloud infrastructure. The ops environment does not run applications, so that teams can feel confident to merge infrastructure changes at any time, without worrying about blocking team members or breaking applications.

Finally, if the change to ops applied successfully, the pipeline will additionally provide a terraform plan to show the required changes for the apps environment. The additional plan helps teams decide if they want to promote this change into the apps environment now.

Having a reliable workflow is crucial for teams to trust their automation. Kubestack, by combining purpose built Terraform modules and its proven triggers helps teams build infrastructure automation that is ready for day-2 operations.

Get Started

If you’ve made it this far and want to learn more, you can get started with the Kubestack framework by following the tutorial.

Top comments (0)