diff --git a/config/config-feature-flags.yaml b/config/config-feature-flags.yaml index 8056ae23b69..3288331422f 100644 --- a/config/config-feature-flags.yaml +++ b/config/config-feature-flags.yaml @@ -26,8 +26,8 @@ data: # # The default behaviour is for Tekton to create Affinity Assistants # - # See more in the workspace documentation about Affinity Assistant - # https://github.com/tektoncd/pipeline/blob/main/docs/workspaces.md#affinity-assistant-and-specifying-workspace-order-in-a-pipeline + # See more in the Affinity Assistant documentation + # https://github.com/tektoncd/pipeline/blob/main/docs/affinityassistants.md # or https://github.com/tektoncd/pipeline/pull/2630 for more info. disable-affinity-assistant: "false" # Setting this flag will determine how PipelineRun Pods are scheduled with Affinity Assistant. @@ -39,7 +39,8 @@ data: # and only allows one pipelinerun to run on a node at a time. # Setting it to "disabled" will not apply any coschedule policy. # - # TODO: add links to documentation and migration strategy + # See more in the Affinity Assistant documentation + # https://github.com/tektoncd/pipeline/blob/main/docs/affinityassistants.md # NOTE: this feature is still under development and not yet functional. coschedule: "workspaces" # Setting this flag to "true" will prevent Tekton scanning attached diff --git a/docs/additional-configs.md b/docs/additional-configs.md index 202fa6e8a07..1ee1693ebe8 100644 --- a/docs/additional-configs.md +++ b/docs/additional-configs.md @@ -193,7 +193,7 @@ that are running while the change occurs. The flags in this ConfigMap are as follows: -- `disable-affinity-assistant` - set this flag to `true` to disable the [Affinity Assistant](./workspaces.md#specifying-workspace-order-in-a-pipeline-and-affinity-assistants) +- `disable-affinity-assistant` - set this flag to `true` to disable the [Affinity Assistant](./affinityassistants) that is used to provide Node Affinity for `TaskRun` pods that share workspace volume. The Affinity Assistant is incompatible with other affinity rules configured for `TaskRun` pods. @@ -206,6 +206,13 @@ The flags in this ConfigMap are as follows: node in the cluster must have an appropriate label matching `topologyKey`. If some or all nodes are missing the specified `topologyKey` label, it can lead to unintended behavior. +- `coschedule`: set this flag determines how PipelineRun Pods are scheduled with [Affinity Assistant](./affinityassistants). +Acceptable values are "workspaces" (default), "pipelineruns", "isolate-pipelinerun", or "disabled". +Setting it to "workspaces" will schedule all the taskruns sharing the same PVC-based workspace in a pipelinerun to the same node. +Setting it to "pipelineruns" will schedule all the taskruns in a pipelinerun to the same node. +Setting it to "isolate-pipelinerun" will schedule all the taskruns in a pipelinerun to the same node, +and only allows one pipelinerun to run on a node at a time. Setting it to "disabled" will not apply any coschedule policy. + - `await-sidecar-readiness`: set this flag to `"false"` to allow the Tekton controller to start a TasksRun's first step immediately without waiting for sidecar containers to be running first. Using this option should decrease the time it takes for a TaskRun to start running, and will allow TaskRun @@ -291,6 +298,7 @@ Features currently in "alpha" are: | [Trusted Resources](./trusted-resources.md) | [TEP-0091](https://github.com/tektoncd/community/blob/main/teps/0091-trusted-resources.md) | N/A | `trusted-resources-verification-no-match-policy` | | [Larger Results via Sidecar Logs](#enabling-larger-results-using-sidecar-logs) | [TEP-0127](https://github.com/tektoncd/community/blob/main/teps/0127-larger-results-via-sidecar-logs.md) | [v0.43.0](https://github.com/tektoncd/pipeline/releases/tag/v0.43.0) | `results-from` | | [Configure Default Resolver](./resolution.md#configuring-built-in-resolvers) | [TEP-0133](https://github.com/tektoncd/community/blob/main/teps/0133-configure-default-resolver.md) | N/A | | +| [Coschedule](./affinityassistants.md) | [TEP-0135](https://github.com/tektoncd/community/blob/main/teps/0135-coscheduling-pipelinerun-pods.md) | N/A |`coschedule` | ### Beta Features diff --git a/docs/affinityassistants.md b/docs/affinityassistants.md new file mode 100644 index 00000000000..8bd9244cfa3 --- /dev/null +++ b/docs/affinityassistants.md @@ -0,0 +1,113 @@ + + +# Affinity Assistants +Affinity Assistant is a feature to coschedule `PipelineRun` `pods` to the same node +based on [kubernetes pod affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity) so that it possible for the taskruns to execute parallel while sharing volume. +Available Affinity Assistant Modes are **coschedule workspaces**, **coschedule pipelineruns**, +**isolate pipelinerun** and **disabled**. + +> :seedling: **coschedule pipelineruns** and **isolate pipelinerun** modes are [**alpha features**](./additional-configs.md#alpha-features). +> **coschedule workspaces** is a **stable feature** + +* **coschedule workspaces** - When a `PersistentVolumeClaim` is used as volume source for a `Workspace` in a `PipelineRun`, +all `TaskRun` pods within the `PipelineRun` that share the `Workspace` will be scheduled to the same Node. + +**Note:** Only one pvc-backed workspace can be mounted to each TaskRun in this mode. + +* **coschedule pipelineruns** - All `TaskRun` pods within the `PipelineRun` will be scheduled to the same Node. + +* **isolate pipelinerun** - All `TaskRun` pods within the `PipelineRun` will be scheduled to the same Node, +and only one PipelineRun is allowed to run on a node at a time. + +* **disabled** - The Affinity Assistant is disabled. No pod coscheduling behavior. + +This means that Affinity Assistant is incompatible with other affinity rules +configured for the `TaskRun` pods (i.e. other affinity rules specified in custom [PodTemplate](pipelineruns.md#specifying-a-pod-template) will be overwritten by Affinity Assistant). +If the `PipelineRun` has a custom [PodTemplate](pipelineruns.md#specifying-a-pod-template) configured, the `NodeSelector` and `Tolerations` fields will also be set on the Affinity Assistant pod. The Affinity Assistant +is deleted when the `PipelineRun` is completed. + +Currently, the Affinity Assistant Modes can be configured by the `disable-affinity-assistant` and `coschedule` feature flags. In 9 months, the `disable-affinity-assistant` feature flag will be deprecated, and the Affinity Assistant Modes will be only determined by the `coschedule` feature flag. + +The following chart summarizes the Affinity Assistant Modes with different combinations of the `disable-affinity-assistant` and `coschedule` feature flags during migration (when both feature flags are present) and after the migration (when only the `coschedule` flag is present). + +
disable-affinity-assistant | +coschedule | +behavior during migration | +behavior after migration | +
---|---|---|---|
false (default) | +disabled | +N/A: invalid | +disabled | +
false (default) | +workspaces (default) | +coschedule workspaces | +coschedule workspaces | +
false (default) | +pipelineruns | +N/A: invalid | +coschedule pipelineruns | +
false (default) | +isolate-pipelinerun | +N/A: invalid | +isolate pipelinerun | +
true | +disabled | +disabled | +disabled | +
true | +workspaces (default) | +disabled | +coschedule workspaces | +
true | +pipelineruns | +coschedule pipelineruns | +coschedule pipelineruns | +
true | +isolate-pipelinerun | +isolate pipelinerun | +isolate pipelinerun | +