跳至内容

HTTP 模板

v3.2 及更高版本

HTTP Template是一种可以执行HTTP请求的模板类型。

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: http-template-
spec:
  entrypoint: main
  templates:
    - name: main
      steps:
        - - name: get-google-homepage
            template: http
            arguments:
              parameters: [{name: url, value: "https://www.google.com"}]
    - name: http
      inputs:
        parameters:
          - name: url
      http:
        timeoutSeconds: 20 # Default 30
        url: "{{inputs.parameters.url}}"
        method: "GET" # Default GET
        headers:
          - name: "x-header-name"
            value: "test-value"
        # Template will succeed if evaluated to true, otherwise will fail
        # Available variables:
        #  request.body: string, the request body
        #  request.headers: map[string][]string, the request headers
        #  response.url: string, the request url
        #  response.method: string, the request method
        #  response.statusCode: int, the response status code
        #  response.body: string, the response body
        #  response.headers: map[string][]string, the response headers
        successCondition: "response.body contains \"google\"" # available since v3.3
        body: "test body" # Change request body

Argo 智能体

HTTP模板使用Argo智能体,该智能体独立于控制器执行请求。智能体与工作流控制器通过WorkflowTaskSet CRD进行通信,该CRD会为每个需要使用Agent的正在运行的Workflow创建。

要使用Argo智能体,您需要确保已添加适当的workflow RBAC来为Argo Workflows配置智能体角色。示例智能体角色可在the quick-start manifests中找到。


有问题吗?

Search on GitHub Discussions and Slack.