Can a workflow be submitted using kubectl instead of argo?

1.1k views Asked by At

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
1

There are 1 answers

1
L42 On BEST ANSWER

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
...