Skip to content

Commit

Permalink
add support for chart version 5.x (#3)
Browse files Browse the repository at this point in the history
* add support for argocd chart v5

* remove chart version constraint

* update docs
  • Loading branch information
nilic authored Aug 30, 2022
1 parent bcd561b commit e9389b6
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 37 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ This module allows for deploying an ArgoCD instance on Kubernetes and OpenShift

Optionally, Argo repository, project and application resources can be added by the module after deployment. This allows for ArgoCD bootstrap according to the [app of apps pattern](https://argo-cd.readthedocs.io/en/stable/operator-manual/cluster-bootstrapping/).

This module version supports ArgoCD charts up to (and not including) 5.0.0.

## Requirements

| Name | Version |
Expand All @@ -30,6 +28,7 @@ No modules.
| Name | Type |
|------|------|
| [helm_release.argocd](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [helm_release.argocd-apps](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
| [random_password.argocd_admin_password](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |

## Inputs
Expand All @@ -41,9 +40,10 @@ No modules.
| <a name="input_argocd_application_name"></a> [argocd\_application\_name](#input\_argocd\_application\_name) | Name of the ArgoCD application to be created | `string` | `null` | no |
| <a name="input_argocd_application_repo_branch"></a> [argocd\_application\_repo\_branch](#input\_argocd\_application\_repo\_branch) | Git repository branch where the ArgoCD application manifests reside | `string` | `"main"` | no |
| <a name="input_argocd_application_repo_path"></a> [argocd\_application\_repo\_path](#input\_argocd\_application\_repo\_path) | Path within the Git repository where the ArgoCD application manifests reside | `string` | `""` | no |
| <a name="input_argocd_apps_chart_version"></a> [argocd\_apps\_chart\_version](#input\_argocd\_apps\_chart\_version) | ArgoCD-apps chart version to install (used for creating project and application). If not specified, latest version is installed | `string` | `null` | no |
| <a name="input_argocd_chart_value_files"></a> [argocd\_chart\_value\_files](#input\_argocd\_chart\_value\_files) | A list of paths to ArgoCD Helm chart values files to be added to the ArgoCD installation | `list(string)` | `[]` | no |
| <a name="input_argocd_chart_values"></a> [argocd\_chart\_values](#input\_argocd\_chart\_values) | A map of key/value to set ArgoCD chart values or override defaults.<br>The key must be specified as the full path to the key, e.g: `configs.secret.bitbucketServerSecret`. <br>Please consult [ArgoCD Helm chart docs](https://github.com/argoproj/argo-helm/tree/main/charts/argo-cd). | `map(string)` | `{}` | no |
| <a name="input_argocd_chart_version"></a> [argocd\_chart\_version](#input\_argocd\_chart\_version) | ArgoCD chart version to install. If not specified, latest supported version is installed | `string` | `"4.10.9"` | no |
| <a name="input_argocd_chart_version"></a> [argocd\_chart\_version](#input\_argocd\_chart\_version) | ArgoCD chart version to install. If not specified, latest version is installed | `string` | `null` | no |
| <a name="input_argocd_ingress_enabled"></a> [argocd\_ingress\_enabled](#input\_argocd\_ingress\_enabled) | Whether to enable a Kubernetes Ingress resource for the ArgoCD server. Will be set to `false` if `argocd_openshift` set to `true` | `bool` | `false` | no |
| <a name="input_argocd_namespace"></a> [argocd\_namespace](#input\_argocd\_namespace) | Kubernetes/OpenShift namespace to install ArgoCD chart to | `string` | `"argocd"` | no |
| <a name="input_argocd_namespace_create"></a> [argocd\_namespace\_create](#input\_argocd\_namespace\_create) | Whether to create the namespace where ArgoCD chart will be installed | `bool` | `true` | no |
Expand Down
22 changes: 19 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* This module allows for deploying an ArgoCD instance on Kubernetes and OpenShift via the [official ArgoCD Helm chart](https://github.com/argoproj/argo-helm).
*
* Optionally, Argo repository, project and application resources can be added by the module after deployment. This allows for ArgoCD bootstrap according to the [app of apps pattern](https://argo-cd.readthedocs.io/en/stable/operator-manual/cluster-bootstrapping/).
*
* This module version supports ArgoCD charts up to (and not including) 5.0.0.
*/

locals {
Expand Down Expand Up @@ -73,7 +71,7 @@ resource "helm_release" "argocd" {
atomic = true
dependency_update = true

values = concat(local.server_settings, local.repository, local.project, local.application, var.argocd_chart_value_files)
values = concat(local.server_settings, local.repository, var.argocd_chart_value_files)

dynamic "set" {
for_each = var.argocd_chart_values
Expand All @@ -84,3 +82,21 @@ resource "helm_release" "argocd" {
}
}
}

resource "helm_release" "argocd-apps" {
count = (local.additional_project || local.additional_application) ? 1 : 0

name = "argocd-apps"
chart = "argocd-apps"
repository = "https://argoproj.github.io/argo-helm"
version = var.argocd_apps_chart_version
namespace = helm_release.argocd.namespace
create_namespace = false
timeout = 600
wait = true
wait_for_jobs = true
atomic = true
dependency_update = true

values = concat(local.project, local.application)
}
33 changes: 16 additions & 17 deletions templates/values-application.tftpl
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
server:
additionalApplications:
- name: ${name}
applications:
- name: ${name}
namespace: ${namespace}
project: ${project}
source:
repoURL: ${repo_url}
targetRevision: ${repo_branch}
path: ${repo_path}
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: ${namespace}
project: ${project}
source:
repoURL: ${repo_url}
targetRevision: ${repo_branch}
path: ${repo_path}
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: ${namespace}
syncPolicy:
automated:
prune: false
selfHeal: false
syncPolicy:
automated:
prune: false
selfHeal: false
23 changes: 11 additions & 12 deletions templates/values-project.tftpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
server:
additionalProjects:
- name: ${name}
namespace: ${namespace}
sourceRepos:
- "*"
destinations:
- namespace: "*"
server: "https://kubernetes.default.svc"
clusterResourceWhitelist:
- group: "*"
kind: "*"
projects:
- name: ${name}
namespace: ${namespace}
sourceRepos:
- "*"
destinations:
- namespace: "*"
server: "https://kubernetes.default.svc"
clusterResourceWhitelist:
- group: "*"
kind: "*"
10 changes: 8 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
variable "argocd_chart_version" {
description = "ArgoCD chart version to install. If not specified, latest supported version is installed"
description = "ArgoCD chart version to install. If not specified, latest version is installed"
type = string
default = "4.10.9"
default = null
}

variable "argocd_apps_chart_version" {
description = "ArgoCD-apps chart version to install (used for creating project and application). If not specified, latest version is installed"
type = string
default = null
}

variable "argocd_timezone" {
Expand Down

0 comments on commit e9389b6

Please sign in to comment.