简体   繁体   中英

Can a workflow be submitted using kubectl instead of argo?

I have the file 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

I can submit this successfully like this: argo submit -n workflows apps/workflows/example-workflow-cowsay.yml .

Can I get the same thing done using kubectl directly? I tried the below but it fails:

$ k apply -n workflows -f apps/workflows/example-workflow-cowsay.yml                                                                       
error: from hello-world-: cannot use generate name with apply

Yes, it's right there in the readme ( version at the time of answering ).

kubectl -n workflows create -f apps/workflows/example-workflow-cowsay.yml did the job.


To elaborate a bit: This makes sense, as what I was trying to "apply" was a single run of a workflow (think an object instance rather than a class). If I'd tried to apply a CronWorkflow, then kubectl apply would have worked. The error message that I got:

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

Told me about it, but I didn't understand it at the time. This is invalid:

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

But this is valid:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM