arrow Back to all posts

Building the lightest-weight Kubernetes dev ephemeral environments

Kardinal is a framework for creating extremely lightweight development environments within a shared Kubernetes cluster.

Building the lightest-weight Kubernetes dev ephemeral environments

We’re excited to introduce Kardinal, an open-source tool that’s designed to make development and test environments for Kubernetes-deployed applications as lightweight as possible. If you manage multiple application deploys across dev, test, and QA, or you’re spinning up expensive development sandboxes, Kardinal can cut down resource usage and time-to-test by over 90%.

Kardinal makes development easier

Testing new features often means spinning up dedicated application environments, which can be both costly and resource-draining. Kardinal flips the script by letting you create temporary, tailored environments that are dynamically managed. This means you get to focus on what really matters without the hassle of managing extra overhead.

Kardinal redefines development environments by introducing the concept of "flows": dedicated paths through your Kubernetes cluster that act as ephemeral environments. These flows are created on-demand to deploy and test the specific versions of services relevant to feature development. In traditional development setups, managing and testing new features often involves deploying numerous resources that other developers have already deployed in some form or fashion, leading to inefficiencies and high resource usage.

These inefficiencies are addressed by deploying the minimum necessary resources related to the feature under development, and reusing any other resource that’s already been deployed in another workflow. This strategy optimizes resource usage. Whether you need a single-service test or a full application flow with isolated state, Kardinal’s flexible architecture ensures you have the tools to test and develop efficiently.

Some of the benefits of this approach:

  • Ephemeral environments: Spin up a new environment exactly when you need it, and just as quickly spin it down when you’re done.
  • Minimal resource usage: Only deploy the services you’re actively working on. Kardinal takes care of the rest, so you don’t waste resources.
  • Flexible flow types: Whether you need to test a single service or an entire application, Kardinal has you covered:
    • Single-service flows: Perfect for when you’re tweaking just one service.
    • Multi-service flows: Ideal for when your feature involves multiple services.
    • State-isolated flows: Great for features that need their own databases or caches.
    • Full application flows: For those times when you need end-to-end testing with full isolation.
  • Cost savings: Kardinal can help you save big by avoiding unnecessary resource duplication. Check out the cost calculator here.
  • Open source: Kardinal is open source, so use it however fits best within your workflows

How Kardinal works

Kardinal is designed to streamline dev and testing environments for your Kubernetes-deployed application.

Here’s a quick look at how it operates:

Kardinal manager + Kardinal kontrol (control plane)

At the heart of Kardinal are Kardinal kontrol and Kardinal manager. Kardinal kontrol is a cloud-hosted control plane that maintains information about topology and resources in your cluster. Kardinal manager is deployed as a service inside your cluster. It maintains a live cluster topology from the control plane and uses routing rules with Istio, to ensure that traffic is routed properly within your environment.

Managing state with plugins

To handle state in your cluster, Kardinal uses a flexible plugin system. These plugins help manage and share state across different environments or set up new “dev” versions of stateful services as needed. Here’s a breakdown:

  • Stateful Service Plugins: These are for managing state in services running on Kubernetes, like Postgres databases.
  • External Service Plugins: These handle state for external services not managed by Kubernetes, such as Stripe or Twilio.

By using these plugins, Kardinal can efficiently set up and tear down flows, reusing existing state or creating new instances as needed.

Plugins operate by applying patches on top of your baseline Kubernetes manifest, which appropriately modify the deployment of the stateful service, or services that depend on external services, for the new flow. For example:

  • You can modify a microservice deployment spec to change an API key environment variable to access a separate dev account for an external service.
  • You can also run scripts within plugins to do things like provision new state, for example to deploy a dev database seeded with data for testing purpose.

Visualizing a cluster

Kardinal includes a frontend that provides a visual representation of your cluster. This frontend connects to the Kardinal manager to retrieve info, show service dependencies, and manage multi-user scenarios. Currently, the control plane is cloud-hosted, but an on-premise option is in the works.

You can read more about our high level concepts and architecture in our documentation.

How to use Kardinal

Getting started with Kardinal is straightforward.

Step 1: Install Kardinal

To install Kardinal, run the following command:

curl get.kardinal.dev -sL | sh

Step 2: Set up a development Kubernetes cluster

All you need is a Kubernetes cluster with Istio enabled, and kubectl installed on your machine, pointing to your cluster. If you need help with this, read more here

Step 3: Deploy the Kardinal Manager to your cluster

Make sure that kubectl is pointing to your cluster, and then run the following command:

kardinal manager deploy kloud-kontrol

Once installed, follow the demo below, or check out our docs on creating your first flow.

Let’s dive into a demo

If you want to see Kardinal in action, here’s how to get started with a demo environment using an online boutique store as an example.

Step 1: Deploy the demo app

In a new terminal window, deploy the demo app via Kardinal:

curl https://raw.githubusercontent.com/kurtosis-tech/new-obd/main/release/obd-kardinal.yaml > ./obd-kardinal.yaml
kardinal deploy -k ./obd-kardinal.yaml

Set up the gateway:

kardinal gateway prod

You can view the frontend of the demo app by going to the local host link that the gateway prints.

Feel free to click around, add items to your cart, and shop!

If you want to see the architecture of your application, the Kardinal dashboard will show you it along with any logical environments (flows) you create on top of it.

To view the dashboard, run:

kardinal dashboard

Click "Traffic configuration" in the sidebar to see the architecture.

Step 2: Create a lightweight development environment

Let's deploy a dev version of the frontend that's adding bolder style to the website, this modification is contained into a single frontend image using an image we've prepared for this demo:

kardinal flow create frontend kurtosistech/frontend:demo-frontend

This command will output a URL that you can use to access the frontend of the development environment. You can view the frontend of the application by going to the URL provided.

To interact with the dev version, first stop your previous gateway (if it's still running)--currently you can only run one gateway at a time in this demo, and run the following to forward the dev demo application port to a URL you can access:

 kardinal gateway <flow-id>

Notice that there are already items in your cart in the development environment. We've configured the development "flow" in this demo to run with it's own database which is seeded with test data.

To inspect the resources in your cluster, and see how Kardinal is reusing resources from your stable environment in the dev environment, go to the dashboard again:

kardinal dashboard

and click on the "Traffic configuration" sidebar item.

Step 3: Clean up your development flow

The flow_id is in the output of the kardinal flow create command, but if you've lost it, you can get it again by running:

kardinal flow ls

When you're done with your development flow, you can delete it by running:

kardinal flow delete <flow_id>

And you're done! 🥳

Helpful resources

If you want to learn more about Kardinal, get additional support, or test it out without installing anything—here are some helpful links:

  • Explore our docs to learn more about how Kardinal works.
  • Ask questions and get help in our community forum.
  • Test Kardinal without installing via our playground.