diff --git a/api/v1alpha1/privateloadzone_types.go b/api/v1alpha1/privateloadzone_types.go index fa033441..f4e0852e 100644 --- a/api/v1alpha1/privateloadzone_types.go +++ b/api/v1alpha1/privateloadzone_types.go @@ -34,6 +34,7 @@ import ( type PrivateLoadZoneSpec struct { Token string `json:"token"` Resources corev1.ResourceRequirements `json:"resources"` + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` ServiceAccountName string `json:"serviceAccountName,omitempty"` NodeSelector map[string]string `json:"nodeSelector,omitempty"` Image string `json:"image,omitempty"` diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index e65a4851..8cae893f 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -380,6 +380,13 @@ func (in *PrivateLoadZoneList) DeepCopyObject() runtime.Object { func (in *PrivateLoadZoneSpec) DeepCopyInto(out *PrivateLoadZoneSpec) { *out = *in in.Resources.DeepCopyInto(&out.Resources) + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]v1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } if in.NodeSelector != nil { in, out := &in.NodeSelector, &out.NodeSelector *out = make(map[string]string, len(*in)) diff --git a/charts/k6-operator/templates/crds/plz.yaml b/charts/k6-operator/templates/crds/plz.yaml index 65e1da9a..744130fb 100644 --- a/charts/k6-operator/templates/crds/plz.yaml +++ b/charts/k6-operator/templates/crds/plz.yaml @@ -76,6 +76,22 @@ spec: x-kubernetes-int-or-string: true type: object type: object + tolerations: + items: + properties: + effect: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array serviceAccountName: type: string token: diff --git a/config/crd/bases/k6.io_privateloadzones.yaml b/config/crd/bases/k6.io_privateloadzones.yaml index 3ce91732..2b6a8dbc 100644 --- a/config/crd/bases/k6.io_privateloadzones.yaml +++ b/config/crd/bases/k6.io_privateloadzones.yaml @@ -75,6 +75,22 @@ spec: type: string token: type: string + tolerations: + items: + properties: + effect: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array required: - resources - token diff --git a/pkg/testrun/plz.go b/pkg/testrun/plz.go index bbe42ef7..95b716dc 100644 --- a/pkg/testrun/plz.go +++ b/pkg/testrun/plz.go @@ -51,6 +51,7 @@ func NewPLZTestRun(plz *v1alpha1.PrivateLoadZone, trData *cloud.TestRunData, ing ServiceAccountName: plz.Spec.ServiceAccountName, NodeSelector: plz.Spec.NodeSelector, Resources: plz.Spec.Resources, + Tolerations: plz.Spec.Tolerations, Volumes: []corev1.Volume{ volume, }, @@ -66,6 +67,7 @@ func NewPLZTestRun(plz *v1alpha1.PrivateLoadZone, trData *cloud.TestRunData, ing ServiceAccountName: plz.Spec.ServiceAccountName, NodeSelector: plz.Spec.NodeSelector, ImagePullSecrets: plz.Spec.ImagePullSecrets, + Tolerations: plz.Spec.Tolerations, }, Script: v1alpha1.K6Script{ LocalFile: "/test/archive.tar", diff --git a/pkg/testrun/plz_test.go b/pkg/testrun/plz_test.go index 0cdebef7..c3f1c21d 100644 --- a/pkg/testrun/plz_test.go +++ b/pkg/testrun/plz_test.go @@ -69,6 +69,14 @@ func Test_NewPLZTestRun(t *testing.T) { corev1.ResourceCPU: resource.MustParse("200m"), corev1.ResourceMemory: resource.MustParse("1G"), } + tolerations = []corev1.Toleration{ + { + Key: "someKey", + Operator: corev1.TolerationOpEqual, + Value: "someValue", + Effect: corev1.TaintEffectNoSchedule, + }, + } someTestRunID = 6543 someRunnerImage = "grafana/k6:0.52.0" someInstances = 10 @@ -95,8 +103,10 @@ func Test_NewPLZTestRun(t *testing.T) { optionalFieldsTestRun.Namespace = someNS optionalFieldsTestRun.Spec.Runner.ServiceAccountName = someSA optionalFieldsTestRun.Spec.Runner.NodeSelector = someNodeSelector + optionalFieldsTestRun.Spec.Runner.Tolerations = tolerations optionalFieldsTestRun.Spec.Starter.ServiceAccountName = someSA optionalFieldsTestRun.Spec.Starter.NodeSelector = someNodeSelector + optionalFieldsTestRun.Spec.Starter.Tolerations = tolerations cloudFieldsTestRun = requiredFieldsTestRun // build up on top of required field case cloudFieldsTestRun.ObjectMeta.Name = TestName(fmt.Sprintf("%d", someTestRunID)) @@ -166,6 +176,7 @@ func Test_NewPLZTestRun(t *testing.T) { Resources: corev1.ResourceRequirements{ Limits: resourceLimits, }, + Tolerations: tolerations, ServiceAccountName: someSA, NodeSelector: someNodeSelector, },