-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix volume mounts on user container (#931)
**Pull Request Checklist** - [x] Fixes #930 - [x] Tests added - [x] Documentation/examples added - [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title See #930 CC: @abschm --------- Signed-off-by: Flaviu Vadan <[email protected]>
- Loading branch information
1 parent
7c9de71
commit 7982f90
Showing
6 changed files
with
191 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# User Container | ||
|
||
|
||
|
||
This example showcases the user of a user container with a volume mount. | ||
|
||
|
||
=== "Hera" | ||
|
||
```python linenums="1" | ||
from hera.workflows import ( | ||
DAG, | ||
UserContainer, | ||
Workflow, | ||
models as m, | ||
script, | ||
) | ||
|
||
|
||
@script( | ||
sidecars=[ | ||
UserContainer(name="sidecar-name", volume_mounts=[m.VolumeMount(mount_path="/whatever", name="something")]) | ||
] | ||
) | ||
def foo(): | ||
print("hi") | ||
|
||
|
||
with Workflow(generate_name="sidecar-volume-mount-", entrypoint="d") as w: | ||
with DAG(name="d"): | ||
foo() | ||
``` | ||
|
||
=== "YAML" | ||
|
||
```yaml linenums="1" | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: sidecar-volume-mount- | ||
spec: | ||
entrypoint: d | ||
templates: | ||
- dag: | ||
tasks: | ||
- name: foo | ||
template: foo | ||
name: d | ||
- name: foo | ||
script: | ||
command: | ||
- python | ||
image: python:3.8 | ||
source: 'import os | ||
|
||
import sys | ||
|
||
sys.path.append(os.getcwd()) | ||
|
||
print(''hi'')' | ||
sidecars: | ||
- name: sidecar-name | ||
volumeMounts: | ||
- mountPath: /whatever | ||
name: something | ||
``` | ||
|
19 changes: 19 additions & 0 deletions
19
examples/workflows/upstream/title-and-descriptin-with-markdown.upstream.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: title-and-description-with-markdown- | ||
labels: | ||
workflows.argoproj.io/archive-strategy: "false" | ||
annotations: | ||
workflows.argoproj.io/title: "**Test Title**" | ||
workflows.argoproj.io/description: | | ||
`This is a simple hello world example.` | ||
You can also run it in Python: https://couler-proj.github.io/couler/examples/#hello-world | ||
spec: | ||
entrypoint: whalesay | ||
templates: | ||
- name: whalesay | ||
container: | ||
image: docker/whalesay:latest | ||
command: [cowsay] | ||
args: ["hello world"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: sidecar-volume-mount- | ||
spec: | ||
entrypoint: d | ||
templates: | ||
- dag: | ||
tasks: | ||
- name: foo | ||
template: foo | ||
name: d | ||
- name: foo | ||
script: | ||
command: | ||
- python | ||
image: python:3.8 | ||
source: 'import os | ||
import sys | ||
sys.path.append(os.getcwd()) | ||
print(''hi'')' | ||
sidecars: | ||
- name: sidecar-name | ||
volumeMounts: | ||
- mountPath: /whatever | ||
name: something |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""This example showcases the user of a user container with a volume mount.""" | ||
|
||
from hera.workflows import ( | ||
DAG, | ||
UserContainer, | ||
Workflow, | ||
models as m, | ||
script, | ||
) | ||
|
||
|
||
@script( | ||
sidecars=[ | ||
UserContainer(name="sidecar-name", volume_mounts=[m.VolumeMount(mount_path="/whatever", name="something")]) | ||
] | ||
) | ||
def foo(): | ||
print("hi") | ||
|
||
|
||
with Workflow(generate_name="sidecar-volume-mount-", entrypoint="d") as w: | ||
with DAG(name="d"): | ||
foo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters