top of page
Search
Writer's pictureTuyen Nguyen

Testkube - Guide to Kubernetes-Native Test Automation


Testkube is an open-source, Kubernetes-native testing framework designed to help teams run, orchestrate, and manage tests within Kubernetes environments. It acts as a testing layer on top of Kubernetes, allowing developers and DevOps teams to integrate, automate, and manage tests as part of their CI/CD workflows in cloud-native environments.


Key features of Testkube


Kubernetes-Native Testing

Testkube is designed specifically for Kubernetes, enabling tests to run as Kubernetes jobs. This approach simplifies running tests in any Kubernetes cluster and utilizes Kubernetes’ native capabilities for scaling, isolation, and resource management.


Test Orchestration

With Testkube, you can orchestrate a wide range of test types and frameworks, from unit and integration tests to end-to-end (E2E) tests. It supports common testing frameworks like Postman, Cypress, JMeter, and more.


CI/CD Integration

Testkube integrates seamlessly with CI/CD tools (e.g., Jenkins, GitHub Actions, GitLab CI) and can be triggered as part of the CI/CD pipeline, automating testing as new changes are pushed to a cluster.


Multiple Test Types and Frameworks

Testkube can handle various testing types, including API tests, performance tests, functional tests, and load tests. It is compatible with many popular testing tools, making it versatile for multiple use cases.


Centralized Test Management

Testkube provides a centralized platform to manage all tests, schedules, configurations, and results, enabling easy access to logs and reports across all test executions.


Distributed Test Execution

By leveraging Kubernetes’ architecture, testkube enables distributed test execution, allowing for multiple tests to run simultaneously, speeding up the testing process.


Built-in Reporting and Observability

Testkube captures logs, metrics, and detailed execution results, allowing teams to analyze test performance, monitor errors, and gather insights to improve their test suites over time.


How Testkube works


Test Execution

Tests are configured and stored in Testkube, and when executed, Testkube runs them as Kubernetes jobs within the cluster. This allows it to use Kubernetes’ containerized environment for test isolation and consistency.


Components

Testkube consists of components:

  • API Server: Acts as the control plane, receiving requests and commands.

  • Testkube Agent: The agent responsible for orchestrating and managing test jobs in the Kubernetes cluster.

  • Dashboard and CLI: Provides a user-friendly interface to manage and monitor tests.


Event-driven and Scalable

Testkube can be configured to run tests based on events, making it ideal for use in microservices and event-driven architectures. Additionally, the framework is scalable, allowing teams to manage thousands of test cases across clusters.


Enough of what it is and its advantages, let's start our journey with how to set up the Testkube.


Testkube Cloud Architecture

Testkube contains two sub-systems:

  • A Control Plane which includes the Dashboard, Storage for Results/Artifacts, Cluster Federation, etc

  • An Agent running in your cluster that manages Testkube resources, runs tests, gathers results, etc.

The two sub-systems can be deployed in variety of ways to give flexibility into where your tests are executed and where test logs and artifacts are stored.


To our best simplicity but still remains our control in Testkube, it is recommended to try with Testkube Cloud. Testkube Cloud has a control plane that is managed by the Testkube team. You only have to run a stateless agent which makes operations a breeze.

Testkube Cloud Architecture - testkube.io

For more details, Deployment Architecture.


Install Docker

As a prerequisite, we should have Docker is installed in our system. An easy way to install Docker is using the Docker Desktop appropriate for our operating system and processor.

We need Docker Desktop to run local Kubernetes clusters using Docker containers as nodes.


Install kubectl

kubectl allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs. For more information including a complete list of kubectl operations, see the kubectl reference documentation.


Installing on Windows

Installing on MacOS

Installing on Linux


Install kind

kind is a tool for running local Kubernetes clusters using Docker container "nodes".

kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI.


Installing on Windows

Installing on MacOS


Verify the successful installation:

$ kind version

Create cluster

Create a local Kubernetes cluster with default configuration:

$ kind create cluster

There are some options we can try while creating a cluster:


Create cluster with configuration file

Create cluster with specific version of Kubernetes image


Check the created cluster:

