Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature]: wf_spec support for CronWorkflows #136

Open
1 task done
wesbragagt opened this issue Sep 17, 2024 · 3 comments
Open
1 task done

[feature]: wf_spec support for CronWorkflows #136

wesbragagt opened this issue Sep 17, 2024 · 3 comments
Assignees
Labels
feature A new feature request triage Needs to be triaged

Comments

@wesbragagt
Copy link
Contributor

Prior Search

  • I have already searched this project's issues to determine if a similar request has already been made.

What new functionality would you like to see?

I would love to be able to create CronWorkflows using the wf_spec module as well.

How would you use this new functionality?

I imagine being able to pass an object schedule that contains the properties outlined in the documentation https://argo-workflows.readthedocs.io/en/latest/cron-workflows/#cronworkflow-options.

@wesbragagt wesbragagt added feature A new feature request triage Needs to be triaged labels Sep 17, 2024
@wesbragagt
Copy link
Contributor Author

For my use case I ended up extending the kube manifest:

resource "kubectl_manifest" "workflows_manifests" {
   for_each = {
    for key, value in var.workflows : key => {
      workflowType = value.schedule != null ? "CronWorkflow" : "WorkflowTemplate"
      spec = merge(
        module.workflows[key].workflow_spec,
        {
          schedule = value.schedule != null ? value.schedule.cron : null
          concurrencyPolicy = value.schedule != null ? value.schedule.concurrencyPolicy : null
          timezone = value.schedule != null ? value.schedule.timezone : null
          workflowSpec = value.schedule != null ? {
            entrypoint = local.entrypoint_key
            templates = module.workflows[key].workflow_spec.templates
          } : null
        }
      )
    }
  }

  yaml_body = yamlencode({
    apiVersion = "argoproj.io/v1alpha1"
    kind       = each.value.workflowType
    metadata = {
      namespace = var.namespace
      name      = module.workflows[each.key].name
      labels    = module.workflows[each.key].labels
    }
    spec = each.value.spec
  })

  server_side_apply = true
  force_conflicts   = true
}

@fullykubed
Copy link
Member

@wesbragagt Can you clarify the ask here?

wf_spec generates a workflow spec (workflowSpec is just a field on most argo CR manifests). The spec can be used on any argo CR: Workflow, WorkflowTemplate, CronWorkflow, ClusterWorkflowTemplate, etc. We'd expect you to use it similar to how you have shown above: by creating the actual resource with a kubectl_manifest iac block that utilized the output of wf_spec in the appropriate location (which depends on what CR you are creating).

It was an intentional design decision to only have the one wf_spec module that could be used when creating any Argo CR rather than individual modules for each argo CR.

What we could do is go ahead and create individual modules such as wf_cron, wf_template, wf_cluster_template, etc. that wraps wf_spec, adds additional fields (similar to how kube_deployment wraps kube_pod), and actually creates the resources. Is that the ask here?

However, we wouldn't add additional fields to wf_spec b/c the CronWorkflow fields are not on the Worfklow schema.

@wesbragagt
Copy link
Contributor Author

@fullykubed I believe having distinct modules for those similar but different enough specs is a good addition to the stack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature request triage Needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants