diff --git a/api/v1alpha1/testrun_types.go b/api/v1alpha1/testrun_types.go index c8894201..08a4dfec 100644 --- a/api/v1alpha1/testrun_types.go +++ b/api/v1alpha1/testrun_types.go @@ -63,6 +63,7 @@ type InitContainer struct { Args []string `json:"args,omitempty"` WorkingDir string `json:"workingDir,omitempty"` VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"` + Resources corev1.ResourceRequirements `json:"resources,omitempty"` RestartPolicy *corev1.ContainerRestartPolicy `json:"restartPolicy,omitempty"` } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 10d98b81..c98be212 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -60,6 +60,7 @@ func (in *InitContainer) DeepCopyInto(out *InitContainer) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + in.Resources.DeepCopyInto(&out.Resources) if in.RestartPolicy != nil { in, out := &in.RestartPolicy, &out.RestartPolicy *out = new(v1.ContainerRestartPolicy) diff --git a/config/crd/bases/k6.io_testruns.yaml b/config/crd/bases/k6.io_testruns.yaml index 0b02b3a9..27e9641c 100644 --- a/config/crd/bases/k6.io_testruns.yaml +++ b/config/crd/bases/k6.io_testruns.yaml @@ -802,6 +802,39 @@ spec: type: string name: type: string + resources: + properties: + claims: + items: + properties: + name: + type: string + request: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object restartPolicy: type: string volumeMounts: @@ -2802,6 +2835,39 @@ spec: type: string name: type: string + resources: + properties: + claims: + items: + properties: + name: + type: string + request: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object restartPolicy: type: string volumeMounts: @@ -4823,6 +4889,39 @@ spec: type: string name: type: string + resources: + properties: + claims: + items: + properties: + name: + type: string + request: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object restartPolicy: type: string volumeMounts: diff --git a/docs/crd-generated.md b/docs/crd-generated.md index d0668995..fb177257 100644 --- a/docs/crd-generated.md +++ b/docs/crd-generated.md @@ -3556,6 +3556,13 @@ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/nam
false + + resources + object + + ResourceRequirements describes the compute resource requirements.
+ + false restartPolicy string @@ -4043,6 +4050,95 @@ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/nam +### TestRun.spec.initializer.initContainers[index].resources +[↩ Parent](#testrunspecinitializerinitcontainersindex) + + + +ResourceRequirements describes the compute resource requirements. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
claims[]object + Claims lists the names of resources, defined in spec.resourceClaims, +that are used by this container. + +This field depends on the +DynamicResourceAllocation feature gate. + +This field is immutable. It can only be set for containers.
+
false
limitsmap[string]int or string + Limits describes the maximum amount of compute resources allowed. +More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
+
false
requestsmap[string]int or string + Requests describes the minimum amount of compute resources required. +If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, +otherwise to an implementation-defined value. Requests cannot exceed Limits. +More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
+
false
+ + +### TestRun.spec.initializer.initContainers[index].resources.claims[index] +[↩ Parent](#testrunspecinitializerinitcontainersindexresources) + + + +ResourceClaim references one entry in PodSpec.ResourceClaims. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
namestring + Name must match the name of one entry in pod.spec.resourceClaims of +the Pod where this field is used. It makes that resource available +inside a container.
+
true
requeststring + Request is the name chosen for a request in the referenced claim. +If empty, everything from the claim is made available, otherwise +only the result of this request.
+
false
+ + ### TestRun.spec.initializer.initContainers[index].volumeMounts[index] [↩ Parent](#testrunspecinitializerinitcontainersindex) @@ -12406,6 +12502,13 @@ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/nam
false + + resources + object + + ResourceRequirements describes the compute resource requirements.
+ + false restartPolicy string @@ -12893,6 +12996,95 @@ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/nam +### TestRun.spec.runner.initContainers[index].resources +[↩ Parent](#testrunspecrunnerinitcontainersindex) + + + +ResourceRequirements describes the compute resource requirements. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
claims[]object + Claims lists the names of resources, defined in spec.resourceClaims, +that are used by this container. + +This field depends on the +DynamicResourceAllocation feature gate. + +This field is immutable. It can only be set for containers.
+
false
limitsmap[string]int or string + Limits describes the maximum amount of compute resources allowed. +More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
+
false
requestsmap[string]int or string + Requests describes the minimum amount of compute resources required. +If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, +otherwise to an implementation-defined value. Requests cannot exceed Limits. +More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
+
false
+ + +### TestRun.spec.runner.initContainers[index].resources.claims[index] +[↩ Parent](#testrunspecrunnerinitcontainersindexresources) + + + +ResourceClaim references one entry in PodSpec.ResourceClaims. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
namestring + Name must match the name of one entry in pod.spec.resourceClaims of +the Pod where this field is used. It makes that resource available +inside a container.
+
true
requeststring + Request is the name chosen for a request in the referenced claim. +If empty, everything from the claim is made available, otherwise +only the result of this request.
+
false
+ + ### TestRun.spec.runner.initContainers[index].volumeMounts[index] [↩ Parent](#testrunspecrunnerinitcontainersindex) @@ -21278,6 +21470,13 @@ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/nam
false + + resources + object + + ResourceRequirements describes the compute resource requirements.
+ + false restartPolicy string @@ -21765,6 +21964,95 @@ More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/nam +### TestRun.spec.starter.initContainers[index].resources +[↩ Parent](#testrunspecstarterinitcontainersindex) + + + +ResourceRequirements describes the compute resource requirements. + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
claims[]object + Claims lists the names of resources, defined in spec.resourceClaims, +that are used by this container. + +This field depends on the +DynamicResourceAllocation feature gate. + +This field is immutable. It can only be set for containers.
+
false
limitsmap[string]int or string + Limits describes the maximum amount of compute resources allowed. +More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
+
false
requestsmap[string]int or string + Requests describes the minimum amount of compute resources required. +If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, +otherwise to an implementation-defined value. Requests cannot exceed Limits. +More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
+
false
+ + +### TestRun.spec.starter.initContainers[index].resources.claims[index] +[↩ Parent](#testrunspecstarterinitcontainersindexresources) + + + +ResourceClaim references one entry in PodSpec.ResourceClaims. + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescriptionRequired
namestring + Name must match the name of one entry in pod.spec.resourceClaims of +the Pod where this field is used. It makes that resource available +inside a container.
+
true
requeststring + Request is the name chosen for a request in the referenced claim. +If empty, everything from the claim is made available, otherwise +only the result of this request.
+
false
+ + ### TestRun.spec.starter.initContainers[index].volumeMounts[index] [↩ Parent](#testrunspecstarterinitcontainersindex) diff --git a/pkg/resources/jobs/helpers.go b/pkg/resources/jobs/helpers.go index 0433402f..da155ab8 100644 --- a/pkg/resources/jobs/helpers.go +++ b/pkg/resources/jobs/helpers.go @@ -141,6 +141,7 @@ func getInitContainers(pod *v1alpha1.Pod, script *types.Script) []corev1.Contain ImagePullPolicy: pod.ImagePullPolicy, SecurityContext: &pod.ContainerSecurityContext, RestartPolicy: k6InitContainer.RestartPolicy, + Resources: k6InitContainer.Resources, } initContainers = append(initContainers, initContainer) }