├── outputs.tf ├── examples └── simple-argo-cd-installation │ └── main.tf ├── variables.tf ├── LICENSE ├── .gitignore ├── README.md └── main.tf /outputs.tf: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/simple-argo-cd-installation/main.tf: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------------------------------------------------- 2 | # Example : Simple Argo CD installation 3 | # ---------------------------------------------------------------------------------------------------------------------- 4 | 5 | module "argo_cd" { 6 | source = "../../" 7 | 8 | namespace = "argocd" 9 | argo_cd_version = "1.8.7" 10 | } -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | variable "argo_cd_version" { 2 | description = "The version of Argo CD." 3 | type = string 4 | default = "1.8.7" 5 | } 6 | 7 | variable "namespace" { 8 | description = "The namespace in which Argo CD will be deployed." 9 | type = string 10 | default = "argocd" 11 | } 12 | 13 | variable "ha" { 14 | description = "True if the HA version of ArgoCD should be installed." 15 | type = bool 16 | default = false 17 | } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Local .terraform directories 2 | **/.terraform/* 3 | 4 | # .tfstate files 5 | *.tfstate 6 | *.tfstate.* 7 | 8 | # Crash log files 9 | crash.log 10 | 11 | # Ignore any .tfvars files that are generated automatically for each Terraform run. Most 12 | # .tfvars files are managed as part of configuration and so should be included in 13 | # version control. 14 | # 15 | # example.tfvars 16 | 17 | # Ignore override files as they are usually used to override resources locally and so 18 | # are not checked in 19 | override.tf 20 | override.tf.json 21 | *_override.tf 22 | *_override.tf.json 23 | 24 | # Intellij 25 | .idea/** -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Terraform Argo CD Module 2 | 3 | This modules make it easy to set up a fresh installation of Argo CD in your Kubernetes cluster. 4 | 5 | ## Compatibility 6 | 7 | This module is meant for use with Terraform >= 0.13.0 If you haven't [upgraded](https://www.terraform.io/upgrade-guides/0-13.html). 8 | 9 | If you want to use Terraform 0.12, use the tag v.1.0.0. Note that the version v.1.0.0 only support ArgoCD 1.5.5 while v1.1+ support all versions of ArgoCD. 10 | 11 | ## Dependencies 12 | This module use the [k8s Terraform provider](https://github.com/banzaicloud/terraform-provider-k8s) from Banzai Cloud to manages Kubernetes manifests 13 | . See the [documentation](https://github.com/banzaicloud/terraform-provider-k8s#installation) to see how to install it. 14 | 15 | ## Usage 16 | See the [examples folder](https://github.com/runoncloud/terraform-kubernetes-argocd/tree/master/examples/simple-argo-cd-installation). 17 | 18 | ```hcl 19 | module "argo_cd" { 20 | source = "runoncloud/argocd/kubernetes" 21 | 22 | namespace = "argocd" 23 | argo_cd_version = "1.8.7" 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /main.tf: -------------------------------------------------------------------------------- 1 | # ---------------------------------------------------------------------------------------------------------------------- 2 | # Module : Argo CD 3 | # Dependencies : 4 | # - https://www.terraform.io/docs/providers/kubernetes/index.html 5 | # - https://github.com/banzaicloud/terraform-provider-k8s 6 | # ---------------------------------------------------------------------------------------------------------------------- 7 | terraform { 8 | required_version = ">= 0.13.0" 9 | 10 | required_providers { 11 | kubernetes = { 12 | source = "hashicorp/kubernetes" 13 | version = ">= 1.13.0" 14 | } 15 | 16 | k8s = { 17 | source = "banzaicloud/k8s" 18 | version = ">= 0.8.0" 19 | } 20 | } 21 | } 22 | 23 | data "http" "install" { 24 | url = "https://raw.githubusercontent.com/argoproj/argo-cd/v${var.argo_cd_version}/manifests/install.yaml" 25 | } 26 | 27 | data "http" "install_ha" { 28 | url = "https://raw.githubusercontent.com/argoproj/argo-cd/v${var.argo_cd_version}/manifests/ha/install.yaml" 29 | } 30 | 31 | 32 | # ---------------------------------------------------------------------------------------------------------------------- 33 | # Namespaces 34 | # ---------------------------------------------------------------------------------------------------------------------- 35 | resource "kubernetes_namespace" "argo" { 36 | metadata { 37 | name = var.namespace 38 | } 39 | } 40 | 41 | # ---------------------------------------------------------------------------------------------------------------------- 42 | # ArgoCD Resources 43 | # ---------------------------------------------------------------------------------------------------------------------- 44 | locals { 45 | resources = split("\n---\n", var.ha ? data.http.install_ha.body : data.http.install.body) 46 | } 47 | 48 | resource "k8s_manifest" "resource" { 49 | count = length(local.resources) 50 | 51 | timeouts { 52 | create = "5m" 53 | delete = "5m" 54 | } 55 | 56 | namespace = var.namespace 57 | content = local.resources[count.index] 58 | 59 | depends_on = [kubernetes_namespace.argo] 60 | } 61 | --------------------------------------------------------------------------------