diff --git a/api/v1alpha1/k6conditions.go b/api/v1alpha1/k6conditions.go
index a21c782d..5ea39624 100644
--- a/api/v1alpha1/k6conditions.go
+++ b/api/v1alpha1/k6conditions.go
@@ -10,6 +10,7 @@ import (
)
const (
+ InitializerSkipped = "InitializerSkipped"
// TestRunRunning indicates if the test run is currently running.
// - if empty / Unknown, it's any stage before k6 resume (starter)
// - if False, it's after all runners have finished successfully or with error
diff --git a/api/v1alpha1/testrun_types.go b/api/v1alpha1/testrun_types.go
index b14f0b0a..49e4c374 100644
--- a/api/v1alpha1/testrun_types.go
+++ b/api/v1alpha1/testrun_types.go
@@ -32,6 +32,9 @@ type PodMetadata struct {
}
type Pod struct {
+ // +optional
+ // +kubebuilder:default=false
+ Disabled bool `json:"disabled,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
AutomountServiceAccountToken string `json:"automountServiceAccountToken,omitempty"`
Env []corev1.EnvVar `json:"env,omitempty"`
@@ -293,3 +296,10 @@ func (k6 *TestRun) ListOptions() *client.ListOptions {
return &client.ListOptions{LabelSelector: selector, Namespace: k6.NamespacedName().Namespace}
}
+
+func (k6 *TestRun) IsInitializerDisabled() bool {
+ if k6.GetSpec().Initializer == nil {
+ return false
+ }
+ return k6.GetSpec().Initializer.Disabled
+}
diff --git a/config/crd/bases/k6.io_testruns.yaml b/config/crd/bases/k6.io_testruns.yaml
index 5143b366..6cfe59f9 100644
--- a/config/crd/bases/k6.io_testruns.yaml
+++ b/config/crd/bases/k6.io_testruns.yaml
@@ -558,6 +558,9 @@ spec:
type: string
type: object
type: object
+ disabled:
+ default: false
+ type: boolean
env:
items:
properties:
@@ -2593,6 +2596,9 @@ spec:
type: string
type: object
type: object
+ disabled:
+ default: false
+ type: boolean
env:
items:
properties:
@@ -4649,6 +4655,9 @@ spec:
type: string
type: object
type: object
+ disabled:
+ default: false
+ type: boolean
env:
items:
properties:
diff --git a/config/samples/k6_v1alpha1_testrun_initializer_disabled.yaml b/config/samples/k6_v1alpha1_testrun_initializer_disabled.yaml
new file mode 100644
index 00000000..630e7351
--- /dev/null
+++ b/config/samples/k6_v1alpha1_testrun_initializer_disabled.yaml
@@ -0,0 +1,13 @@
+---
+apiVersion: k6.io/v1alpha1
+kind: TestRun
+metadata:
+ name: k6-sample
+spec:
+ parallelism: 4
+ initializer:
+ disabled: true
+ script:
+ configMap:
+ name: k6-test
+ file: test.js
diff --git a/docs/crd-generated.md b/docs/crd-generated.md
index 0d681b50..29fc102c 100644
--- a/docs/crd-generated.md
+++ b/docs/crd-generated.md
@@ -869,6 +869,15 @@ Some fields are present in both SecurityContext and PodSecurityContext. When bo
are set, the values in SecurityContext take precedence.