Closed AndrewUnderwoodAtFanatics closed 1 year ago
Awesome! This is working for me now. For posterities sake, here's what a Test CRD with a custom jobTemplate looks like.
apiVersion: tests.testkube.io/v3
kind: Test
metadata:
name: template-test
namespace: testkube
spec:
type: cypress/project
content:
type: git
repository:
type: git
uri: https://github.com/kubeshop/testkube-example-cypress-project.git
branch: main
path: cypress
executionRequest:
jobTemplate: "apiVersion: batch/v1\nkind: Job\nspec:\n template:\n spec:\n containers:\n - name: {{ .Name }}\n image: {{ .Image }}\n imagePullPolicy: Always\n command:\n - \"/bin/runner\"\n - '{{ .Jsn }}'\n resources:\n limits:\n memory: 128Mi\n"
If you're doing a GitOps process and store CRDs in Git, you can store the CRD using a multiline for the jobTemplate like this to improve readability:
apiVersion: tests.testkube.io/v3
kind: Test
metadata:
name: template-test
namespace: testkube
spec:
type: cypress/project
content:
type: git
repository:
type: git
uri: https://github.com/kubeshop/testkube-example-cypress-project.git
branch: main
path: cypress
executionRequest:
jobTemplate: |
apiVersion: batch/v1
kind: Job
spec:
template:
spec:
containers:
- name: {{ .Name }}
image: {{ .Image }}
imagePullPolicy: Always
command:
- "/bin/runner"
- '{{ .Jsn }}'
resources:
limits:
memory: 128Mi
However, the K8s API server won't return the CRD in this multiline format once inserted into the cluster. It condenses the jobTemplate
field into a single line string like the first example.
you can create your test using cli as in example and provide --crd-only flag. It will print you CRD version of the test
Describe the bug I'm attempting to follow the docs on how to change the job template for a test to create a Test in my cluster with a custom jobTemplate. Ultimately I want to do this so I can get an idea of what my Test CRD should look like in order to set a custom jobTemplate with higher memory limits for the Job pod.
I've followed the doc to create the provided cypress Test, here is the CRD the cli command has created in my cluster:
However, when I execute this Test through the webUI, dashboard gets the following 500 error back from the testkube API server:
In the testkube-api-server logs I see the following stacktrace:
To Reproduce Steps to reproduce the behavior:
Expected behavior Is there a more correct syntax for specifying a custom jobTemplate in a Test CRD or is there a bug at play here?
Version / Cluster I'm running version
1.9.231
of the testkube helm chart