代码之家  ›  专栏  ›  技术社区  ›  L42

可以使用kubectl而不是argo提交工作流吗?

  •  0
  • L42  · 技术社区  · 3 年前

    我有文件 example-workflow-cowsay.yml :

    apiVersion: argoproj.io/v1alpha1
    kind: Workflow
    metadata:
      generateName: hello-world-
    spec:
      entrypoint: whalesay
      templates:
      - name: whalesay
        container:
          image: docker/whalesay
          command: [cowsay]
          args: ["hello world"]
          resources:
            limits:
              memory: 32Mi
              cpu: 100m
    

    我可以这样成功提交: argo submit -n workflows apps/workflows/example-workflow-cowsay.yml

    我可以用做同样的事情吗 kubectl 直接地我尝试了以下操作,但失败了:

    $ k apply -n workflows -f apps/workflows/example-workflow-cowsay.yml                                                                       
    error: from hello-world-: cannot use generate name with apply
    
    1 回复  |  直到 3 年前
        1
  •  2
  •   L42    3 年前

    是的,就在那儿 readme ( version at the time of answering )。

    kubectl -n workflows create -f apps/workflows/example-workflow-cowsay.yml 完成了任务。


    详细说明一下:这是有道理的,因为我试图“应用”的是工作流的一次运行(想想对象实例而不是类)。如果我尝试应用CronWorkflow,那么 kubectl apply 会起作用的。我收到的错误消息:

    error: from hello-world-: cannot use generate name with apply
    

    告诉过我这件事,但当时我不明白。这是无效的:

    apiVersion: argoproj.io/v1alpha1
    kind: CronWorkflow
    metadata:
      generateName: some-name
    ...
    

    但这是有效的:

    apiVersion: argoproj.io/v1alpha1
    kind: CronWorkflow
    metadata:
      name: some-name
    ...
    
    推荐文章