Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 115 additions & 32 deletions .github/workflows/bootstrap-argocd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ArgoCD
name: ArgoCD Bootstrap

on:
push:
Expand All @@ -10,31 +10,45 @@ on:
permissions:
id-token: write
contents: read
pull-requests: write
issues: read
security-events: write


jobs:
bootstrap:
name: Bootstrap ${{ matrix.environment }}
changes:
runs-on: ubuntu-latest

outputs:
dev: ${{ steps.filter.outputs.dev }}
staging: ${{ steps.filter.outputs.staging }}
prod: ${{ steps.filter.outputs.prod }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Detect changes
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
dev:
- 'argocd/dev/**'
staging:
- 'argocd/staging/**'
prod:
- 'argocd/prod/**'

bootstrap-dev:
name: Bootstrap dev
needs: changes
if: needs.changes.outputs.dev == 'true'
runs-on: ubuntu-latest
environment: ${{ matrix.environment }}

strategy:
matrix:
include:
- environment: dev
cluster: eks-dev-cluster
- environment: staging
cluster: eks-staging-cluster
- environment: prod
cluster: eks-prod-cluster
environment: dev

steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- uses: aws-actions/configure-aws-credentials@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1
Expand All @@ -48,24 +62,93 @@ jobs:
run: |
aws eks update-kubeconfig \
--region us-east-1 \
--name ${{ matrix.cluster }}
--name eks-dev-cluster

- name: Apply Root Application
- name: Apply Argo CD root application
run: |
kubectl apply -f argocd/${{ matrix.environment }}/root-app.yaml
kubectl apply \
--namespace argocd \
--filename argocd/dev/root-app.yaml

- name: Wait for Root Application
- name: Show Argo CD applications
run: |
kubectl wait \
--for=condition=Established \
crd/applications.argoproj.io \
--timeout=60s || true
kubectl get applications \
--namespace argocd

bootstrap-staging:
name: Bootstrap staging
needs: changes
if: needs.changes.outputs.staging == 'true'
runs-on: ubuntu-latest
environment: staging

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Show Applications
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1

- name: Install kubectl
uses: azure/setup-kubectl@v4
with:
version: latest

- name: Configure kubeconfig
run: |
kubectl get applications -n argocd || true
aws eks update-kubeconfig \
--region us-east-1 \
--name eks-staging-cluster

- name: Show ApplicationSets
- name: Apply Argo CD root application
run: |
kubectl get applicationsets -n argocd || true
kubectl apply \
--namespace argocd \
--filename argocd/staging/root-app.yaml

- name: Show Argo CD applications
run: |
kubectl get applications \
--namespace argocd

bootstrap-prod:
name: Bootstrap prod
needs: changes
if: needs.changes.outputs.prod == 'true'
runs-on: ubuntu-latest
environment: prod

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: us-east-1

- name: Install kubectl
uses: azure/setup-kubectl@v4
with:
version: latest

- name: Configure kubeconfig
run: |
aws eks update-kubeconfig \
--region us-east-1 \
--name eks-prod-cluster

- name: Apply Argo CD root application
run: |
kubectl apply \
--namespace argocd \
--filename argocd/prod/root-app.yaml

- name: Show Argo CD applications
run: |
kubectl get applications \
--namespace argocd
11 changes: 10 additions & 1 deletion argocd/dev/applicationset-apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,20 @@ spec:
server: https://kubernetes.default.svc
namespace: dev

revisionHistoryLimit: 5

syncPolicy:
automated:
prune: true
selfHeal: true

retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m

syncOptions:
- CreateNamespace=true

12 changes: 11 additions & 1 deletion argocd/dev/applicationset-infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@ spec:
server: https://kubernetes.default.svc
namespace: '{{namespace}}'

revisionHistoryLimit: 5

syncPolicy:
automated:
prune: true
selfHeal: true

retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m

syncOptions:
- CreateNamespace=true

16 changes: 14 additions & 2 deletions argocd/dev/applicationset-monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@ spec:
server: https://kubernetes.default.svc
namespace: "{{namespace}}"

revisionHistoryLimit: 5

syncPolicy:
automated:
prune: true
selfHeal: true

selfHeal: true

retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m

syncOptions:
- CreateNamespace=true

4 changes: 2 additions & 2 deletions argocd/dev/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ kind: Kustomization
resources:
- applicationset-apps.yaml
- applicationset-infra.yaml
- applicationset-monitoring.yaml
- applicationset-monitoring.yaml

4 changes: 2 additions & 2 deletions argocd/dev/root-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ spec:
syncPolicy:
automated:
prune: true
selfHeal: true

selfHeal: true
11 changes: 10 additions & 1 deletion argocd/prod/applicationset-apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,20 @@ spec:
server: https://kubernetes.default.svc
namespace: prod

revisionHistoryLimit: 5

syncPolicy:
automated:
prune: true
selfHeal: true

retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m

syncOptions:
- CreateNamespace=true
- CreateNamespace=true

55 changes: 32 additions & 23 deletions argocd/prod/applicationset-infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,35 @@ spec:
path: infrastructure/overlay/prod
namespace: prod

template:
metadata:
name: '{{name}}-prod'

spec:
project: default

source:
repoURL: https://github.com/Emmy-github-webdev/Kubernetes-argocd.git
targetRevision: main
path: '{{path}}'

destination:
server: https://kubernetes.default.svc
namespace: '{{namespace}}'

syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true

template:
metadata:
name: '{{name}}-prod'

spec:
project: default

source:
repoURL: https://github.com/Emmy-github-webdev/Kubernetes-argocd.git
targetRevision: main
path: apps/{{name}}/overlays/prod

destination:
server: https://kubernetes.default.svc
namespace: prod

revisionHistoryLimit: 5

syncPolicy:
automated:
prune: true
selfHeal: true

retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m

syncOptions:
- CreateNamespace=true
14 changes: 13 additions & 1 deletion argocd/prod/applicationset-monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@ spec:
server: https://kubernetes.default.svc
namespace: "{{namespace}}"

revisionHistoryLimit: 5

syncPolicy:
automated:
prune: true
selfHeal: true
selfHeal: true

retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m

syncOptions:
- CreateNamespace=true

11 changes: 10 additions & 1 deletion argocd/staging/applicationset-apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,19 @@ spec:
server: https://kubernetes.default.svc
namespace: staging

revisionHistoryLimit: 5

syncPolicy:
automated:
prune: true
selfHeal: true

retry:
limit: 5
backoff:
duration: 5s
factor: 2
maxDuration: 3m

syncOptions:
- CreateNamespace=true
- CreateNamespace=true
Loading
Loading