Skip to content

Commit

Permalink
[TektonConfig] Allows user to set priorityClassName parameter for
Browse files Browse the repository at this point in the history
the tekton resources created.

In TektonConfig CR, allows  `.spec.config.priorityClassName` as a
new optional field where users can set the priorityClassName.

However, extenally the necessary Kubernetes PriorityClass needs to
be created accordingly to allow successful pod scheduling, else the
pod will not come into Running stage
  • Loading branch information
guhaneswaran authored and tekton-robot committed Jun 27, 2022
1 parent 858cacc commit 823835a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
9 changes: 8 additions & 1 deletion docs/TektonConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The TektonConfig CR provides the following features
config:
nodeSelector: <>
tolerations: []
priorityClassName: system-cluster-critical
pipeline:
disable-affinity-assistant: false
disable-creds-init: false
Expand Down Expand Up @@ -86,6 +87,7 @@ Config provides fields to configure deployments created by the Operator.
This provides following fields:
- [`nodeSelector`][node-selector]
- [`tolerations`][tolerations]
- [`priorityClassName`][priorityClassName]

User can pass the required fields and this would be passed to all Operator components which will get added in all
deployments created by Operator.
Expand All @@ -100,11 +102,13 @@ config:
operator: "Equal"
value: "value1"
effect: "NoSchedule"
priorityClassName: system-node-critical
```

This is an `Optional` section.


**NOTE**: If `spec.config.priorityClassName` is used, then the required [`priorityClass`][priorityClass] is
expected to be created by the user to get the Tekton resources pods in running state
### Pipeline
Pipeline section allows user to customize the Tekton pipeline features. This allow user to customize the values in configmaps.

Expand Down Expand Up @@ -203,3 +207,6 @@ This is an `Optional` section.
[node-selector]:https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector
[tolerations]:https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
[schedule]:https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#cron-schedule-syntax
[priorityClassName]: https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#pod-priority
[priorityClass]: https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass

3 changes: 3 additions & 0 deletions pkg/apis/operator/v1alpha1/tektonconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,7 @@ type TektonConfigList struct {
type Config struct {
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// PriorityClassName holds the priority class to be set to pod template
// +optional
PriorityClassName string `json:"priorityClassName,omitempty"`
}
1 change: 1 addition & 0 deletions pkg/reconciler/common/transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ func AddConfiguration(config v1alpha1.Config) mf.Transformer {

d.Spec.Template.Spec.NodeSelector = config.NodeSelector
d.Spec.Template.Spec.Tolerations = config.Tolerations
d.Spec.Template.Spec.PriorityClassName = config.PriorityClassName

unstrObj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(d)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/reconciler/common/transformers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ func TestAddConfiguration(t *testing.T) {
Effect: "noSchedule",
},
},
PriorityClassName: string("system-cluster-critical"),
}

manifest, err = manifest.Transform(AddConfiguration(config))
Expand All @@ -509,7 +510,7 @@ func TestAddConfiguration(t *testing.T) {
d := &v1beta1.Deployment{}
err = runtime.DefaultUnstructuredConverter.FromUnstructured(manifest.Resources()[0].Object, d)
assertNoEror(t, err)

assert.Equal(t, d.Spec.Template.Spec.NodeSelector["foo"], config.NodeSelector["foo"])
assert.Equal(t, d.Spec.Template.Spec.Tolerations[0].Key, config.Tolerations[0].Key)
assert.Equal(t, d.Spec.Template.Spec.PriorityClassName, config.PriorityClassName)
}

0 comments on commit 823835a

Please sign in to comment.