Skip to content

Commit

Permalink
Add argocd support
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhaus committed Sep 10, 2021
1 parent 02fe9c5 commit 66d0e77
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 @@ -42,11 +42,18 @@ No modules.
| Name | Type |
|------|------|
| [helm_release.prometheus_node_exporter](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 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <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` | `"prometheus-node-exporter"` | no |
| <a name="input_helm_chart_version"></a> [helm\_chart\_version](#input\_helm\_chart\_version) | Version of the Helm chart | `string` | `"2.0.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" = var.values
}
}
"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
@@ -1,5 +1,5 @@
resource "helm_release" "prometheus_node_exporter" {
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 @@ -57,3 +57,41 @@ variable "values" {
default = ""
description = "Additional yaml encoded values which will be passed to the Helm chart."
}

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 66d0e77

Please sign in to comment.