Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TektonConfig] Allows user to set priorityClassName parameter #797

Merged
merged 1 commit into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}