├── README.md ├── apps ├── billing │ ├── base │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ └── service.yml │ └── envs │ │ ├── prod-eu │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ ├── replicas.yml │ │ ├── settings.yml │ │ └── version.yml │ │ └── prod-us │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ ├── replicas.yml │ │ ├── settings.yml │ │ └── version.yml ├── fake-invoices │ ├── base │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ └── service.yml │ └── envs │ │ └── qa │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ ├── settings.yml │ │ └── version.yml ├── invoices │ ├── base │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ └── service.yml │ └── envs │ │ ├── prod-eu │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ ├── replicas.yml │ │ ├── settings.yml │ │ └── version.yml │ │ ├── prod-us │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ ├── replicas.yml │ │ ├── settings.yml │ │ └── version.yml │ │ ├── qa │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ ├── settings.yml │ │ └── version.yml │ │ └── staging │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ ├── replicas.yml │ │ ├── settings.yml │ │ └── version.yml ├── orders │ ├── base │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ └── service.yml │ └── envs │ │ ├── prod-us │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ ├── replicas.yml │ │ ├── settings.yml │ │ └── version.yml │ │ ├── qa │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ ├── settings.yml │ │ └── version.yml │ │ └── staging │ │ ├── deployment.yml │ │ ├── kustomization.yml │ │ ├── replicas.yml │ │ ├── settings.yml │ │ └── version.yml └── payments │ ├── base │ ├── deployment.yml │ ├── kustomization.yml │ └── service.yml │ └── envs │ ├── prod-eu │ ├── deployment.yml │ ├── kustomization.yml │ ├── replicas.yml │ ├── settings.yml │ └── version.yml │ └── prod-us │ ├── deployment.yml │ ├── kustomization.yml │ ├── replicas.yml │ ├── settings.yml │ └── version.yml ├── appsets ├── my-prod-appset.yml ├── my-qa-appset.yml └── my-staging-appset.yml ├── docs ├── hierarchy-of-manifests.png └── levels.png └── root-argocd-app.yml /README.md: -------------------------------------------------------------------------------- 1 | # How to structure your Argo CD repositories using Application Sets 2 | 3 | This is an exaple repository for Organizing your applications with Argo CD. 4 | 5 | ## Best practice - Use the three level structure 6 | 7 | The starting point should be a 3 level structure as shown in the image below 8 | 9 | ![structure](docs/hierarchy-of-manifests.png) 10 | 11 | At the lowest level we have the Kubernetes manifests that define how the application runs (category 1 of manifests). These are your Kustomize or Helm templates and they are completely self-contained, meaning that they can be deployed on their own on any cluster even without Argo CD. We have covered in detail the structure of these files in the promotion blog post. 12 | 13 | One level above, we have the Application Set as explained in the previous section. These wrap the main Kubernetes manifests into Argo CD applications (category 2 of manifests). Notice that in most cases you only need ApplicationSets and not individual Application CRDs. 14 | 15 | Last, as an optional component you can group all your application sets in an App-of-App that will help you bootstrap a completely empty cluster with all apps. This level might not be needed if you have a different way of creating clusters (i.e. with terraform/pulumi/crossplane) and this is why it is not really essential. 16 | 17 | And that’s it! 18 | 19 | Notice how simple this pattern is: 20 | 21 | There are only 3 levels of abstraction. We have seen companies that have 4 or 5 making the mental model much more complex 22 | Each level is completely independent of everything else. You can install the Kubernetes manifests on their own, or you can pick a specific application set or you can pick everything at the root. But it is your choice. 23 | Helm and Kustomize are only used once at the Kubernetes manifests and nowhere else. This makes the templating system super easy to understand 24 | 25 | ![folders](docs/levels.png) 26 | 27 | Read the full blog post at https://codefresh.io/blog/how-to-structure-your-argo-cd-repositories-using-application-sets/ 28 | 29 | 30 | -------------------------------------------------------------------------------- /apps/billing/base/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | annotations: 7 | codefresh.io/app: simple-go-app 8 | spec: 9 | replicas: 2 10 | selector: 11 | matchLabels: 12 | app: trivial-go-web-app 13 | template: 14 | metadata: 15 | labels: 16 | app: trivial-go-web-app 17 | spec: 18 | containers: 19 | - name: webserver-simple 20 | imagePullPolicy: Always 21 | image: docker.io/kostiscodefresh/simple-env-app:1.0 22 | ports: 23 | - containerPort: 8080 24 | -------------------------------------------------------------------------------- /apps/billing/base/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - deployment.yml 6 | - service.yml -------------------------------------------------------------------------------- /apps/billing/base/service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: simple-service 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: trivial-go-web-app 9 | ports: 10 | - protocol: TCP 11 | port: 80 12 | targetPort: 8080 -------------------------------------------------------------------------------- /apps/billing/envs/prod-eu/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: ENV 13 | value: "prod-eu" 14 | - name: GPU_ENABLED 15 | value: "1" 16 | -------------------------------------------------------------------------------- /apps/billing/envs/prod-eu/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../base 6 | 7 | patchesStrategicMerge: 8 | - deployment.yml 9 | - version.yml 10 | - replicas.yml 11 | - settings.yml 12 | 13 | -------------------------------------------------------------------------------- /apps/billing/envs/prod-eu/replicas.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | replicas: 8 -------------------------------------------------------------------------------- /apps/billing/envs/prod-eu/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: UI_THEME 13 | value: "dark" 14 | - name: CACHE_SIZE 15 | value: "1024kb" 16 | - name: PAGE_LIMIT 17 | value: "25" 18 | - name: SORTING 19 | value: "ascending" 20 | - name: N_BUCKETS 21 | value: "42" -------------------------------------------------------------------------------- /apps/billing/envs/prod-eu/version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | image: docker.io/kostiscodefresh/simple-env-app:3.0 12 | -------------------------------------------------------------------------------- /apps/billing/envs/prod-us/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: ENV 13 | value: "prod-us" 14 | - name: GPU_ENABLED 15 | value: "1" 16 | -------------------------------------------------------------------------------- /apps/billing/envs/prod-us/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../base 6 | 7 | 8 | patchesStrategicMerge: 9 | - deployment.yml 10 | - version.yml 11 | - replicas.yml 12 | - settings.yml 13 | 14 | -------------------------------------------------------------------------------- /apps/billing/envs/prod-us/replicas.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | replicas: 10 -------------------------------------------------------------------------------- /apps/billing/envs/prod-us/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: UI_THEME 13 | value: "dark" 14 | - name: CACHE_SIZE 15 | value: "1024kb" 16 | - name: PAGE_LIMIT 17 | value: "25" 18 | - name: SORTING 19 | value: "ascending" 20 | - name: N_BUCKETS 21 | value: "42" -------------------------------------------------------------------------------- /apps/billing/envs/prod-us/version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | image: docker.io/kostiscodefresh/simple-env-app:2.0 12 | -------------------------------------------------------------------------------- /apps/fake-invoices/base/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | annotations: 7 | codefresh.io/app: simple-go-app 8 | spec: 9 | replicas: 2 10 | selector: 11 | matchLabels: 12 | app: trivial-go-web-app 13 | template: 14 | metadata: 15 | labels: 16 | app: trivial-go-web-app 17 | spec: 18 | containers: 19 | - name: webserver-simple 20 | imagePullPolicy: Always 21 | image: docker.io/kostiscodefresh/simple-env-app:1.0 22 | ports: 23 | - containerPort: 8080 24 | -------------------------------------------------------------------------------- /apps/fake-invoices/base/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - deployment.yml 6 | - service.yml -------------------------------------------------------------------------------- /apps/fake-invoices/base/service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: simple-service 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: trivial-go-web-app 9 | ports: 10 | - protocol: TCP 11 | port: 80 12 | targetPort: 8080 -------------------------------------------------------------------------------- /apps/fake-invoices/envs/qa/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: ENV 13 | value: "qa" 14 | - name: GPU_ENABLED 15 | value: "1" 16 | -------------------------------------------------------------------------------- /apps/fake-invoices/envs/qa/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../base 6 | 7 | 8 | patchesStrategicMerge: 9 | - deployment.yml 10 | - version.yml 11 | - settings.yml 12 | 13 | 14 | -------------------------------------------------------------------------------- /apps/fake-invoices/envs/qa/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: UI_THEME 13 | value: "light" 14 | - name: CACHE_SIZE 15 | value: "2048kb" 16 | - name: PAGE_LIMIT 17 | value: "25" 18 | - name: SORTING 19 | value: "ascending" 20 | - name: N_BUCKETS 21 | value: "42" -------------------------------------------------------------------------------- /apps/fake-invoices/envs/qa/version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | image: docker.io/kostiscodefresh/simple-env-app:1.0 12 | -------------------------------------------------------------------------------- /apps/invoices/base/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | annotations: 7 | codefresh.io/app: simple-go-app 8 | spec: 9 | replicas: 2 10 | selector: 11 | matchLabels: 12 | app: trivial-go-web-app 13 | template: 14 | metadata: 15 | labels: 16 | app: trivial-go-web-app 17 | spec: 18 | containers: 19 | - name: webserver-simple 20 | imagePullPolicy: Always 21 | image: docker.io/kostiscodefresh/simple-env-app:1.0 22 | ports: 23 | - containerPort: 8080 24 | -------------------------------------------------------------------------------- /apps/invoices/base/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - deployment.yml 6 | - service.yml -------------------------------------------------------------------------------- /apps/invoices/base/service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: simple-service 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: trivial-go-web-app 9 | ports: 10 | - protocol: TCP 11 | port: 80 12 | targetPort: 8080 -------------------------------------------------------------------------------- /apps/invoices/envs/prod-eu/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: ENV 13 | value: "prod-eu" 14 | - name: GPU_ENABLED 15 | value: "1" 16 | -------------------------------------------------------------------------------- /apps/invoices/envs/prod-eu/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../base 6 | 7 | patchesStrategicMerge: 8 | - deployment.yml 9 | - version.yml 10 | - replicas.yml 11 | - settings.yml 12 | 13 | -------------------------------------------------------------------------------- /apps/invoices/envs/prod-eu/replicas.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | replicas: 8 -------------------------------------------------------------------------------- /apps/invoices/envs/prod-eu/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: UI_THEME 13 | value: "dark" 14 | - name: CACHE_SIZE 15 | value: "1024kb" 16 | - name: PAGE_LIMIT 17 | value: "25" 18 | - name: SORTING 19 | value: "ascending" 20 | - name: N_BUCKETS 21 | value: "42" -------------------------------------------------------------------------------- /apps/invoices/envs/prod-eu/version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | image: docker.io/kostiscodefresh/simple-env-app:3.0 12 | -------------------------------------------------------------------------------- /apps/invoices/envs/prod-us/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: ENV 13 | value: "prod-us" 14 | - name: GPU_ENABLED 15 | value: "1" 16 | -------------------------------------------------------------------------------- /apps/invoices/envs/prod-us/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../base 6 | 7 | 8 | patchesStrategicMerge: 9 | - deployment.yml 10 | - version.yml 11 | - replicas.yml 12 | - settings.yml 13 | 14 | -------------------------------------------------------------------------------- /apps/invoices/envs/prod-us/replicas.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | replicas: 10 -------------------------------------------------------------------------------- /apps/invoices/envs/prod-us/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: UI_THEME 13 | value: "dark" 14 | - name: CACHE_SIZE 15 | value: "1024kb" 16 | - name: PAGE_LIMIT 17 | value: "25" 18 | - name: SORTING 19 | value: "ascending" 20 | - name: N_BUCKETS 21 | value: "42" -------------------------------------------------------------------------------- /apps/invoices/envs/prod-us/version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | image: docker.io/kostiscodefresh/simple-env-app:2.0 12 | -------------------------------------------------------------------------------- /apps/invoices/envs/qa/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: ENV 13 | value: "qa" 14 | - name: GPU_ENABLED 15 | value: "1" 16 | -------------------------------------------------------------------------------- /apps/invoices/envs/qa/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | 5 | resources: 6 | - ../../base 7 | 8 | 9 | patchesStrategicMerge: 10 | - deployment.yml 11 | - version.yml 12 | - settings.yml 13 | 14 | 15 | -------------------------------------------------------------------------------- /apps/invoices/envs/qa/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: UI_THEME 13 | value: "light" 14 | - name: CACHE_SIZE 15 | value: "2048kb" 16 | - name: PAGE_LIMIT 17 | value: "25" 18 | - name: SORTING 19 | value: "ascending" 20 | - name: N_BUCKETS 21 | value: "42" -------------------------------------------------------------------------------- /apps/invoices/envs/qa/version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | image: docker.io/kostiscodefresh/simple-env-app:1.0 12 | -------------------------------------------------------------------------------- /apps/invoices/envs/staging/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: ENV 13 | value: "staging-us" 14 | - name: GPU_ENABLED 15 | value: "1" 16 | -------------------------------------------------------------------------------- /apps/invoices/envs/staging/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../base 6 | 7 | 8 | patchesStrategicMerge: 9 | - deployment.yml 10 | - version.yml 11 | - replicas.yml 12 | - settings.yml 13 | 14 | -------------------------------------------------------------------------------- /apps/invoices/envs/staging/replicas.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | replicas: 3 -------------------------------------------------------------------------------- /apps/invoices/envs/staging/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: UI_THEME 13 | value: "light" 14 | - name: CACHE_SIZE 15 | value: "1024kb" 16 | - name: PAGE_LIMIT 17 | value: "25" 18 | - name: SORTING 19 | value: "ascending" 20 | - name: N_BUCKETS 21 | value: "24" -------------------------------------------------------------------------------- /apps/invoices/envs/staging/version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | image: docker.io/kostiscodefresh/simple-env-app:2.0 12 | -------------------------------------------------------------------------------- /apps/orders/base/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | annotations: 7 | codefresh.io/app: simple-go-app 8 | spec: 9 | replicas: 2 10 | selector: 11 | matchLabels: 12 | app: trivial-go-web-app 13 | template: 14 | metadata: 15 | labels: 16 | app: trivial-go-web-app 17 | spec: 18 | containers: 19 | - name: webserver-simple 20 | imagePullPolicy: Always 21 | image: docker.io/kostiscodefresh/simple-env-app:1.0 22 | ports: 23 | - containerPort: 8080 24 | -------------------------------------------------------------------------------- /apps/orders/base/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - deployment.yml 6 | - service.yml -------------------------------------------------------------------------------- /apps/orders/base/service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: simple-service 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: trivial-go-web-app 9 | ports: 10 | - protocol: TCP 11 | port: 80 12 | targetPort: 8080 -------------------------------------------------------------------------------- /apps/orders/envs/prod-us/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: ENV 13 | value: "prod-us" 14 | - name: GPU_ENABLED 15 | value: "1" 16 | -------------------------------------------------------------------------------- /apps/orders/envs/prod-us/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../base 6 | 7 | 8 | patchesStrategicMerge: 9 | - deployment.yml 10 | - version.yml 11 | - replicas.yml 12 | - settings.yml 13 | 14 | -------------------------------------------------------------------------------- /apps/orders/envs/prod-us/replicas.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | replicas: 10 -------------------------------------------------------------------------------- /apps/orders/envs/prod-us/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: UI_THEME 13 | value: "dark" 14 | - name: CACHE_SIZE 15 | value: "1024kb" 16 | - name: PAGE_LIMIT 17 | value: "25" 18 | - name: SORTING 19 | value: "ascending" 20 | - name: N_BUCKETS 21 | value: "42" -------------------------------------------------------------------------------- /apps/orders/envs/prod-us/version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | image: docker.io/kostiscodefresh/simple-env-app:2.0 12 | -------------------------------------------------------------------------------- /apps/orders/envs/qa/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: ENV 13 | value: "qa" 14 | - name: GPU_ENABLED 15 | value: "1" 16 | -------------------------------------------------------------------------------- /apps/orders/envs/qa/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../base 6 | 7 | 8 | patchesStrategicMerge: 9 | - deployment.yml 10 | - version.yml 11 | - settings.yml 12 | 13 | 14 | -------------------------------------------------------------------------------- /apps/orders/envs/qa/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: UI_THEME 13 | value: "light" 14 | - name: CACHE_SIZE 15 | value: "2048kb" 16 | - name: PAGE_LIMIT 17 | value: "25" 18 | - name: SORTING 19 | value: "ascending" 20 | - name: N_BUCKETS 21 | value: "42" -------------------------------------------------------------------------------- /apps/orders/envs/qa/version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | image: docker.io/kostiscodefresh/simple-env-app:1.0 12 | -------------------------------------------------------------------------------- /apps/orders/envs/staging/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: ENV 13 | value: "staging-us" 14 | - name: GPU_ENABLED 15 | value: "1" 16 | -------------------------------------------------------------------------------- /apps/orders/envs/staging/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../base 6 | 7 | 8 | patchesStrategicMerge: 9 | - deployment.yml 10 | - version.yml 11 | - replicas.yml 12 | - settings.yml 13 | 14 | -------------------------------------------------------------------------------- /apps/orders/envs/staging/replicas.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | replicas: 3 -------------------------------------------------------------------------------- /apps/orders/envs/staging/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: UI_THEME 13 | value: "light" 14 | - name: CACHE_SIZE 15 | value: "1024kb" 16 | - name: PAGE_LIMIT 17 | value: "25" 18 | - name: SORTING 19 | value: "ascending" 20 | - name: N_BUCKETS 21 | value: "24" -------------------------------------------------------------------------------- /apps/orders/envs/staging/version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | image: docker.io/kostiscodefresh/simple-env-app:2.0 12 | -------------------------------------------------------------------------------- /apps/payments/base/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | annotations: 7 | codefresh.io/app: simple-go-app 8 | spec: 9 | replicas: 2 10 | selector: 11 | matchLabels: 12 | app: trivial-go-web-app 13 | template: 14 | metadata: 15 | labels: 16 | app: trivial-go-web-app 17 | spec: 18 | containers: 19 | - name: webserver-simple 20 | imagePullPolicy: Always 21 | image: docker.io/kostiscodefresh/simple-env-app:1.0 22 | ports: 23 | - containerPort: 8080 24 | -------------------------------------------------------------------------------- /apps/payments/base/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - deployment.yml 6 | - service.yml -------------------------------------------------------------------------------- /apps/payments/base/service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: simple-service 5 | spec: 6 | type: ClusterIP 7 | selector: 8 | app: trivial-go-web-app 9 | ports: 10 | - protocol: TCP 11 | port: 80 12 | targetPort: 8080 -------------------------------------------------------------------------------- /apps/payments/envs/prod-eu/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: ENV 13 | value: "prod-eu" 14 | - name: GPU_ENABLED 15 | value: "1" 16 | -------------------------------------------------------------------------------- /apps/payments/envs/prod-eu/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../base 6 | 7 | patchesStrategicMerge: 8 | - deployment.yml 9 | - version.yml 10 | - replicas.yml 11 | - settings.yml 12 | 13 | -------------------------------------------------------------------------------- /apps/payments/envs/prod-eu/replicas.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | replicas: 8 -------------------------------------------------------------------------------- /apps/payments/envs/prod-eu/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: UI_THEME 13 | value: "dark" 14 | - name: CACHE_SIZE 15 | value: "1024kb" 16 | - name: PAGE_LIMIT 17 | value: "25" 18 | - name: SORTING 19 | value: "ascending" 20 | - name: N_BUCKETS 21 | value: "42" -------------------------------------------------------------------------------- /apps/payments/envs/prod-eu/version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | image: docker.io/kostiscodefresh/simple-env-app:3.0 12 | -------------------------------------------------------------------------------- /apps/payments/envs/prod-us/deployment.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: ENV 13 | value: "prod-us" 14 | - name: GPU_ENABLED 15 | value: "1" 16 | -------------------------------------------------------------------------------- /apps/payments/envs/prod-us/kustomization.yml: -------------------------------------------------------------------------------- 1 | apiVersion: kustomize.config.k8s.io/v1beta1 2 | kind: Kustomization 3 | 4 | resources: 5 | - ../../base 6 | 7 | 8 | patchesStrategicMerge: 9 | - deployment.yml 10 | - version.yml 11 | - replicas.yml 12 | - settings.yml 13 | 14 | -------------------------------------------------------------------------------- /apps/payments/envs/prod-us/replicas.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | replicas: 10 -------------------------------------------------------------------------------- /apps/payments/envs/prod-us/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | env: 12 | - name: UI_THEME 13 | value: "dark" 14 | - name: CACHE_SIZE 15 | value: "1024kb" 16 | - name: PAGE_LIMIT 17 | value: "25" 18 | - name: SORTING 19 | value: "ascending" 20 | - name: N_BUCKETS 21 | value: "42" -------------------------------------------------------------------------------- /apps/payments/envs/prod-us/version.yml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: simple-deployment 6 | spec: 7 | template: 8 | spec: 9 | containers: 10 | - name: webserver-simple 11 | image: docker.io/kostiscodefresh/simple-env-app:2.0 12 | -------------------------------------------------------------------------------- /appsets/my-prod-appset.yml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: ApplicationSet 3 | metadata: 4 | name: my-prod-appset 5 | namespace: argocd 6 | spec: 7 | goTemplate: true 8 | goTemplateOptions: ["missingkey=error"] 9 | generators: 10 | - git: 11 | repoURL: https://github.com/kostis-codefresh/many-appsets-demo.git 12 | revision: HEAD 13 | directories: 14 | - path: apps/*/envs/prod-us 15 | - path: apps/*/envs/prod-eu 16 | template: 17 | metadata: 18 | name: '{{index .path.segments 1}}-{{index .path.segments 3}}' 19 | spec: 20 | # The project the application belongs to. 21 | project: default 22 | 23 | # Source of the application manifests 24 | source: 25 | repoURL: https://github.com/kostis-codefresh/many-appsets-demo.git 26 | targetRevision: HEAD 27 | path: '{{.path.path}}' 28 | 29 | # Destination cluster and namespace to deploy the application 30 | destination: 31 | server: https://kubernetes.default.svc 32 | namespace: '{{index .path.segments 1}}-{{index .path.segments 3}}' 33 | 34 | # Sync policy 35 | syncPolicy: 36 | syncOptions: 37 | - CreateNamespace=true 38 | automated: # automated sync by default retries failed attempts 5 times with following delays between attempts ( 5s, 10s, 20s, 40s, 80s ); retry controlled using `retry` field. 39 | prune: true # Specifies if resources should be pruned during auto-syncing ( false by default ). 40 | selfHeal: true # Specifies if partial app sync should be executed when resources are changed only in target Kubernetes cluster and no git change detected ( false by default ). 41 | 42 | -------------------------------------------------------------------------------- /appsets/my-qa-appset.yml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: ApplicationSet 3 | metadata: 4 | name: my-qa-appset 5 | namespace: argocd 6 | spec: 7 | goTemplate: true 8 | goTemplateOptions: ["missingkey=error"] 9 | generators: 10 | - git: 11 | repoURL: https://github.com/kostis-codefresh/many-appsets-demo.git 12 | revision: HEAD 13 | directories: 14 | - path: apps/*/envs/qa 15 | template: 16 | metadata: 17 | name: '{{index .path.segments 1}}-{{index .path.segments 3}}' 18 | spec: 19 | # The project the application belongs to. 20 | project: default 21 | 22 | # Source of the application manifests 23 | source: 24 | repoURL: https://github.com/kostis-codefresh/many-appsets-demo.git 25 | targetRevision: HEAD 26 | path: '{{.path.path}}' 27 | 28 | # Destination cluster and namespace to deploy the application 29 | destination: 30 | server: https://kubernetes.default.svc 31 | namespace: '{{index .path.segments 1}}-{{index .path.segments 3}}' 32 | 33 | # Sync policy 34 | syncPolicy: 35 | syncOptions: 36 | - CreateNamespace=true 37 | automated: # automated sync by default retries failed attempts 5 times with following delays between attempts ( 5s, 10s, 20s, 40s, 80s ); retry controlled using `retry` field. 38 | prune: true # Specifies if resources should be pruned during auto-syncing ( false by default ). 39 | selfHeal: true # Specifies if partial app sync should be executed when resources are changed only in target Kubernetes cluster and no git change detected ( false by default ). 40 | 41 | -------------------------------------------------------------------------------- /appsets/my-staging-appset.yml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: ApplicationSet 3 | metadata: 4 | name: my-staging-appset 5 | namespace: argocd 6 | spec: 7 | goTemplate: true 8 | goTemplateOptions: ["missingkey=error"] 9 | generators: 10 | - git: 11 | repoURL: https://github.com/kostis-codefresh/many-appsets-demo.git 12 | revision: HEAD 13 | directories: 14 | - path: apps/*/envs/staging 15 | template: 16 | metadata: 17 | name: '{{index .path.segments 1}}-{{index .path.segments 3}}' 18 | spec: 19 | # The project the application belongs to. 20 | project: default 21 | 22 | # Source of the application manifests 23 | source: 24 | repoURL: https://github.com/kostis-codefresh/many-appsets-demo.git 25 | targetRevision: HEAD 26 | path: '{{.path.path}}' 27 | 28 | # Destination cluster and namespace to deploy the application 29 | destination: 30 | server: https://kubernetes.default.svc 31 | namespace: '{{index .path.segments 1}}-{{index .path.segments 3}}' 32 | 33 | # Sync policy 34 | syncPolicy: 35 | syncOptions: 36 | - CreateNamespace=true 37 | automated: # automated sync by default retries failed attempts 5 times with following delays between attempts ( 5s, 10s, 20s, 40s, 80s ); retry controlled using `retry` field. 38 | prune: true # Specifies if resources should be pruned during auto-syncing ( false by default ). 39 | selfHeal: true # Specifies if partial app sync should be executed when resources are changed only in target Kubernetes cluster and no git change detected ( false by default ). 40 | 41 | -------------------------------------------------------------------------------- /docs/hierarchy-of-manifests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kostis-codefresh/many-appsets-demo/317b8b8195c57f7e6489e5359719acc3eeceabc6/docs/hierarchy-of-manifests.png -------------------------------------------------------------------------------- /docs/levels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kostis-codefresh/many-appsets-demo/317b8b8195c57f7e6489e5359719acc3eeceabc6/docs/levels.png -------------------------------------------------------------------------------- /root-argocd-app.yml: -------------------------------------------------------------------------------- 1 | apiVersion: argoproj.io/v1alpha1 2 | kind: Application 3 | metadata: 4 | name: all-apps 5 | namespace: argocd 6 | spec: 7 | project: default 8 | source: 9 | repoURL: https://github.com/kostis-codefresh/many-appsets-demo.git 10 | targetRevision: HEAD 11 | path: appsets 12 | destination: 13 | server: https://kubernetes.default.svc 14 | namespace: argocd 15 | syncPolicy: 16 | syncOptions: 17 | - CreateNamespace=true 18 | automated: 19 | prune: true 20 | selfHeal: true --------------------------------------------------------------------------------