From 3516b2cb29ab6676590e24ba6f05359bdfd70f30 Mon Sep 17 00:00:00 2001 From: Khue Doan Date: Wed, 9 Jun 2021 01:03:40 +0700 Subject: [PATCH] Move ArgoCD back to infra bootstrap Avoid ArgoCD server issue when applying Argo apps to quickly --- README.md | 4 ++-- apps/kustomization.yaml | 3 --- apps/resources/namespace.yaml | 4 ---- infra/bootstrap.tf | 18 ++++++++++++++++++ infra/{main.tf => cluster.tf} | 4 ++++ infra/terraform.tf | 4 ---- 6 files changed, 24 insertions(+), 13 deletions(-) delete mode 100644 apps/resources/namespace.yaml create mode 100644 infra/bootstrap.tf rename infra/{main.tf => cluster.tf} (96%) diff --git a/README.md b/README.md index d6f4fcd8..7f307475 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ - DHCP server point it to the TFTP server to get boot files and boot config - The boot config contains parameter to get [automated OS installation config file](./metal/roles/pxe-boot/templates/http/kickstart/fedora.ks.j2) - The OS get installed and the machine reboots to the new operating system - - Terraform will create a Kubernetes [cluster](./infra/main.tf) + - Terraform will create a Kubernetes [cluster](./infra/cluster.tf) and some install some [Helm chart for bootstrap](./infra/bootstrap.tf) - ArgoCD will install the [applications](./apps/resources) ### Layers @@ -58,7 +58,7 @@ |-------|------------------------|---------------------------------------------------------|---------------------| | 0 | [metal](./metal) | Bare metal OS installation, Terraform state backend,... | Ansible, PXE server | | 1 | [infra](./infra) | Kubernetes clusters | Terraform, Helm | -| 2 | [apps](./apps) | Gitea, Vault and more in the future | Argo | +| 2 | [apps](./apps) | Gitea, Vault and more in the future | ArgoCD | ## Get Started diff --git a/apps/kustomization.yaml b/apps/kustomization.yaml index 1145c128..2b112fbe 100644 --- a/apps/kustomization.yaml +++ b/apps/kustomization.yaml @@ -2,9 +2,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -# Prerequisites -- resources/namespace.yaml -- github.com/argoproj/argo-cd//manifests/cluster-install?ref=v2.0.2 # System - resources/cert-manager.yaml - resources/longhorn.yaml diff --git a/apps/resources/namespace.yaml b/apps/resources/namespace.yaml deleted file mode 100644 index a040f2ba..00000000 --- a/apps/resources/namespace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: argocd diff --git a/infra/bootstrap.tf b/infra/bootstrap.tf new file mode 100644 index 00000000..c8225070 --- /dev/null +++ b/infra/bootstrap.tf @@ -0,0 +1,18 @@ +provider "helm" { + kubernetes { + host = rke_cluster.cluster.api_server_url + client_certificate = rke_cluster.cluster.client_cert + client_key = rke_cluster.cluster.client_key + cluster_ca_certificate = rke_cluster.cluster.ca_crt + } +} + +resource "helm_release" "argocd" { + name = "argocd" + repository = "https://argoproj.github.io/argo-helm" + chart = "argo-cd" + version = "3.1.2" + + namespace = "argocd" + create_namespace = true +} diff --git a/infra/main.tf b/infra/cluster.tf similarity index 96% rename from infra/main.tf rename to infra/cluster.tf index 17bc2cfa..303d86e1 100644 --- a/infra/main.tf +++ b/infra/cluster.tf @@ -1,3 +1,7 @@ +provider "rke" { + debug = true +} + locals { hosts = yamldecode(file("../metal/hosts.yml")) user = local.hosts.metal.vars.ansible_user diff --git a/infra/terraform.tf b/infra/terraform.tf index 84c69413..1450d75b 100644 --- a/infra/terraform.tf +++ b/infra/terraform.tf @@ -14,7 +14,3 @@ terraform { } } } - -provider "rke" { - debug = true -}