From f4b63c018ff14694118a7e7d38428582b889affc Mon Sep 17 00:00:00 2001 From: Khue Doan Date: Tue, 28 Dec 2021 10:10:29 +0700 Subject: [PATCH] refactor(bootstrap)!: split argocd and root --- bootstrap/Makefile | 20 ++++++++++++++------ bootstrap/{ => argocd}/Chart.yaml | 2 +- bootstrap/argocd/apply.sh | 11 +++++++++++ bootstrap/{ => argocd}/values.yaml | 8 -------- bootstrap/root/Chart.yaml | 3 +++ bootstrap/{ => root}/apply.sh | 0 bootstrap/{ => root}/templates/stack.yaml | 6 +++--- bootstrap/{ => root}/values-seed.yaml | 0 bootstrap/root/values.yaml | 9 +++++++++ bootstrap/templates/argocd.yaml | 23 ----------------------- 10 files changed, 41 insertions(+), 41 deletions(-) rename bootstrap/{ => argocd}/Chart.yaml (93%) create mode 100755 bootstrap/argocd/apply.sh rename bootstrap/{ => argocd}/values.yaml (94%) create mode 100644 bootstrap/root/Chart.yaml rename bootstrap/{ => root}/apply.sh (100%) rename bootstrap/{ => root}/templates/stack.yaml (85%) rename bootstrap/{ => root}/values-seed.yaml (100%) create mode 100644 bootstrap/root/values.yaml delete mode 100644 bootstrap/templates/argocd.yaml diff --git a/bootstrap/Makefile b/bootstrap/Makefile index b46540d0..6d2d49e3 100644 --- a/bootstrap/Makefile +++ b/bootstrap/Makefile @@ -1,16 +1,24 @@ .POSIX: .EXPORT_ALL_VARIABLES: -KUBECONFIG = ../metal/kubeconfig.yaml +KUBECONFIG = $(shell pwd)/../metal/kubeconfig.yaml -default: namespace apply +default: namespace argocd root -charts: Chart.yaml - helm dependency update +argocd/charts: argocd/Chart.yaml + cd argocd \ + && helm dependency update namespace: kubectl create namespace argocd --dry-run=client --output=yaml \ | kubectl apply -f - -apply: charts - ./apply.sh +.PHONY: argocd +argocd: argocd/charts + cd argocd && \ + ./apply.sh + +.PHONY: root +root: + cd root && \ + ./apply.sh diff --git a/bootstrap/Chart.yaml b/bootstrap/argocd/Chart.yaml similarity index 93% rename from bootstrap/Chart.yaml rename to bootstrap/argocd/Chart.yaml index 5cf24349..d4f1879e 100644 --- a/bootstrap/Chart.yaml +++ b/bootstrap/argocd/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 -name: bootstrap +name: argocd version: 0.0.0 dependencies: - name: argo-cd diff --git a/bootstrap/argocd/apply.sh b/bootstrap/argocd/apply.sh new file mode 100755 index 00000000..a3d6ef2c --- /dev/null +++ b/bootstrap/argocd/apply.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +helm template \ + --include-crds \ + --namespace argocd \ + argocd . \ + | kubectl apply -n argocd -f - + +kubectl -n argocd wait --timeout=60s --for condition=Established \ + crd/applications.argoproj.io \ + crd/applicationsets.argoproj.io diff --git a/bootstrap/values.yaml b/bootstrap/argocd/values.yaml similarity index 94% rename from bootstrap/values.yaml rename to bootstrap/argocd/values.yaml index cabf8c80..657c0e5d 100644 --- a/bootstrap/values.yaml +++ b/bootstrap/argocd/values.yaml @@ -54,11 +54,3 @@ argo-cd: - secretName: argocd-tls-certificate hosts: - *host - -gitops: - repo: https://git.khuedoan.com/ops/homelab - revision: master -stacks: - - system - - platform - - apps diff --git a/bootstrap/root/Chart.yaml b/bootstrap/root/Chart.yaml new file mode 100644 index 00000000..563e5408 --- /dev/null +++ b/bootstrap/root/Chart.yaml @@ -0,0 +1,3 @@ +apiVersion: v2 +name: root +version: 0.0.0 diff --git a/bootstrap/apply.sh b/bootstrap/root/apply.sh similarity index 100% rename from bootstrap/apply.sh rename to bootstrap/root/apply.sh diff --git a/bootstrap/templates/stack.yaml b/bootstrap/root/templates/stack.yaml similarity index 85% rename from bootstrap/templates/stack.yaml rename to bootstrap/root/templates/stack.yaml index d410c387..c8206e62 100644 --- a/bootstrap/templates/stack.yaml +++ b/bootstrap/root/templates/stack.yaml @@ -3,7 +3,7 @@ apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: - name: {{ $stack }} + name: {{ $stack.name }} namespace: {{ $.Release.Namespace }} spec: generators: @@ -11,14 +11,14 @@ spec: repoURL: {{ $.Values.gitops.repo }} revision: {{ $.Values.gitops.revision }} directories: - - path: {{ $stack }}/* + - path: {{ $stack.name }}/* template: metadata: name: '{{ `{{path.basename}}` }}' spec: destination: name: in-cluster - namespace: '{{ `{{path.basename}}` }}' + namespace: '{{ default `{{path.basename}}` $stack.namespace }}' project: default # TODO source: repoURL: {{ $.Values.gitops.repo }} diff --git a/bootstrap/values-seed.yaml b/bootstrap/root/values-seed.yaml similarity index 100% rename from bootstrap/values-seed.yaml rename to bootstrap/root/values-seed.yaml diff --git a/bootstrap/root/values.yaml b/bootstrap/root/values.yaml new file mode 100644 index 00000000..359232e0 --- /dev/null +++ b/bootstrap/root/values.yaml @@ -0,0 +1,9 @@ +gitops: + repo: https://git.khuedoan.com/ops/homelab + revision: master +stacks: + - name: bootstrap + namespace: argocd # Override default value + - name: system + - name: platform + - name: apps diff --git a/bootstrap/templates/argocd.yaml b/bootstrap/templates/argocd.yaml deleted file mode 100644 index 29847646..00000000 --- a/bootstrap/templates/argocd.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: argoproj.io/v1alpha1 -kind: Application -metadata: - name: argocd - namespace: {{ .Release.Namespace }} -spec: - destination: - name: in-cluster - namespace: {{ .Release.Namespace }} - project: default - source: - repoURL: {{ .Values.gitops.repo }} - targetRevision: {{ $.Values.gitops.revision }} - path: bootstrap - syncPolicy: - automated: - selfHeal: true - retry: - backoff: - duration: 1m - factor: 2 - maxDuration: 16m - limit: 10