Skip to content

A small app in Go to test your APIs in Kubernetes enviromnent

License

Notifications You must be signed in to change notification settings

BenjaminFourmaux/k8s-api_tester

Repository files navigation

k8s API Tester

A small app in Go to test your APIs in Kubernetes enviromnent

Banner

Features ✨

  • Send a HTTP request
  • Declare tests using a YAML file who describe test
  • Dockerfile to build the Docker image 🐳
  • Wget and Curl package are installed !
  • Kubernetes YAML manifest to deploy pod for test in your Kube env ⚓
  • Integrate Bruno (or create Postman like) to have an interface to send request on Kubernetes cluster 🐶
  • Create a Grafana connector to get in dashboard Health of app ✔️⚠️

To start unsing API Tester 🚀

Go

Install Go lang 1.21.3 on your system Download it. Clone (or dezip) this project and run the following command:

go run main.go

Docker

Build Docker image with Dockerfile

docker build -t api_tester:1.0.0 -f Infrastructure/docker/dockerfile .

Or download the image from release files named api_tester.tar. Load this image on your Docker

docker load -i api_tester.tar

The image is save on your local image registry. To deploy a container, use the following command. And check env var if necessary.

docker run -e IS_CONTAINERIZED=true api_tester:1.0.0

Kubernetes

Chose a deployment type between Pod, DaemonSet, Stateful or CronJob depending of why you need. To deploy a deployment, run the following command:

kubectl apply -f deploy-pod.yaml

You can modify files if necessary.

Describe your Tests with YAML file

Tests are described in tests.yaml YAML file. It location in container is /etc/api_tester/tests.yaml.
You can overwrite this file by binding your own file as a volume to the container location.

Properties

Key Description Type
tests Array of test Array
name Name of the test String
url URL of the API to test String
method HTTP method to use String
expectedHTTPCode The expected HTTP code Int

Exemple

tests:
  - name: "Test Internet connection"
    url: "https://google.com"
    method: "GET"
    expectedHTTPCode: 200

  - name: "Back API health"
    url: "http://back-api/health"
    method: "GET"
    expectedHTTPCode: 200

Contributors

Licence

All Service Down project's is under Apache License v2. You can:

  • Reuse the code
  • Modified the code
  • Build the code

You must Mention the © Copyright if you use and modified code for your own profit. Thank you

About

A small app in Go to test your APIs in Kubernetes enviromnent

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages