├── .gitignore ├── Makefile ├── README.md ├── apps ├── demo1 │ ├── chart │ │ ├── .helmignore │ │ ├── Chart.lock │ │ ├── Chart.yaml │ │ └── values.yaml │ └── envs │ │ ├── values-dev.yaml │ │ ├── values-prod.yaml │ │ └── values-test.yaml └── demo2 │ ├── chart │ ├── .helmignore │ ├── Chart.lock │ ├── Chart.yaml │ └── values.yaml │ └── envs │ ├── values-dev.yaml │ ├── values-prod.yaml │ └── values-test.yaml ├── bin ├── promote ├── promote-image └── update-image-spec └── projects ├── dev.yaml ├── prod.yaml └── test.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | charts/ 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | SEQ=1 3 | NAME=scoil 4 | SUBSCRIPTION=XXXXXXXXXXXX 5 | REGION=eastus 6 | NODES=2 7 | 8 | RESOURCE_GROUP=$(NAME)-${LOGNAME}-$(SEQ) 9 | REGISTRY_NAME=$(NAME)${LOGNAME}$(SEQ) 10 | REGISTRY=$(REGISTRY_NAME).azurecr.io 11 | CLUSTER=$(NAME)-$(SEQ) 12 | 13 | # 14 | # Targets 15 | # 16 | default: creds 17 | 18 | # 19 | # Auth 20 | # 21 | creds: creds-cluster creds-registry 22 | 23 | creds-cluster: 24 | az aks get-credentials --resource-group $(RESOURCE_GROUP) --name $(CLUSTER) --overwrite-existing 25 | 26 | creds-registry: 27 | az acr login --name $(REGISTRY) 28 | 29 | # 30 | # Cluster provisioning targets 31 | # 32 | provision: provision-aks-cluster 33 | 34 | provision-setup: 35 | az account set --subscription $(SUBSCRIPTION) 36 | az group create --name $(RESOURCE_GROUP) --location $(REGION) 37 | 38 | provision-registry: provision-setup 39 | az acr create --resource-group $(RESOURCE_GROUP) --name $(REGISTRY_NAME) --sku Basic 40 | 41 | provision-aks-cluster: provision-registry 42 | az aks create --resource-group $(RESOURCE_GROUP) --name $(CLUSTER) --node-count $(NODES) --attach-acr $(REGISTRY_NAME) 43 | 44 | # 45 | # Purge infrastructure 46 | # 47 | purge: 48 | az group delete --name $(RESOURCE_GROUP) --no-wait --subscription $(SUBSCRIPTION) 49 | 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gitops-workloads-demo 2 | 3 | This repository demonstrates how Helm based work loads can be managed by ArgoCD. 4 | 5 | ## Application setup 6 | 7 | The configuration for each application is stored under the [apps](apps) directory. There is a [chart](apps/demo1/chart) directory to store the helm chart of the application and an [envs](apps/demo1/envs) directory to record the helm values file to be used when deploying to the "dev", "test" or "prod" environments. 8 | 9 | apps 10 | ├── demo1 11 |    ├── chart 12 |    │   ├── Chart.yaml 13 |    │   └── .. 14 |    └── envs 15 |    ├── values-dev.yaml 16 |    ├── values-prod.yaml 17 |    └── values-test.yaml 18 | 19 | ## Testing the helm chart 20 | 21 | You can test the helm chart generation as follows. 22 | 23 | helm dependency build apps/demo1/chart 24 | helm template apps/demo1/chart -f apps/demo1/envs/values-dev.yaml 25 | 26 | ## ArgoCD configuration 27 | 28 | The ArgoCD configuration for each environment is recorded in the following files. 29 | 30 | * [projects/dev.yaml](projects/dev.yaml) 31 | * [projects/test.yaml](projects/test.yaml) 32 | * [projects/prod.yaml](projects/prod.yaml) 33 | 34 | If you investigate you'll discover each file configures two things, an [ArgoCD project](https://argo-cd.readthedocs.io/en/stable/user-guide/projects/) 35 | and an [ApplicationSet](https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/) to deploy the helm charts. 36 | Assuming each cluster is running ArgoCD, you can bootstrap any of the workloads as follows: 37 | 38 | kubectl -n argocd apply -f projects/dev.yaml # Run this against the "Dev" cluster 39 | 40 | # Software 41 | 42 | The following tool dependencies 43 | 44 | * Azure CLI 45 | * kubectl 46 | * argocd cli 47 | 48 | # DEMO 49 | 50 | ## Setup 51 | 52 | Provision three kubernetes clusters. The Makefile has logic to create AKS clusters on Azure. Possible to use other mechanisms (AWS EKS, minikube, kind) 53 | 54 | make provision creds-cluster SUBSCRIPTION=$SUB SEQ=dev 55 | make provision creds-cluster SUBSCRIPTION=$SUB SEQ=test 56 | make provision creds-cluster SUBSCRIPTION=$SUB SEQ=prod 57 | 58 | Perform a "core" install of ArgoCD on the k8s clusters 59 | 60 | kubectl --context scoil-dev create namespace argocd 61 | kubectl --context scoil-dev apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/core-install.yaml 62 | 63 | kubectl --context scoil-test create namespace argocd 64 | kubectl --context scoil-test apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/core-install.yaml 65 | 66 | kubectl --context scoil-prod create namespace argocd 67 | kubectl --context scoil-prod apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/core-install.yaml 68 | 69 | Bootstrap workloads onto the clusters 70 | 71 | kubectl --context scoil-dev -n argocd apply -f projects/dev.yaml 72 | kubectl --context scoil-test -n argocd apply -f projects/test.yaml 73 | kubectl --context scoil-prod -n argocd apply -f projects/prod.yaml 74 | 75 | ## ArgoCD UIs 76 | 77 | To launch UI requires running one of the following proxy sessions 78 | 79 | Dev cluster 80 | 81 | kubectl config set-context scoil-dev --namespace argocd 82 | kubectl config use-context scoil-dev 83 | argocd admin dashboard --port 8081 84 | 85 | Test Cluster 86 | 87 | kubectl config set-context scoil-test --namespace argocd 88 | kubectl config use-context scoil-test 89 | argocd admin dashboard --port 8082 90 | 91 | Prod cluster 92 | 93 | kubectl config set-context scoil-prod --namespace argocd 94 | kubectl config use-context scoil-prod 95 | argocd admin dashboard --port 8083 96 | 97 | The Argo CD UIs are available at following URLs: 98 | 99 | * http://localhost:8081 100 | * http://localhost:8082 101 | * http://localhost:8083 102 | 103 | ## Promoting releases 104 | 105 | This example illustrates a promotion process where docker images are promoted by being pushed into different docker registries 106 | 107 | ```mermaid 108 | flowchart LR 109 | id1[(Development)] -- promote --> id2[(Test)] -- promote --> id3[(Production)] 110 | ``` 111 | 112 | 113 | ### Push a release candidate to Dev 114 | 115 | **Step 1** 116 | 117 | Login to the Dev registry 118 | 119 | az acr login --name scoilmarkdev.azurecr.io 120 | 121 | Push a pre-built image to the the Dev registry 122 | 123 | docker pull nginx:1.22.0 124 | docker tag nginx:1.22.0 scoilmarkdev.azurecr.io/nginx:1.22.0 125 | docker push scoilmarkdev.azurecr.io/nginx:1.22.0 126 | 127 | **Step 2** 128 | 129 | Tell ArgoCD to deploy the image 130 | 131 | # 132 | # Update the image spec 133 | # 134 | export IMAGE=scoilmarkdev.azurecr.io/nginx:1.22.0 135 | yq e -i '.app.containers[0].image=strenv(IMAGE)' apps/demo1/envs/values-dev.yaml 136 | 137 | # 138 | # Commit and push change 139 | # 140 | git add apps/demo1/envs/values-dev.yaml 141 | git commit -am "Update image to $IMAGE" 142 | git push 143 | 144 | ### Promote release candidate to Test 145 | 146 | **Step 1** 147 | 148 | Push the image into the Test docker registry 149 | 150 | az acr import --name scoilmarktest --source scoilmarkdev.azurecr.io/nginx:1.22.0 151 | 152 | **Step 2** 153 | 154 | Tell ArgoCD to deploy the image 155 | 156 | # 157 | # Update the image spec 158 | # 159 | export IMAGE=scoilmarktest.azurecr.io/nginx:1.22.0 160 | yq e -i '.app.containers[0].image=strenv(IMAGE)' apps/demo1/envs/values-test.yaml 161 | 162 | # 163 | # Commit and push change 164 | # 165 | git add apps/demo1/envs/values-test.yaml 166 | git commit -am "Update image to $IMAGE" 167 | git push 168 | 169 | ### Promote release candidate to Prod 170 | 171 | **Step 1** 172 | 173 | Push the image into the Prod docker registry 174 | 175 | az acr import --name scoilmarkprod --source scoilmarktest.azurecr.io/nginx:1.22.0 176 | 177 | **Step 2** 178 | 179 | Tell ArgoCD to deploy the image 180 | 181 | # 182 | # Update the image spec 183 | # 184 | export IMAGE=scoilmarkprod.azurecr.io/nginx:1.22.0 185 | yq e -i '.app.containers[0].image=strenv(IMAGE)' apps/demo1/envs/values-prod.yaml 186 | 187 | # 188 | # Commit and push change 189 | # 190 | git add apps/demo1/envs/values-prod.yaml 191 | git commit -am "Update image to $IMAGE" 192 | git push 193 | 194 | 195 | # Cleanup 196 | 197 | The following command will delete the Azure resource group created by this tutorial 198 | 199 | make purge SUBSCRIPTION=$SUB SEQ=dev 200 | make purge SUBSCRIPTION=$SUB SEQ=test 201 | make purge SUBSCRIPTION=$SUB SEQ=prod 202 | 203 | -------------------------------------------------------------------------------- /apps/demo1/chart/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /apps/demo1/chart/Chart.lock: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - name: component-chart 3 | repository: https://charts.devspace.sh 4 | version: 0.8.4 5 | digest: sha256:747e95716c7fd47603e6f2caebf1830fe80ae720e1d1916b81c6cf8e4fe5c6c0 6 | generated: "2022-07-07T15:56:57.1983686+01:00" 7 | -------------------------------------------------------------------------------- /apps/demo1/chart/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: demo1 3 | description: A Helm chart for Kubernetes 4 | type: application 5 | version: 0.1.0 6 | appVersion: "1.16.0" 7 | 8 | dependencies: 9 | # 10 | # https://devspace.sh/component-chart/docs/introduction 11 | # 12 | - name: component-chart 13 | repository: https://charts.devspace.sh 14 | version: 0.8.4 15 | alias: app 16 | -------------------------------------------------------------------------------- /apps/demo1/chart/values.yaml: -------------------------------------------------------------------------------- 1 | app: 2 | containers: 3 | - name: nginx 4 | image: nginx:latest 5 | resources: 6 | requests: 7 | memory: "64Mi" 8 | cpu: "250m" 9 | limits: 10 | memory: "128Mi" 11 | cpu: "500m" 12 | livenessProbe: 13 | httpGet: 14 | path: / 15 | port: 80 16 | initialDelaySeconds: 45 17 | readinessProbe: 18 | httpGet: 19 | path: / 20 | port: 80 21 | service: 22 | ports: 23 | - port: 80 24 | type: ClusterIP 25 | -------------------------------------------------------------------------------- /apps/demo1/envs/values-dev.yaml: -------------------------------------------------------------------------------- 1 | app: 2 | containers: 3 | - name: nginx 4 | image: scoilmarkdev.azurecr.io/nginx:1.22.0 5 | resources: 6 | requests: 7 | memory: "64Mi" 8 | cpu: "250m" 9 | limits: 10 | memory: "128Mi" 11 | cpu: "500m" 12 | livenessProbe: 13 | httpGet: 14 | path: / 15 | port: 80 16 | initialDelaySeconds: 45 17 | readinessProbe: 18 | httpGet: 19 | path: / 20 | port: 80 21 | service: 22 | ports: 23 | - port: 80 24 | type: ClusterIP 25 | -------------------------------------------------------------------------------- /apps/demo1/envs/values-prod.yaml: -------------------------------------------------------------------------------- 1 | app: 2 | containers: 3 | - name: nginx 4 | image: scoilmarkprod.azurecr.io/nginx:1.22.0 5 | resources: 6 | requests: 7 | memory: "64Mi" 8 | cpu: "250m" 9 | limits: 10 | memory: "128Mi" 11 | cpu: "500m" 12 | livenessProbe: 13 | httpGet: 14 | path: / 15 | port: 80 16 | initialDelaySeconds: 45 17 | readinessProbe: 18 | httpGet: 19 | path: / 20 | port: 80 21 | service: 22 | ports: 23 | - port: 80 24 | type: ClusterIP 25 | -------------------------------------------------------------------------------- /apps/demo1/envs/values-test.yaml: -------------------------------------------------------------------------------- 1 | app: 2 | containers: 3 | - name: nginx 4 | image: scoilmarktest.azurecr.io/nginx:1.22.0 5 | resources: 6 | requests: 7 | memory: "64Mi" 8 | cpu: "250m" 9 | limits: 10 | memory: "128Mi" 11 | cpu: "500m" 12 | livenessProbe: 13 | httpGet: 14 | path: / 15 | port: 80 16 | initialDelaySeconds: 45 17 | readinessProbe: 18 | httpGet: 19 | path: / 20 | port: 80 21 | service: 22 | ports: 23 | - port: 80 24 | type: ClusterIP 25 | -------------------------------------------------------------------------------- /apps/demo2/chart/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /apps/demo2/chart/Chart.lock: -------------------------------------------------------------------------------- 1 | dependencies: 2 | - name: component-chart 3 | repository: https://charts.devspace.sh 4 | version: 0.8.4 5 | digest: sha256:747e95716c7fd47603e6f2caebf1830fe80ae720e1d1916b81c6cf8e4fe5c6c0 6 | generated: "2022-07-07T15:56:57.1983686+01:00" 7 | -------------------------------------------------------------------------------- /apps/demo2/chart/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: demo2 3 | description: A Helm chart for Kubernetes 4 | type: application 5 | version: 0.1.0 6 | appVersion: "1.16.0" 7 | 8 | dependencies: 9 | # 10 | # https://devspace.sh/component-chart/docs/introduction 11 | # 12 | - name: component-chart 13 | repository: https://charts.devspace.sh 14 | version: 0.8.4 15 | alias: app 16 | -------------------------------------------------------------------------------- /apps/demo2/chart/values.yaml: -------------------------------------------------------------------------------- 1 | app: 2 | containers: 3 | - name: nginx 4 | image: nginx:latest 5 | resources: 6 | requests: 7 | memory: "64Mi" 8 | cpu: "250m" 9 | limits: 10 | memory: "128Mi" 11 | cpu: "500m" 12 | livenessProbe: 13 | httpGet: 14 | path: / 15 | port: 80 16 | initialDelaySeconds: 45 17 | readinessProbe: 18 | httpGet: 19 | path: / 20 | port: 80 21 | service: 22 | ports: 23 | - port: 80 24 | type: ClusterIP 25 | -------------------------------------------------------------------------------- /apps/demo2/envs/values-dev.yaml: -------------------------------------------------------------------------------- 1 | app: 2 | containers: 3 | - name: nginx 4 | image: nginx:1.22.0 5 | resources: 6 | requests: 7 | memory: "64Mi" 8 | cpu: "250m" 9 | limits: 10 | memory: "128Mi" 11 | cpu: "500m" 12 | livenessProbe: 13 | httpGet: 14 | path: / 15 | port: 80 16 | initialDelaySeconds: 45 17 | readinessProbe: 18 | httpGet: 19 | path: / 20 | port: 80 21 | service: 22 | ports: 23 | - port: 80 24 | type: ClusterIP 25 | -------------------------------------------------------------------------------- /apps/demo2/envs/values-prod.yaml: -------------------------------------------------------------------------------- 1 | app: 2 | containers: 3 | - name: nginx 4 | image: nginx:1.22.0 5 | resources: 6 | requests: 7 | memory: "64Mi" 8 | cpu: "250m" 9 | limits: 10 | memory: "128Mi" 11 | cpu: "500m" 12 | livenessProbe: 13 | httpGet: 14 | path: / 15 | port: 80 16 | initialDelaySeconds: 45 17 | readinessProbe: 18 | httpGet: 19 | path: / 20 | port: 80 21 | service: 22 | ports: 23 | - port: 80 24 | type: ClusterIP 25 | -------------------------------------------------------------------------------- /apps/demo2/envs/values-test.yaml: -------------------------------------------------------------------------------- 1 | app: 2 | containers: 3 | - name: nginx 4 | image: nginx:1.22.0 5 | resources: 6 | requests: 7 | memory: "64Mi" 8 | cpu: "250m" 9 | limits: 10 | memory: "128Mi" 11 | cpu: "500m" 12 | livenessProbe: 13 | httpGet: 14 | path: / 15 | port: 80 16 | initialDelaySeconds: 45 17 | readinessProbe: 18 | httpGet: 19 | path: / 20 | port: 80 21 | service: 22 | ports: 23 | - port: 80 24 | type: ClusterIP 25 | -------------------------------------------------------------------------------- /bin/promote: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PROMOTE_FROM=${1:-dev} 4 | PROMOTE_TO=${2:-test} 5 | REGISTRY_NAME=$3 6 | 7 | echo "Promoting from '$PROMOTE_FROM' to '$PROMOTE_TO' ..." 8 | 9 | set -e 10 | 11 | for FILE in $(find apps/*/envs -name values-$PROMOTE_FROM.yaml -type f ) 12 | do 13 | bin/promote-image $FILE $REGISTRY_NAME 14 | bin/update-image-spec $FILE $(dirname $FILE)/values-$PROMOTE_TO.yaml $REGISTRY_NAME 15 | done 16 | -------------------------------------------------------------------------------- /bin/promote-image: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$#" -eq 2 ]; then 4 | 5 | SRC_FILE=$1 6 | REGISTRY_NAME=$2 7 | 8 | set -x 9 | az acr import --name $REGISTRY_NAME --source $(yq e '.app.containers[0].image' $SRC_FILE) 10 | 11 | else 12 | echo "$0 " 13 | fi 14 | 15 | -------------------------------------------------------------------------------- /bin/update-image-spec: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$#" -eq 3 ]; then 4 | 5 | SRC_FILE=$1 6 | TRG_FILE=$2 7 | REGISTRY_NAME=$3 8 | 9 | OLD_IMAGE=$(yq e '.app.containers[0].image' $SRC_FILE) 10 | export NEW_IMAGE=$REGISTRY_NAME.azurecr.io/${OLD_IMAGE#*/} 11 | 12 | set -x 13 | yq e -i '.app.containers[0].image=strenv(NEW_IMAGE)' $TRG_FILE 14 | 15 | else 16 | echo "$0 " 17 | fi 18 | 19 | -------------------------------------------------------------------------------- /projects/dev.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: AppProject 3 | metadata: 4 | name: dev 5 | namespace: argocd 6 | # Finalizer that ensures that project is not deleted until it is not referenced by any application 7 | finalizers: 8 | - resources-finalizer.argocd.argoproj.io 9 | spec: 10 | clusterResourceWhitelist: 11 | - group: '*' 12 | kind: '*' 13 | description: dev project 14 | destinations: 15 | - namespace: '*' 16 | server: '*' 17 | namespaceResourceWhitelist: 18 | - group: '*' 19 | kind: '*' 20 | sourceRepos: 21 | - '*' 22 | --- 23 | apiVersion: argoproj.io/v1alpha1 24 | kind: ApplicationSet 25 | metadata: 26 | creationTimestamp: null 27 | name: dev 28 | namespace: argocd 29 | spec: 30 | generators: 31 | - git: 32 | files: 33 | - path: apps/**/envs/values-dev.yaml 34 | repoURL: https://github.com/myspotontheweb/gitops-workloads-demo.git 35 | requeueAfterSeconds: 20 36 | revision: "" 37 | template: 38 | metadata: {} 39 | spec: 40 | destination: {} 41 | project: "" 42 | source: 43 | repoURL: "" 44 | template: 45 | metadata: 46 | labels: 47 | app.kubernetes.io/name: '{{ path[1] }}' 48 | name: dev-{{ path[1] }} 49 | namespace: argocd 50 | spec: 51 | project: dev 52 | destination: 53 | namespace: 'dev' 54 | server: 'https://kubernetes.default.svc' 55 | source: 56 | repoURL: https://github.com/myspotontheweb/gitops-workloads-demo.git 57 | path: '{{ path }}/../chart' 58 | targetRevision: 'main' 59 | helm: 60 | valueFiles: 61 | - '../envs/values-dev.yaml' 62 | syncPolicy: 63 | automated: 64 | prune: true 65 | selfHeal: true 66 | syncOptions: 67 | - CreateNamespace=true -------------------------------------------------------------------------------- /projects/prod.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: AppProject 3 | metadata: 4 | name: prod 5 | namespace: argocd 6 | # Finalizer that ensures that project is not deleted until it is not referenced by any application 7 | finalizers: 8 | - resources-finalizer.argocd.argoproj.io 9 | spec: 10 | clusterResourceWhitelist: 11 | - group: '*' 12 | kind: '*' 13 | description: prod project 14 | destinations: 15 | - namespace: '*' 16 | server: '*' 17 | namespaceResourceWhitelist: 18 | - group: '*' 19 | kind: '*' 20 | sourceRepos: 21 | - '*' 22 | --- 23 | apiVersion: argoproj.io/v1alpha1 24 | kind: ApplicationSet 25 | metadata: 26 | creationTimestamp: null 27 | name: prod 28 | namespace: argocd 29 | spec: 30 | generators: 31 | - git: 32 | files: 33 | - path: apps/**/envs/values-prod.yaml 34 | repoURL: https://github.com/myspotontheweb/gitops-workloads-demo.git 35 | requeueAfterSeconds: 20 36 | revision: "" 37 | template: 38 | metadata: {} 39 | spec: 40 | destination: {} 41 | project: "" 42 | source: 43 | repoURL: "" 44 | template: 45 | metadata: 46 | labels: 47 | app.kubernetes.io/name: '{{ path[1] }}' 48 | name: prod-{{ path[1] }} 49 | namespace: argocd 50 | spec: 51 | project: prod 52 | destination: 53 | namespace: 'prod' 54 | server: 'https://kubernetes.default.svc' 55 | source: 56 | repoURL: https://github.com/myspotontheweb/gitops-workloads-demo.git 57 | path: '{{ path }}/../chart' 58 | targetRevision: 'main' 59 | helm: 60 | valueFiles: 61 | - '../envs/values-prod.yaml' 62 | syncPolicy: 63 | automated: 64 | prune: true 65 | selfHeal: true 66 | syncOptions: 67 | - CreateNamespace=true 68 | -------------------------------------------------------------------------------- /projects/test.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: AppProject 3 | metadata: 4 | name: test 5 | namespace: argocd 6 | # Finalizer that ensures that project is not deleted until it is not referenced by any application 7 | finalizers: 8 | - resources-finalizer.argocd.argoproj.io 9 | spec: 10 | clusterResourceWhitelist: 11 | - group: '*' 12 | kind: '*' 13 | description: test project 14 | destinations: 15 | - namespace: '*' 16 | server: '*' 17 | namespaceResourceWhitelist: 18 | - group: '*' 19 | kind: '*' 20 | sourceRepos: 21 | - '*' 22 | --- 23 | apiVersion: argoproj.io/v1alpha1 24 | kind: ApplicationSet 25 | metadata: 26 | creationTimestamp: null 27 | name: test 28 | namespace: argocd 29 | spec: 30 | generators: 31 | - git: 32 | files: 33 | - path: apps/**/envs/values-test.yaml 34 | repoURL: https://github.com/myspotontheweb/gitops-workloads-demo.git 35 | requeueAfterSeconds: 20 36 | revision: "" 37 | template: 38 | metadata: {} 39 | spec: 40 | destination: {} 41 | project: "" 42 | source: 43 | repoURL: "" 44 | template: 45 | metadata: 46 | labels: 47 | app.kubernetes.io/name: '{{ path[1] }}' 48 | name: test-{{ path[1] }} 49 | namespace: argocd 50 | spec: 51 | project: test 52 | destination: 53 | namespace: 'test' 54 | server: 'https://kubernetes.default.svc' 55 | source: 56 | repoURL: https://github.com/myspotontheweb/gitops-workloads-demo.git 57 | path: '{{ path }}/../chart' 58 | targetRevision: 'main' 59 | helm: 60 | valueFiles: 61 | - '../envs/values-test.yaml' 62 | syncPolicy: 63 | automated: 64 | prune: true 65 | selfHeal: true 66 | syncOptions: 67 | - CreateNamespace=true 68 | --------------------------------------------------------------------------------