Argo: Submit raw workflow to the REST api

Created on 10 Aug 2020  路  6Comments  路  Source: argoproj/argo

Summary

Can we send directly raw yaml workflows to the REST api?
It seems that it is possible using K8s API but it is not documented anymore: #1163 and #1757.

Motivation

I would appreciate to describe my workflows in YAML and submit them directly to the API,
without the need to convert them into the OpenAPI format.

question wontfix

Most helpful comment

I have given up submitting the template through the API since I needed to specify the parameters and it is not possible using the POST /api/v1/workflows/{namespace} endpoint.

We now deploy a WorkflowTemplate using helm and trigger a Workflow using the POST /api/v1/workflows/{namespace}/submit endpoint using a JSON message:

{
  "resourceKind": "WorkflowTemplate",
  "resourceName": "my-workflow-template-name",
  "submitOptions": {
    "parameters": ["my-fist-param=2020-07-20", "my-second-param=2020-07-21"]
  }
}

It would have been nice to be able to create a workflow and specify its parameters using the POST /api/v1/workflows/{namespace} endpoint.

All 6 comments

In short - no. You must use the Open API format as described. However, you can submit YAML and that YAML contains the workflow itself:

https://argoproj.github.io/argo/swagger/#post_2

If I follow the documentation of the POST /api/v1/workflows/{namespace} endpoint, I have to submit a io.argoproj.workflow.v1alpha1.WorkflowCreateRequest that indeed contains the workflow.

Something like that should work:

curl --location --request POST 'http://localhost:2746/api/v1/workflows/argo' \
--header 'Content-Type: application/yaml' \
--data-raw 'workflow:
  apiVersion: argoproj.io/v1alpha1
  kind: Workflow
  metadata:
    generateName: hello-world-
    labels:
      workflows.argoproj.io/archive-strategy: "false"
  spec:
    entrypoint: whalesay
    templates:
    - name: whalesay
      container:
        image: docker/whalesay:latest
        command: [cowsay]
        args: ["hello world"]
'

But I get

{
  "error":"invalid character 'w' looking for beginning of value",
  "code":3,
  "message":"invalid character 'w' looking for beginning of value"
}

Since when does the API support YAML? Or am I just using the wrong Content-Type?

I have given up submitting the template through the API since I needed to specify the parameters and it is not possible using the POST /api/v1/workflows/{namespace} endpoint.

We now deploy a WorkflowTemplate using helm and trigger a Workflow using the POST /api/v1/workflows/{namespace}/submit endpoint using a JSON message:

{
  "resourceKind": "WorkflowTemplate",
  "resourceName": "my-workflow-template-name",
  "submitOptions": {
    "parameters": ["my-fist-param=2020-07-20", "my-second-param=2020-07-21"]
  }
}

It would have been nice to be able to create a workflow and specify its parameters using the POST /api/v1/workflows/{namespace} endpoint.

you can submit YAML and that YAML contains the workflow itself:

I think I'm incorrect about this. I think that it must be JSON. You should be able to pass the same submitOptions you to the the /submit endpoint.

I would like to pass the submitOptions to the POST /api/v1/workflows/{namespace} endpoint
to be able to create a Workflow and specify its parameters

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings