Argo CD allows us to integrate more config management tools using config management plugins. Most prominent inbuilt tools are helm and kustomize.
We have to option, when it comes to create our own Config Management Plugin (CMP):
Add the plugin config to the main Argo CD ConfigMap. Our repo-server container will then run the plugin’s commands.
There are two ways to install a Config Management Plugin:
sidecar plugin
This is a good option for a more complex plugin that would clutter the Argo CD ConfigMap. A copy of the repository is sent to the sidecar container as a tarball and processed individually per application.
ConfigMap plugin (this method is deprecated and will be removed in a future version)
The repo-server container will run your plugin’s commands.
Sidecar plugin
An operator can configure a plugin tool via a sidecar to repo-server. The following changes are required to configure a new plugin:
Write the plugin configuration file
Plugins will be configured via a ConfigManagementPlugin manifest located inside the plugin container.
While the ConfigManagementPlugin looks like a Kubernetes object, it is not actually a custom resource. It only follows kubernetes-style spec conventions.
The generate command must print a valid YAML stream to stdout. Both init and generate commands are executed inside the application source directory.
The discover.fileName is used as glob pattern to determine whether an application repository is supported by the plugin or not.
If discover.fileName is not provided, the discover.find.command is executed in order to determine whether an application repository is supported by the plugin or not.
The find command should return a non-error exit code and produce output to stdout when the application source type is supported.
Place the plugin configuration file in the sidecar
Argo CD expects the plugin configuration file to be located at /home/argocd/cmp-server/config/plugin.yaml in the sidecar.
If you use a custom image for the sidecar, you can add the file directly to that image.
If you use a stock image for the sidecar or would rather maintain the plugin configuration in a ConfigMap, just nest the plugin config file in a ConfigMap under the plugin.yaml key and mount the ConfigMap in the sidecar (see next section).
Register the plugin sidecar
To install a plugin, patch argocd-repo-server to run the plugin container as a sidecar, with argocd-cmp-server as its entrypoint. You can use either off-the-shelf or custom-built plugin image as sidecar image. For example:
ConfigMap plugin
ConfigMap plugins are deprecated and will no longer be supported in 2.7.
The following changes are required to configure a new plugin:
Make sure required binaries are available in argocd-repo-server pod. The binaries can be added via volume mounts or using a custom image (see custom_tools for examples of both).
Register a new plugin in argocd-cm ConfigMap:
The generate command must print a valid YAML or JSON stream to stdout. Both init and generate commands are executed inside the application source directory or in path when specified for the app.
Create an Application which uses your new CMP.
Migrating from argocd-cm plugins
Installing plugins by modifying the argocd-cm ConfigMap is deprecated as of v2.4. Support will be completely removed in a future release.
To converting the ConfigMap entry into a config file, First, copy the plugin’s configuration into its own YAML file. Take for example the following ConfigMap entry:
The pluginName item would be converted to a config file like this:
The lockRepo key is not relevant for sidecar plugins, because sidecar plugins do not share a single source repo directory when generating manifests.
Debugging a CMP
If you are actively developing a sidecar-installed CMP, keep a few things in mind:
If you are mounting plugin.yaml from a ConfigMap, you will have to restart the repo-server Pod so the plugin will pick up the changes.
If you have baked plugin.yaml into your image, you will have to build, push, and force a re-pull of that image on the repo-server Pod so the plugin will pick up the changes. If you are using :latest, the Pod will always pull the new image. If you’re using a different, static tag, set imagePullPolicy: Always on the CMP’s sidecar container.
CMP errors are cached by the repo-server in Redis. Restarting the repo-server Pod will not clear the cache. Always do a “Hard Refresh” when actively developing a CMP so you have the latest output.