Skip to content

Commit

Permalink
Add argocd support (#8)
Browse files Browse the repository at this point in the history
* Add Argo support

* Update docs

* Update argo variable name
  • Loading branch information
martinhaus authored Sep 22, 2021
1 parent 86dd6dd commit 7486ab3
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ No modules.
| [aws_iam_role.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role_policy_attachment.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [helm_release.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [kubernetes_manifest.this](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/manifest) | resource |
| [aws_iam_policy_document.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.cluster_autoscaler_assume](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
Expand All @@ -63,6 +64,12 @@ No modules.
| <a name="input_cluster_identity_oidc_issuer"></a> [cluster\_identity\_oidc\_issuer](#input\_cluster\_identity\_oidc\_issuer) | The OIDC Identity issuer for the cluster | `string` | n/a | yes |
| <a name="input_cluster_identity_oidc_issuer_arn"></a> [cluster\_identity\_oidc\_issuer\_arn](#input\_cluster\_identity\_oidc\_issuer\_arn) | The OIDC Identity issuer ARN for the cluster that can be used to associate IAM roles with a service account | `string` | n/a | yes |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | The name of the cluster | `string` | n/a | yes |
| <a name="input_argo_application_enabled"></a> [argo\_application\_enabled](#input\_argo\_application\_enabled) | If set to true, the module will be deployed as ArgoCD application, otherwise it will be deployed as a Helm release | `bool` | `false` | no |
| <a name="input_argo_destionation_server"></a> [argo\_destionation\_server](#input\_argo\_destionation\_server) | Destination server for ArgoCD Application | `string` | `"https://kubernetes.default.svc"` | no |
| <a name="input_argo_info"></a> [argo\_info](#input\_argo\_info) | ArgoCD info manifest parameter | `list` | <pre>[<br> {<br> "name": "terraform",<br> "value": "true"<br> }<br>]</pre> | no |
| <a name="input_argo_namespace"></a> [argo\_namespace](#input\_argo\_namespace) | Namespace to deploy ArgoCD application CRD to | `string` | `"argo"` | no |
| <a name="input_argo_project"></a> [argo\_project](#input\_argo\_project) | ArgoCD Application project | `string` | `"default"` | no |
| <a name="input_argo_sync_policy"></a> [argo\_sync\_policy](#input\_argo\_sync\_policy) | ArgoCD syncPolicy manifest parameter | `map` | `{}` | no |
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Variable indicating whether deployment is enabled | `bool` | `true` | no |
| <a name="input_helm_chart_name"></a> [helm\_chart\_name](#input\_helm\_chart\_name) | Helm chart name to be installed | `string` | `"cluster-autoscaler"` | no |
| <a name="input_helm_chart_version"></a> [helm\_chart\_version](#input\_helm\_chart\_version) | Version of the Helm chart | `string` | `"9.10.3"` | no |
Expand Down
30 changes: 30 additions & 0 deletions argo.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
resource "kubernetes_manifest" "this" {
count = var.argo_application_enabled ? 1 : 0
manifest = {
"apiVersion" = "argoproj.io/v1alpha1"
"kind" = "Application"
"metadata" = {
"name" = var.helm_release_name
"namespace" = var.argo_namespace
}
"spec" = {
"project" = var.argo_project
"source" = {
"repoURL" = var.helm_repo_url
"chart" = var.helm_chart_name
"targetRevision" = var.helm_chart_version
"helm" = {
"releaseName" = var.helm_release_name
"parameters" = [for k, v in var.settings : tomap({ "forceString" : true, "name" : k, "value" : v })]
"values" = data.utils_deep_merge_yaml.values[0].output
}
}
"destination" = {
"server" = var.argo_destionation_server
"namespace" = var.k8s_namespace
}
"syncPolicy" = var.argo_sync_policy
"info" = var.argo_info
}
}
}
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ data "utils_deep_merge_yaml" "values" {
}

resource "helm_release" "cluster_autoscaler" {
count = var.enabled ? 1 : 0
count = var.enabled && !var.argo_application_enabled ? 1 : 0
chart = var.helm_chart_name
create_namespace = var.helm_create_namespace
namespace = var.k8s_namespace
Expand Down
38 changes: 38 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,41 @@ variable "values" {
default = ""
description = "Additional yaml encoded values which will be passed to the Helm chart, see https://hub.helm.sh/charts/stable/cluster-autoscaler"
}

variable "argo_namespace" {
type = string
default = "argo"
description = "Namespace to deploy ArgoCD application CRD to"
}


variable "argo_application_enabled" {
type = bool
default = false
description = "If set to true, the module will be deployed as ArgoCD application, otherwise it will be deployed as a Helm release"
}

variable "argo_destionation_server" {
type = string
default = "https://kubernetes.default.svc"
description = "Destination server for ArgoCD Application"
}

variable "argo_project" {
type = string
default = "default"
description = "ArgoCD Application project"
}

variable "argo_info" {
default = [{
"name" = "terraform"
"value" = "true"
}]
description = "ArgoCD info manifest parameter"
}

variable "argo_sync_policy" {
description = "ArgoCD syncPolicy manifest parameter"
default = {}
}

0 comments on commit 7486ab3

Please sign in to comment.