Skip to content

Commit

Permalink
feat: Add argo workflows add on module (#1110)
Browse files Browse the repository at this point in the history
Co-authored-by: Victor Gu <ec2-user@ip-10-1-1-13.us-west-2.compute.internal>
  • Loading branch information
victorgu-github and Victor Gu committed Nov 1, 2022
1 parent 7c6f16d commit 3634343
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/add-ons/argo-workflows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Argo Workflows

[Argo Workflows](https://argoproj.github.io/argo-workflows/) is an open source container-native workflow engine for orchestrating parallel jobs on Kubernetes. It is implemented as a Kubernetes CRD (Custom Resource Definition). As a result, Argo workflows can be managed using kubectl and natively integrates with other Kubernetes services such as volumes, secrets, and RBAC.

For complete project documentation, please visit the [Argo Workflows documentation site](https://argoproj.github.io/argo-workflows/).

[DoEKS has an example demonstrates how to use Argo Workflows to assign jobs to Amazon EKS] (https://awslabs.github.io/data-on-eks/docs/job-schedulers-eks/argo-workflows-eks)

## Usage

Argo Workflows can be deployed by enabling the add-on via the following.

```hcl
enable_argo_workflows = true
```


```
### GitOps Configuration
The following properties are made available for use when managing the add-on via GitOps.
```
argoWorkflows = {
enable = true
}
```
3 changes: 3 additions & 0 deletions modules/kubernetes-addons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
| <a name="module_app_2048"></a> [app\_2048](#module\_app\_2048) | ./app-2048 | n/a |
| <a name="module_appmesh_controller"></a> [appmesh\_controller](#module\_appmesh\_controller) | ./appmesh-controller | n/a |
| <a name="module_argo_rollouts"></a> [argo\_rollouts](#module\_argo\_rollouts) | ./argo-rollouts | n/a |
| <a name="module_argo_workflows"></a> [argo\_workflows](#module\_argo\_workflows) | ./argo-workflows | n/a |
| <a name="module_argocd"></a> [argocd](#module\_argocd) | ./argocd | n/a |
| <a name="module_aws_cloudwatch_metrics"></a> [aws\_cloudwatch\_metrics](#module\_aws\_cloudwatch\_metrics) | ./aws-cloudwatch-metrics | n/a |
| <a name="module_aws_coredns"></a> [aws\_coredns](#module\_aws\_coredns) | ./aws-coredns | n/a |
Expand Down Expand Up @@ -116,6 +117,7 @@
| <a name="input_appmesh_helm_config"></a> [appmesh\_helm\_config](#input\_appmesh\_helm\_config) | AppMesh Helm Chart config | `any` | `{}` | no |
| <a name="input_appmesh_irsa_policies"></a> [appmesh\_irsa\_policies](#input\_appmesh\_irsa\_policies) | Additional IAM policies for a IAM role for service accounts | `list(string)` | `[]` | no |
| <a name="input_argo_rollouts_helm_config"></a> [argo\_rollouts\_helm\_config](#input\_argo\_rollouts\_helm\_config) | Argo Rollouts Helm Chart config | `any` | `null` | no |
| <a name="input_argo_workflows_helm_config"></a> [argo\_workflows\_helm\_config](#input\_argo\_workflows\_helm\_config) | Argo workflows Helm Chart config | `any` | `null` | no |
| <a name="input_argocd_applications"></a> [argocd\_applications](#input\_argocd\_applications) | Argo CD Applications config to bootstrap the cluster | `any` | `{}` | no |
| <a name="input_argocd_helm_config"></a> [argocd\_helm\_config](#input\_argocd\_helm\_config) | Argo CD Kubernetes add-on config | `any` | `{}` | no |
| <a name="input_argocd_manage_add_ons"></a> [argocd\_manage\_add\_ons](#input\_argocd\_manage\_add\_ons) | Enable managing add-on configuration via ArgoCD App of Apps | `bool` | `false` | no |
Expand Down Expand Up @@ -180,6 +182,7 @@
| <a name="input_enable_app_2048"></a> [enable\_app\_2048](#input\_enable\_app\_2048) | Enable sample app 2048 | `bool` | `false` | no |
| <a name="input_enable_appmesh_controller"></a> [enable\_appmesh\_controller](#input\_enable\_appmesh\_controller) | Enable AppMesh add-on | `bool` | `false` | no |
| <a name="input_enable_argo_rollouts"></a> [enable\_argo\_rollouts](#input\_enable\_argo\_rollouts) | Enable Argo Rollouts add-on | `bool` | `false` | no |
| <a name="input_enable_argo_workflows"></a> [enable\_argo\_workflows](#input\_enable\_argo\_workflows) | Enable Argo workflows add-on | `bool` | `false` | no |
| <a name="input_enable_argocd"></a> [enable\_argocd](#input\_enable\_argocd) | Enable Argo CD Kubernetes add-on | `bool` | `false` | no |
| <a name="input_enable_aws_cloudwatch_metrics"></a> [enable\_aws\_cloudwatch\_metrics](#input\_enable\_aws\_cloudwatch\_metrics) | Enable AWS CloudWatch Metrics add-on for Container Insights | `bool` | `false` | no |
| <a name="input_enable_aws_efs_csi_driver"></a> [enable\_aws\_efs\_csi\_driver](#input\_enable\_aws\_efs\_csi\_driver) | Enable AWS EFS CSI driver add-on | `bool` | `false` | no |
Expand Down
47 changes: 47 additions & 0 deletions modules/kubernetes-addons/argo-workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Argo Workflows

## Introduction

[Argo Workflows](https://argoproj.github.io/argo-workflows/) is an event-driven workflow automation framework for Kubernetes which helps you trigger K8s objects, Argo Workflows, Serverless workloads, etc. on events from a variety of sources like webhooks, S3, schedules, messaging queues, gcp pubsub, sns, sqs, etc.

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.72 |
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.10 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | >= 2.10 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_helm_addon"></a> [helm\_addon](#module\_helm\_addon) | ../helm-addon | n/a |

## Resources

| Name | Type |
|------|------|
| [kubernetes_namespace_v1.this](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace_v1) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_addon_context"></a> [addon\_context](#input\_addon\_context) | Input configuration for the addon | <pre>object({<br> aws_caller_identity_account_id = string<br> aws_caller_identity_arn = string<br> aws_eks_cluster_endpoint = string<br> aws_partition_id = string<br> aws_region_name = string<br> eks_cluster_id = string<br> eks_oidc_issuer_url = string<br> eks_oidc_provider_arn = string<br> tags = map(string)<br> irsa_iam_role_path = string<br> irsa_iam_permissions_boundary = string<br> })</pre> | n/a | yes |
| <a name="input_helm_config"></a> [helm\_config](#input\_helm\_config) | Helm provider config for the argo workflows. | `any` | `{}` | no |
| <a name="input_manage_via_gitops"></a> [manage\_via\_gitops](#input\_manage\_via\_gitops) | Determines if the add-on should be managed via GitOps. | `bool` | `false` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_argocd_gitops_config"></a> [argocd\_gitops\_config](#output\_argocd\_gitops\_config) | Configuration used for managing the add-on with ArgoCD |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
34 changes: 34 additions & 0 deletions modules/kubernetes-addons/argo-workflows/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
locals {
name = "argo-workflows"

# https://github.com/argoproj/argo-helm/tree/main/charts/argo-workflows
default_helm_config = {
name = local.name
chart = local.name
repository = "https://argoproj.github.io/argo-helm"
version = "v0.20.1"
namespace = local.name
create_namespace = true
description = "Argo events Helm chart deployment configuration"
}

helm_config = merge(local.default_helm_config, var.helm_config)

argocd_gitops_config = {
enable = true
}
}

module "helm_addon" {
source = "../helm-addon"

helm_config = local.helm_config
addon_context = var.addon_context
}

resource "kubernetes_namespace_v1" "this" {
count = try(local.helm_config["create_namespace"], true) && local.helm_config["namespace"] != "kube-system" ? 1 : 0
metadata {
name = local.helm_config["namespace"]
}
}
4 changes: 4 additions & 0 deletions modules/kubernetes-addons/argo-workflows/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "argocd_gitops_config" {
description = "Configuration used for managing the add-on with ArgoCD"
value = var.manage_via_gitops ? local.argocd_gitops_config : null
}
28 changes: 28 additions & 0 deletions modules/kubernetes-addons/argo-workflows/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
variable "helm_config" {
description = "Helm provider config for the argo workflows."
type = any
default = {}
}

variable "manage_via_gitops" {
description = "Determines if the add-on should be managed via GitOps."
type = bool
default = false
}

variable "addon_context" {
description = "Input configuration for the addon"
type = object({
aws_caller_identity_account_id = string
aws_caller_identity_arn = string
aws_eks_cluster_endpoint = string
aws_partition_id = string
aws_region_name = string
eks_cluster_id = string
eks_oidc_issuer_url = string
eks_oidc_provider_arn = string
tags = map(string)
irsa_iam_role_path = string
irsa_iam_permissions_boundary = string
})
}
14 changes: 14 additions & 0 deletions modules/kubernetes-addons/argo-workflows/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_version = ">= 1.0.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.72"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.10"
}
}
}
1 change: 1 addition & 0 deletions modules/kubernetes-addons/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ locals {
vpa = var.enable_vpa ? module.vpa[0].argocd_gitops_config : null
yunikorn = var.enable_yunikorn ? module.yunikorn[0].argocd_gitops_config : null
argoRollouts = var.enable_argo_rollouts ? module.argo_rollouts[0].argocd_gitops_config : null
argoWorkflows = var.enable_argo_workflows ? module.argo_workflows[0].argocd_gitops_config : null
karpenter = var.enable_karpenter ? module.karpenter[0].argocd_gitops_config : null
kubernetesDashboard = var.enable_kubernetes_dashboard ? module.kubernetes_dashboard[0].argocd_gitops_config : null
awsCloudWatchMetrics = var.enable_aws_cloudwatch_metrics ? module.aws_cloudwatch_metrics[0].argocd_gitops_config : null
Expand Down
8 changes: 8 additions & 0 deletions modules/kubernetes-addons/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ module "argo_rollouts" {
addon_context = local.addon_context
}

module "argo_workflows" {
count = var.enable_argo_workflows ? 1 : 0
source = "./argo-workflows"
helm_config = var.argo_workflows_helm_config
manage_via_gitops = var.argocd_manage_add_ons
addon_context = local.addon_context
}

module "aws_efs_csi_driver" {
count = var.enable_aws_efs_csi_driver ? 1 : 0
source = "./aws-efs-csi-driver"
Expand Down
13 changes: 13 additions & 0 deletions modules/kubernetes-addons/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,19 @@ variable "cert_manager_istio_csr_helm_config" {
default = {}
}

#-----------Argo workflows ADDON-------------
variable "enable_argo_workflows" {
description = "Enable Argo workflows add-on"
type = bool
default = false
}

variable "argo_workflows_helm_config" {
description = "Argo workflows Helm Chart config"
type = any
default = null
}

#-----------Argo Rollouts ADDON-------------
variable "enable_argo_rollouts" {
description = "Enable Argo Rollouts add-on"
Expand Down

0 comments on commit 3634343

Please sign in to comment.