Str*_*ter 7 go kubernetes argoproj argo-workflows
我们有一个 golang 应用程序,它根据请求将 Argo 工作流提交给 kubernetes 集群。我想将 yaml 文件传递给其中一个步骤,我想知道这样做的选项是什么。
最后,我想将此文件传递给测试步骤,如下例所示:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: test-
spec:
entrypoint: test
templates:
- name: test
container:
image: gcr.io/testproj/test:latest
command: [bash]
source: |
python test.py --config_file_path=/path/to/config.yaml
Run Code Online (Sandbox Code Playgroud)
此步骤中使用的图像将有一个 python 脚本,该脚本接收此文件的路径,然后访问它。
要使用 golang 提交 Argo 工作流,我们使用以下依赖项:
谢谢你。
工作流参数通常是一小段文本或数字。但是,如果您的 yaml 文件相当小,您可以对其进行字符串编码并将其作为参数传递。
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: test-
spec:
entrypoint: test
arguments:
parameters:
- name: yaml
value: "string-encoded yaml"
templates:
- name: test
container:
image: gcr.io/testproj/test:latest
command: [bash]
source: |
# In this case, the string-encoding should be BASH-compatible.
python test.py --config_file_as_string="{{inputs.parameters.message}}"
Run Code Online (Sandbox Code Playgroud)
Argo 支持多种类型的工件。也许最简单的用例是原始参数类型。
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: test-
spec:
entrypoint: test
templates:
- name: test
inputs:
artifacts:
- name: yaml
path: /path/to/config.yaml
raw:
data: |
this is
the raw file
contents
container:
image: gcr.io/testproj/test:latest
command: [bash]
source: |
python test.py --config_file_path=/path/to/config.yaml
Run Code Online (Sandbox Code Playgroud)
此外raw,Argo 支持“S3、Artifactory、HTTP、[和] Git”工件(我认为还有其他)。
例如,如果您选择使用 S3,则可以从 golang 应用程序上传文件,然后将 S3 存储桶和密钥作为参数传递。
我对golang客户端不熟悉,但肯定支持传递参数,我认为也应该支持传递原始参数。
| 归档时间: |
|
| 查看次数: |
2207 次 |
| 最近记录: |