Skip to content

Commit

Permalink
feat: set template display name in yaml (#14077)
Browse files Browse the repository at this point in the history
Signed-off-by: MenD32 <[email protected]>
Co-authored-by: MenD32 <[email protected]>
Signed-off-by: Alex Collins <[email protected]>
  • Loading branch information
2 people authored and alexec committed Jan 27, 2025
1 parent b2dd1df commit 4eff7ad
Show file tree
Hide file tree
Showing 27 changed files with 684 additions and 203 deletions.
7 changes: 7 additions & 0 deletions api/jsonschema/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/executor_swagger.md
Original file line number Diff line number Diff line change
Expand Up @@ -3807,6 +3807,7 @@ of the first container processes are calculated.
|------|------|---------|:--------:| ------- |-------------|---------|
| activeDeadlineSeconds | [IntOrString](#int-or-string)| `IntOrString` | | | | |
| affinity | [Affinity](#affinity)| `Affinity` | | | | |
| annotations | map of string| `map[string]string` | | | Annotations is a list of annotations to add to the template at runtime | |
| archiveLocation | [ArtifactLocation](#artifact-location)| `ArtifactLocation` | | | | |
| automountServiceAccountToken | boolean| `bool` | | | AutomountServiceAccountToken indicates whether a service account token should be automatically mounted in pods.</br>ServiceAccountName of ExecutorConfig must be specified if this value is false. | |
| container | [Container](#container)| `Container` | | | | |
Expand Down
1 change: 1 addition & 0 deletions docs/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -1723,6 +1723,7 @@ Template is a reusable and composable unit of execution in a workflow
|:----------:|:----------:|---------------|
|`activeDeadlineSeconds`|[`IntOrString`](#intorstring)|Optional duration in seconds relative to the StartTime that the pod may be active on a node before the system actively tries to terminate the pod; value must be positive integer This field is only applicable to container and script templates.|
|`affinity`|[`Affinity`](#affinity)|Affinity sets the pod's scheduling constraints Overrides the affinity set at the workflow level (if any)|
|`annotations`|`Map< string , string >`|Annotations is a list of annotations to add to the template at runtime|
|`archiveLocation`|[`ArtifactLocation`](#artifactlocation)|Location in which all files related to the step will be stored (logs, artifacts, etc...). Can be overridden by individual items in Outputs. If omitted, will use the default artifact repository location configured in the controller, appended with the <workflowname>/<nodename> in the key.|
|`automountServiceAccountToken`|`boolean`|AutomountServiceAccountToken indicates whether a service account token should be automatically mounted in pods. ServiceAccountName of ExecutorConfig must be specified if this value is false.|
|`container`|[`Container`](#container)|Container is the main container image to run in the pod|
Expand Down
66 changes: 66 additions & 0 deletions docs/walk-through/annotations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Annotations

Argo Workflows now supports annotations as a new field in workflow templates.

## Adding Annotations to a template

To add annotations to a workflow template, include the `annotations` field in template definition, for example:

```yaml
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: example-workflow-template
spec:
entrypoint: whalesay
templates:
- name: whalesay
annotations:
workflows.argoproj.io/display-name: "my-custom-display-name"
container:
image: docker/whalesay
command: [cowsay]
args: ["hello world"]
```

In this example, the annotation `workflows.argoproj.io/display-name` is used to change the node name in the UI to "my-custom-display-name".

## Annotation Templates

Annotations can also be created dynamically using parameters. This allows you to dynamically set annotation values based on input parameters.

Here is an example:

```yaml
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: templated-annotations-workflow
spec:
entrypoint: whalesay
arguments:
parameters:
- name: display-name
value: "default-display-name"
templates:
- name: whalesay
annotations:
workflows.argoproj.io/display-name: "{{inputs.parameters.display-name}}"
inputs:
parameters:
- name: display-name
container:
image: docker/whalesay
command: [cowsay]
args: ["hello world"]
```

In this example, the annotation `workflows.argoproj.io/display-name` is set using the `display-name` parameter. You can override this parameter when submitting the workflow to dynamically change the annotation value.

## Supported Annotation Types

Here is a table of all supported annotation types in Argo Workflows:

| Annotation Key | Description |
|----------------------------------------------|-----------------------------------------------------------------------------|
| `workflows.argoproj.io/display-name` | Changes the node name in the UI. |
2 changes: 2 additions & 0 deletions docs/walk-through/loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ spec:
# This template is the same as in the previous example
- name: cat-os-release
annotations:
workflows.argoproj.io/display-name: "os-{{inputs.parameters.image}}-{{inputs.parameters.tag}}" # this sets a custom name for the node in the UI, based on the template's parameters
inputs:
parameters:
- name: image
Expand Down
2 changes: 2 additions & 0 deletions examples/loops-param-argument.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ spec:
withParam: "{{inputs.parameters.os-list}}"

- name: cat-os-release
annotations:
workflows.argoproj.io/display-name: "os-{{inputs.parameters.image}}-{{inputs.parameters.tag}}"
inputs:
parameters:
- name: image
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions manifests/base/crds/full/argoproj.io_cronworkflows.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions manifests/base/crds/full/argoproj.io_workflows.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions manifests/base/crds/full/argoproj.io_workflowtasksets.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions manifests/base/crds/full/argoproj.io_workflowtemplates.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ nav:
- walk-through/exit-handlers.md
- walk-through/timeouts.md
# template types
- walk-through/annotations.md
- walk-through/suspending.md
- walk-through/kubernetes-resources.md
# container configuration
Expand Down
Loading

0 comments on commit 4eff7ad

Please sign in to comment.