A Kubernetes operator for managing network and storage performance tests in Kubernetes environments. This controller automates the execution, scheduling, and monitoring of various tests including Ping, Dig, and FIO (Flexible I/O Tester).
The Kubernetes Test Tools Controller extends Kubernetes with custom resources to manage and execute network and storage performance tests. It helps operators validate infrastructure performance, troubleshoot connectivity issues, and establish performance baselines.
This controller provides the following core capabilities:
-
Network Tests:
- Ping Tests: Measure connectivity and latency to specified endpoints
- Dig Tests: Validate DNS resolution and performance
- Nc Tests
- Iperf Tests
- Tcpping tests
-
Storage Tests:
- FIO Tests: Benchmark disk I/O performance with flexible configurations
-
Test Report Management:
- Automated collection of test results
- Historical data tracking
- Status monitoring
-
Scheduling:
- Cron-based scheduling of recurring tests
- One-time test execution
- Kubernetes cluster v1.19+
- kubectl configured to communicate with your cluster
- cert-manager v1.0.0+ (for webhook support)
-
Clone the repository:
git clone https://github.com/yourusername/kubernetes-test-tools.git cd kubernetes-test-tools -
Install Custom Resource Definitions (CRDs):
make install
-
Deploy the controller:
make deploy
-
Verify the installation:
kubectl get pods -n testtools-system
Create a YAML file for a ping test:
apiVersion: testtools.xiaoming.com/v1
kind: Ping
metadata:
name: example-ping-test
spec:
host: "8.8.8.8"
count: 5Apply the file:
kubectl apply -f ping-test.yamlCheck the results:
kubectl get ping example-ping-test -o yamlCreate a YAML file for a DNS dig test:
apiVersion: testtools.xiaoming.com/v1
kind: Dig
metadata:
name: example-dig-test
spec:
host: "kubernetes.default.svc.cluster.local"
type: "A"Apply the file:
kubectl apply -f dig-test.yamlCheck the results:
kubectl get dig example-dig-test -o yamlCreate a YAML file for a DNS dig test:
apiVersion: testtools.xiaoming.com/v1
kind: Nc
metadata:
name: nc-sample-simple
spec:
host: "kubernetes.io"
port: 443
timeout: 5
verbose: trueApply the file:
kubectl apply -f nc-sample-simple.yamlCheck the results:
kubectl get dig nc-sample-simple -o yamlCreate a YAML file for a DNS dig test:
apiVersion: testtools.xiaoming.com/v1
kind: TcpPing
metadata:
name: tcpping-sample-simple
spec:
host: "kubernetes.io"
port: 443
count: 5
timeout: 3
interval: 1Apply the file:
kubectl apply -f tcpping-sample-simple.yamlCheck the results:
kubectl get dig tcpping-sample-simple -o yamlCreate a YAML file for a DNS dig test:
apiVersion: testtools.xiaoming.com/v1
kind: Iperf
metadata:
name: iperf-sample-simple
spec:
port: 5201
duration: 10
protocol: "tcp"
verbose: trueApply the file:
kubectl apply -f iperf-sample-simple.yamlCheck the results:
kubectl get dig iperf-sample-simple -o yamlCreate a YAML file for an FIO storage test:
apiVersion: testtools.xiaoming.com/v1
kind: Fio
metadata:
name: example-fio-test
spec:
filePath: "/data/fio-test"
readWrite: "randread"
blockSize: "4k"
ioDepth: 32
size: "1g"
ioEngine: "libaio"Apply the file:
kubectl apply -f fio-test.yamlCheck the results:
kubectl get fio example-fio-test -o yamlOne major advantage of using this controller is that a TestReport is created automatically. Users only need to create a Fio, Ping, Dig, Nc, Tcpping or Iperf resource, and the controller will:
Automatically create a corresponding TestReport resource for each test resource
Automatically collect test results and update the report
Automatically maintain test history and statistical data
For example, after creating a Fio resource:
apiVersion: testtools.xiaoming.com/v1
kind: Fio
metadata:
name: my-fio-test
spec:
filePath: "/data/test-file"
readWrite: "randread"
# other configurationThe controller will automatically create a TestReport resource named fio-my-fio-test-report. There is no need to manually create or associate a TestReport—the entire process is fully automated.
Get the complete test report:
kubectl get testreport <report-name> -o yamlConfigure error handling and retries:
apiVersion: testtools.xiaoming.com/v1
kind: Fio
metadata:
name: fio-with-retries
spec:
# ... other configurations
retries: 3
retryInterval: 60 # seconds
timeoutSeconds: 600-
Install dependencies:
go mod download
-
Run the controller locally:
make run
Build the controller:
make buildRun tests:
make testTo add a new test type:
- Define the CRD in
api/v1/ - Implement the controller in
controllers/ - Update the
main.gofile to include the new controller - Generate the CRD manifests with
make manifests
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
For issues or suggestions, please open an issue in the GitHub repository.
