Kwok: simulate nodes with “Kubernetes without Kubelet” for controller testing

Kwok: simulate nodes with “Kubernetes without Kubelet” for controller testing

A Kubernetes SIG (Special Interest Group) has introduced Kwok (Kubernetes Without Kubelet) in order to make testing a Kubernetes controller easier. Kwok simulates nodes, pods and other Kubernetes resources without really provisioning them, which means a large deployment can be tested on a local PC without the delay or expense of real infrastructure.

“You can simulate thousands of nodes on your laptop without significant consumption of CPU or memory resources,” states the official post. It is early days for the project, the current release being 0.1.0. Kwok started as a migration of two previous projects, called fake-kubelet and fake-k8s, used for testing the control plane under pressure.

Kwok at runtime

The project consists of two tools, kwok, which simulates thousands of nodes, and kwokctl, which is a command-line interface (cli) to create and manage kwok clusters. It works with standard Kubernetes tools such as kubectl and helm. Installation is a matter of running a Kwok container in Docker, or there are binaries for Linux, macOS and Windows available from the Kwok repository on GitHub.

The primary use cases for Kwok are learning, development and testing. The tool includes the ability to simulate node failures, high loads, or network issues, in order to investigate behavior in these different conditions.

The main limitation is that this is a simulation. “Kwok doesn’t accurately reflect the performance or behavior of real nodes under various workloads or environments. Instead, it approximates some behaviors using simple formulas,” says the team. It also lacks security, and “assumes that all requests from the kube-apiserver are authorized and valid,” making it impossible to test security-related issues.

There is a Kwok roadmap which lists a number of issues and forthcoming features, with anticipated future versions including 0.2, 0.3 and eventually 1.0.

One example of Kwok use is here where IBM research scientist Sunyanan Choochotkaew describes an issue with an open source Container Network Interface (CNI) operator she is working on. “When the cluster becomes larger, the controller can become a bottleneck,” she writes. “With kwok, we can create a number of fake nodes and set a Multi-CNI daemon DaemonSet to be scheduled to those fake nodes.” She concluded that “with some modifications and stub Pod implementation, kwok can become very useful in scalability test.”