A Terraform module for provisioning and configuring ArgoCD applications. This module can be used with or without the Project-Octal terraform-kubernetes-argocd module. The only hard requirement is a Kubernetes cluster with a functioning ArgoCD deployment and project for the application to reside in.
Note: This repository has been renamed from terraform-argocd-application
to terraform-kubernetes-argocd-application
to better follow the Terraform module naming convention.
When upgrading from v1.0.5 or older to v2.0.0+ you will need to import all the argocd application manifests
Import the resource state from the cluster
# Import the ArgoCD application using the new provider
terraform import -var-file=secrets.tfvars 'module.kubedb_argocd_application.kubernetes_manifest.argo_application' "apiVersion=argoproj.io/v1alpha1,kind=Application,namespace=kube-argocd,name=kubedb"
# Delete the state reference to the old k8s_manifest object
terraform state rm 'module.kubedb_argocd_application.k8s_manifest.argo_application'
module "project" {
source = "project-octal/argocd-project/kubernetes"
version = "2.0.0"
argocd_namespace = data.terraform_remote_state.infra.outputs.cluster_argocd_namespace
name = local.instance_name
description = local.project_description
destinations = [
{
server = "https://kubernetes.default.svc"
namespace = kubernetes_namespace.kergiva_namespace.metadata.0.name
}
]
}
module "argocd_application" {
source = "project-octal/argocd-application/kubernetes"
version = "2.0.0"
argocd_namespace = "kube-argocd"
destination_server = "https://kubernetes.default.svc"
project = module.project.name
name = "example-application-name"
namespace = "argo-project-permitted-namespace"
repo_url = "https://argo-project-permitted-repo-url/"
chart = "foo-chart"
target_revision = "0.0.1"
helm_values = {
helm_values = "go-here"
}
automated_self_heal = true
automated_prune = true
labels = {
custom = "lables-to-apply"
}
}
// The following module will create app that deploys from git repo under chart directory
// chart variable is applicable for git based application sources. For that reason, it should be set empty
// Otherwise, argocd app will be in unknown state
module "argocd_application_git" {
source = "project-octal/argocd-application/kubernetes"
version = "2.0.0"
argocd_namespace = "kube-argocd"
destination_server = "https://kubernetes.default.svc"
project = module.project.name
name = "example-application-name"
namespace = "argo-project-permitted-namespace"
repo_url = "[email protected]:myorg/myrepo.git"
chart = ""
path = "Chart" // location of helm chart in the git repo
target_revision = "master" // git branch name
helm_values = {
helm_values = "go-here"
}
automated_self_heal = true
automated_prune = true
labels = {
custom = "lables-to-apply"
}
}
Name | Version |
---|---|
terraform | >= 0.14.8, < 2.0.0 |
Name | Version |
---|---|
kubernetes | 2.6.1 |
No modules.
Name | Type |
---|---|
kubernetes_manifest.argo_application | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
argocd_namespace | The name of the target ArgoCD Namespace | string |
n/a | yes |
automated_prune | Specifies if resources should be pruned during auto-syncing | bool |
false |
no |
automated_self_heal | Specifies if partial app sync should be executed when resources are changed only in target Kubernetes cluster and no git change detected | bool |
false |
no |
cascade_delete | Set to true if this application should cascade delete | bool |
false |
no |
chart | The name of the Helm chart | string |
n/a | yes |
destination_server | n/a | string |
"https://kubernetes.default.svc" |
no |
helm_parameters | Parameters that will override helm_values | list(object({ |
[] |
no |
helm_values | Helm values as a block of yaml | any |
{} |
no |
ignore_differences | Ignore differences at the specified json pointers | list(object({ kind : string, group : string, name : string, jsonPointers : list(string) })) |
[] |
no |
labels | n/a | map(string) |
{} |
no |
name | The name of this application | string |
n/a | yes |
namespace | n/a | string |
n/a | yes |
path | n/a | string |
"" |
no |
project | The project that this ArgoCD application will be placed into. | string |
n/a | yes |
release_name | Release name override (defaults to application name) | string |
null |
no |
repo_url | Source of the Helm application manifests | string |
n/a | yes |
retry_backoff_duration | The amount to back off. Default unit is seconds, but could also be a duration (e.g. 2m , 1h ) |
string |
"5s" |
no |
retry_backoff_factor | A factor to multiply the base duration after each failed retry | number |
2 |
no |
retry_backoff_max_duration | The maximum amount of time allowed for the backoff strategy | string |
"3m" |
no |
retry_limit | Number of failed sync attempt retries; unlimited number of attempts if less than 0 | number |
5 |
no |
sync_option_create_namespace | Namespace Auto-Creation ensures that namespace specified as the application destination exists in the destination cluster. | bool |
true |
no |
sync_option_validate | disables resource validation (equivalent to 'kubectl apply --validate=true') | bool |
false |
no |
sync_options | A list of sync options to apply to the application | list(string) |
[] |
no |
target_revision | Revision of the Helm application manifests to use | string |
"" |
no |
No outputs.