https://github.com/chengfang/multi-source-cmp
  
  
    Argo CD multi-source applications using CMP (configuration management plugin) 
    https://github.com/chengfang/multi-source-cmp
  
        Last synced: 7 months ago 
        JSON representation
    
Argo CD multi-source applications using CMP (configuration management plugin)
- Host: GitHub
- URL: https://github.com/chengfang/multi-source-cmp
- Owner: chengfang
- License: apache-2.0
- Created: 2024-04-22T03:13:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-25T02:47:59.000Z (over 1 year ago)
- Last Synced: 2025-01-31T11:18:28.279Z (9 months ago)
- Size: 195 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- 
            Metadata Files:
            - Readme: README.md
- License: LICENSE
 
Awesome Lists containing this project
README
          # Argo CD multi-source applications with CMP (config management plugin)
This repo contains some Argo CD applications to demonstrate how to configure 
multi-source apps to work with CMP.
## Project structure
* CMP plugin config files
  * the config map that defines the CMP plugin: `cmp/cmp-plugin-config.yaml`
  * the patch file for argocd-repo-server: `cmp/argocd-repo-server-patch.yaml`
```bash
└── cmp
    ├── argocd-repo-server-patch.yaml
    └── cmp-plugin-config.yaml
```
* user application files, including CMP marker files for plugin discovery. `source1`
  and `source2` can serve as the source individually for single-source Argo CD
  application, or jointly for multi-source Argo CD application.
```bash
├── apps
│   ├── source1
│   │   └── cmp-plugin-config.env
│   └── source2
│       └── tomcat2.yaml 
```
* Argo CD application manifest files, including both single-source and multi-source
  applications.
```bash
├── argo-apps
│   ├── multi-source-app-with-discover.yaml
│   └── single-source-app.yaml
```
## Install CMP as side-car container in argocd-repo-server
```bash
# switch to argocd namespace for convenience
kubectl config set-context --current --namespace argocd
# apply the CMP plugin config as a config map
kubectl apply -f cmp/cmp-plugin-config.yaml
# apply the patch to argocd-repo-server
kubectl patch deployments/argocd-repo-server --patch-file cmp/argocd-repo-server-patch.yaml
# verify CMP plugin and argocd-repo-server
kubectl get cm cmp-plugin-config
kubectl get deploy | fgrep argocd-repo-server
```
## Deploy a single-source Argo CD application with CMP
```bash
# apply the Argo CD application manifest
kubectl apply -f argo-apps/single-source-app.yaml
# verify application is deployed, and the configmap resource is generated by the CMP plugin.
# The configmap name is based on the value in the file located in `source1`, and the
# Argo CD application name.
kubectl get cm source1-single-source-app
kubectl get app single-source-app
# clean up
kubectl delete app single-source-app
kubectl delete cm source1-single-source-app
```
## Deploy a multi-source Argo CD application with CMP
```bash
# apply the Argo CD application manifest
kubectl apply -f argo-apps/multi-source-app-with-discover.yaml
# verify application is deployed, and the configmap resource is generated by the CMP plugin.
# The configmap name is based on the value in the file located in `source1`, and the
# Argo CD application name.
# This multi-source application also includes a tomcat deployment.
kubectl get cm source1-multi-source-app-with-discover
kubectl get app multi-source-app-with-discover
kubectl get pod
# clean up
kubectl delete app multi-source-app-with-discover
kubectl delete cm source1-multi-source-app-with-discover
```
The screenshot from Argo CD UI shows the Argo CD application `multi-source-app-with-discover`
is healthy and synced up correctly. It contains both the config map `source1-multi-source-app-with-discover`
generated by the CMP plugin, and the tomcat deployment from the 2nd application source.

## Limitations of using CMP in multi-source application
A single-source Argo CD application can be configured to use a certain CMP in either of
the following 2 ways:
* Include a `discover` mechanism in the CMP configuration, typically via some marker files.
* specify a `plugin` element in the Argo CD application spec `source` section to
  denote the association between the CMP and application source. This `plugin`
  element may also include environment variables and parameters that will be passed
  to the CMP.
For multi-source applications using CMP, only the first option, i.e., `discover`
mechanism is supported. Each individual source under the `sources` field in a 
multi-source application does not allow a `plugin` field, as would a regular
single-source application.
As demonstrated in this project, application-specific parameters and variables
can still be passed to CMP runtime via files in application source.