refactor(bootstrap)!: split argocd and root

This commit is contained in:
Khue Doan 2021-12-28 10:10:29 +07:00
parent c3eaf7ee06
commit f4b63c018f
10 changed files with 41 additions and 41 deletions

View File

@ -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

View File

@ -1,5 +1,5 @@
apiVersion: v2
name: bootstrap
name: argocd
version: 0.0.0
dependencies:
- name: argo-cd

11
bootstrap/argocd/apply.sh Executable file
View File

@ -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

View File

@ -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

View File

@ -0,0 +1,3 @@
apiVersion: v2
name: root
version: 0.0.0

View File

@ -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 }}

View File

@ -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

View File

@ -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