Skip to content

kuptan/terraform-k8s-argocd-bootstrap

Repository files navigation

Terraform K8s ArgoCD Bootstrap

License GitHub Release PR's Welcome

A terraform module that will bootstrap a Kubernetes cluster with ArgoCD.

Usage

variable "target_cluster_name" {
  description = "The cluster name where the ArgoCD will be installed"
  type        = string

  default = "operation-cluster"
}

variable "remote_clusters" {
  description = "Remote cluster to be managed by ArgoCD"
  type        = list(object({ name : string, namespaces : list(string) }))

  default = [{
    name       = "cluster-a"
    namespaces = ["default", "cert-manager", "monitoring"]
  }]
}

######### 
### AWS EKS target cluster credentials
#########
data "aws_eks_cluster" "target" {
  name = var.target_cluster_name
}

data "aws_eks_cluster_auth" "target" {
  name = var.target_cluster_name
}

provider "helm" {
  kubernetes {
    host                   = data.aws_eks_cluster.target.endpoint
    cluster_ca_certificate = base64decode(data.aws_eks_cluster.target.certificate_authority.0.data)
    token                  = data.aws_eks_cluster_auth.target.token
  }
}

provider "kubernetes" {
  host                   = data.aws_eks_cluster.target.endpoint
  cluster_ca_certificate = base64decode(data.aws_eks_cluster.target.certificate_authority.0.data)
  token                  = data.aws_eks_cluster_auth.target.token
}

module "argocd-bootstrap" {
  source = "kube-champ/argocd-bootstrap/k8s"
  ...

  chart_version = "3.7.1"
  
  additional_chart_value_files = [file("path/to/values/file.yaml")]

  chart_values_overrides = {
    "controller.name" = "custom-controller-name"
  }
}

Check the examples folder for more examples

Module Info

See the module info here here or view it on the Terraform Registry

Contributing

See contributing docs here