MCPcopy Index your code
hub / github.com/Kong/kubernetes-testing-framework

github.com/Kong/kubernetes-testing-framework @v0.51.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.51.0 ↗ · + Follow
502 symbols 2,058 edges 96 files 284 documented · 57% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ktf-banner

tests codecov Go Report Card GoDoc License

Kong Kubernetes Testing Framework (KTF)

Testing framework used by the Kong Kubernetes Team.

Originally this testing framework was developed for the Kong Kubernetes Ingress Controller (KIC) but is now used across multiple Kubernetes projects.

This testing framework supports the following use cases:

  • provide Kubernetes testing environments pre-deployed with addons for manual and automated testing via CLI or Golang
  • provide unit testing utilities for Golang tests which focus on Kubernetes
  • provide integration testing utilities for Golang tests which test Kubernetes controllers and other applications

Requirements

  • Go v1.19.x+
  • Linux (Mac/Windows not currently supported)

Usage

This framework can be used via command-line interface or as a Golang library.

Command Line Tool

This project provides a command-line tool named ktf which can be used to build Kubernetes testing environments.

Install

If you have Golang installed locally you can install with go:

$ go install github.com/kong/kubernetes-testing-framework/cmd/ktf@latest

Otherwise you can use the shell script to install the latest release for your operating system:

$ curl --proto '=https' -sSf https://kong.github.io/kubernetes-testing-framework/install.sh | sh

If neither of these options suits you then you can install manually by navigating to the RELEASES page and downloading the binary for your platform directly.

Provisioning Kubernetes Testing Environments

You can deploy a testing environment with the following command:

$ ktf environments create --generate-name

Testing environments can be deleted with this command:

$ ktf environments delete --name <NAME>

Examples

Commonly this tool is used to deploy a Kubernetes environment with addons such as the Kong Gateway.

You can deploy a cluster with the Kong Gateway already deployed and accessible via LoadBalancer services by running the following:

$ ktf environments create --name kong-gateway-testing --addon metallb --addon kong

Once the cluster is up configure your kubectl to use it:

$ kubectl cluster-info --context kind-kong-gateway-testing

You can see the IP addresses where you can reach the Gateway and the Admin API with:

$ kubectl -n kong-system get services

Contributing

See CONTRIBUTING.md.

Community

If you have any questions about this tool and want to get in touch with the maintainers, check in on #kong in Kubernetes Slack.

Extension points exported contracts — how you extend this code

Addon (Interface)
Addon is a loadable component to extend the functionality of a Cluster. [12 implementers]
pkg/clusters/addons.go
Environment (Interface)
----------------------------------------------------------------------------- Public Types - Testing Environments ------ [1 …
pkg/environments/environment.go
Doer (Interface)
(no doc) [1 implementers]
internal/retry/command.go
HTTPResponseExpectOpt (FuncType)
(no doc)
internal/test/assert.go
Builder (Interface)
(no doc) [14 implementers]
pkg/clusters/cluster.go
ErrorFunc (FuncType)
(no doc)
internal/retry/command.go
Cluster (Interface)
Cluster objects represent a running Kubernetes cluster. [2 implementers]
pkg/clusters/cluster.go

Core symbols most depended-on inside this repo

Name
called by 162
pkg/clusters/addons.go
Cluster
called by 145
pkg/environments/environment.go
Client
called by 127
pkg/clusters/cluster.go
Build
called by 61
pkg/clusters/cluster.go
Delete
called by 34
pkg/clusters/addons.go
WithAddons
called by 33
pkg/environments/builder.go
Cleanup
called by 31
pkg/clusters/cluster.go
WaitForReady
called by 27
pkg/environments/environment.go

Shape

Method 265
Function 184
Struct 39
TypeAlias 7
Interface 5
FuncType 2

Languages

Go100%

Modules by API surface

pkg/clusters/addons/kong/builder.go24 symbols
pkg/clusters/addons/kong/addon.go23 symbols
pkg/clusters/utils.go17 symbols
pkg/clusters/cluster.go17 symbols
pkg/clusters/types/gke/cluster.go16 symbols
pkg/clusters/types/gke/builder.go15 symbols
pkg/clusters/addons/metallb/metallb.go15 symbols
pkg/clusters/addons/certmanager/addon.go15 symbols
pkg/clusters/types/kind/cluster.go14 symbols
pkg/clusters/addons/istio/addon.go14 symbols
pkg/clusters/addons/argocd/addon.go14 symbols
test/integration/kongaddon_test.go13 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add kubernetes-testing-framework \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact