Zooz / predator

A powerful open-source platform for load testing APIs.
https://zooz.github.io/predator/
Apache License 2.0
576 stars 109 forks source link

I'd like to be able to define kubernetes resources config for test jobs #336

Closed nishaad78 closed 4 years ago

nishaad78 commented 4 years ago

Is your feature request related to a problem? Please describe. Currently this is the only resources config set by default for a k8s Job:

        resources:
          requests:
            cpu: "1"

I would want more control over this so that I can specify requests and limits, especially on memory. This is so that a rogue test run won't accidentally affect other workloads running on the k8s node.

Describe the solution you'd like A way to specify resources config for my Tests, ideally, when creating a Test.

enudler commented 4 years ago

Hi @nishaad78

Regarding CPU, you can set the requested CPU on the config endpoint (https://zooz.github.io/predator/configuration.html) (runner_cpu) or in the UI

But as you said, this is the requested CPU and not the limit.

To enhance the predator-runner job template we lately introduced a new config variable called: 'custom_runner_definition'

This variable is expected to be a JSON which will be merged with the default predator-runner job template, there you customize it.

It's was merged to mater about two weeks ago and will be part of 1.4 release so if you want to use it, change the predator image to zooz/predator:latest

example usage for your use-case (this template can be further customized if needed):

curl -X PUT \
  http://PREDATOR-API-URL/v1/config \
  -H 'Content-Type: application/json' \
  -d '{
    "custom_runner_definition": {
        "spec": {
            "template": {
                "spec": {
                    "containers": [{
                        "resources": {
                            "requests": {
                                "memory": "128Mi",
                                "cpu": "0.5"
                            },
                            "limits": {
                                "memory": "1024Mi",
                                "cpu": "1"
                            }
                        }
                    }]
                }
            }
        }
    }
}'
enudler commented 4 years ago

btw @nishaad78 you can also install Predator in specific namespace and give that namespace limits on CPU and Memory

https://kubernetes.io/docs/tasks/administer-cluster/manage-resources/memory-default-namespace/

nishaad78 commented 4 years ago

Thanks @enudler!