I have a pipeline that references a task:
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: foo
spec:
tasks:
- name: my-bar-task
taskRef:
name: bar-task
bundle: ...
That task has resources:
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: bar-task
spec:
steps:
- name: step-one
resources:
requests:
memory: "1Gi"
cpu: "1"
limits:
memory: "2Gi"
cpu: "1"
I would like to be able to override the resources in the pipeline definition. Something like this:
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
name: foo
spec:
tasks:
- name: my-bar-task
taskRef:
name: bar-task
bundle: ...
resources:
requests:
memory: "4Gi"
cpu: "1"
limits:
memory: "5Gi"
cpu: "1"
But when I tried that, the override was ignored. Is what I am trying possible? I know the resources can be overridden from a pipeline run but I am particularly wondering about doing that in a pipeline.
At the pipeline level: NO.
However this is possible, at the PipelineRun/TaskRun level.
ALTHOUGH, this is an alpha feature (not yet globally available / "stable"). Over time, it may graduate as a stable feature -- keeping in mind there could be breaking changes in that process. Afterwards, should be enabled by default.
Nowadays, you need to enable the corresponding alpha feature first (TEP-0094: specifying resource requirements at runtime)
Depending on where/how you installed Tekton, you should have some configmap, somewhere, like the following:
$ kubectl get cm -n tekton-pipelines -o yaml feature-flags
apiVersion: v1
data:
...
enable-api-fields: alpha
...
kind: ConfigMap
metadata:
name: feature-flags
namespace: tekton-pipelines
Setting enable-api-fields: alpha
should enable that feature in your installation.
Having done so, you would be able to override those values, in your PipelineRun. Eg:
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
spec:
taskRunSpecs:
- pipelineTaskName: build
stepOverrides:
- name: build
resources:
limits:
cpu: 200m
memory: 768Mi
requests:
cpu: 100m
memory: 512Mi
pipelineRef:
name: docker-build