$ kind get cluster
kind-testkube

Check if the corresponding container is created:

$ docker ps
CONTAINER ID   IMAGE                  COMMAND                  CREATED
1ae8811317d6   kindest/node:v1.30.0   "/usr/local/bin/entr…"   3 hours ago

Or via Docker Desktop application:


Or get confirmation of the nodes via kubectl:

$ kubectl get nodes
NAME                          STATUS   ROLES           AGE   VERSION
kind-testkube-control-plane   Ready    control-plane   24h   v1.30.0

Install testkube CLI

The Testkube CLI enables you to manage your Testkube installation and interact with resources like creating Test Workflows, starting test executions, managing triggers, and more. For a complete list of commands, refer to the CLI Commands Reference.


Installing on Windows

Installing on MacOS


Validate the successful installation:

$ testkube version

For other systems/methods, Testkube CLI.


Install testkube

Since we decided to follow Testkube Cloud Architecture, we need to sign in to Testkube Cloud first.


Then it will ask us to create new environment, let's select option with having a K8s cluster or Docker available:


After providing your own preferred name for environment, we will be provided with cli command to set up Testkube Agent:


Upon successful set up:


⚠️ Caution: Cannot upgrade Testkube

⚠️ Caution: Issue with setting pro environment context


Define the test workflow

Test Workflow is a cutting-edge and highly effective method for defining and executing tests within Kubernetes clusters. With its versatility, Test Workflow offers the following advantages:

  • Running tests with different versions of testing tools and dependencies.

  • Defining multiple steps within test execution workflows.

  • Gaining greater control over test execution, including resource allocation and setup/tearDown processes.

  • Customizing tool-specific commands and arguments to suit your needs.


It is using specific workflow language wrapped in a CRD. Below is high-level structure:


Example - Test Workflow for Postman

The Postman collection for running below TestWorkflow is from Testkube repository:


Example - Test Workflow for k6

Below is an example for k6 load test, which we just add inline test for simplicity.


Run the Test Workflow - using Dashboard

Since we are utilizing Test Cloud Architecture with Test Agent hosted in our own cluster, we fortunately have 2 options for running our Test Workflows. The first option is using the Dashboard in Testkube Cloud.


We need to log into your Testkube Cloud and navigate to Test Workflow to create a new one:


And there are 4 selections:

Create from Wizard

Start from an example

Combine existing Workflows

Import from YAML


Run the Test Workflow - using Testkube CLI

Since we have Test Agent in our created cluster, we are allowed to create new workflow yaml as CRD and use command to add and run it.

  • Create a yaml file, such as my-workflow.yaml.

  • Copy and paste the content of workflow (we can use the two provided examples above).

  • Execute the below command:

$ kubectl apply -f my-workflow.yaml && kubectl testkube run tw my-test --watch

$ kubectl apply -f <yaml file of workflow> && kubectl testkube run tw <name of test worfklow> --watch
  • View the status and logs from the Workflow as it is executing.


Check the past executions

We have both Dashboard in Testkube Cloud and Testkube CLI so we have 2 options to check the past executions.


Using Dashboard

Using CLI


Integrate with CI/CD Pipelines

Testkube Workflow execution can easily be integrated in your CI pipelines, run on a cron schedule or trigger on a Kubernetes event.


Trigger from CI/CD

Trigger on a schedule

Trigger on a Kubernetes event

More Triggers


Conclusions

In summary, Testkube brings powerful, Kubernetes-native automation to testing workflows, allowing teams to manage, scale, and streamline testing directly within the cluster. With support for various frameworks and easy CI/CD integration, Testkube turns testing into an efficient part of continuous delivery, enhancing collaboration and quality across applications.


As Kubernetes leads modern cloud infrastructure, Testkube is an essential tool for scalable, automated testing. Embrace Testkube, and simplify your path to robust, integrated Kubernetes-native testing.


What are we expecting in the next blog post?


It will be an extremely interesting topic - Approach to GitOps Cloud Native Testing with Testkube. Please stay tuned for it!!!



94 views0 comments

Recent Posts

See All

Comments


bottom of page