An ArgoCD Configuration Management Plugin (CMP) for processing OpenShift Templates. This plugin discovers template files, processes them using the oc CLI, and outputs a stream of valid Kubernetes/OpenShift manifests.
This plugin:
- Discovers all OpenShift template files in your repository
- Supports multiple templates per repository, processing each one automatically
- Processes them using the
occommand-line tool - Passes parameters from ArgoCD Application configuration
- Generates standard Kubernetes/OpenShift manifests
ArgoCD only requires that plugins output valid manifests to stdout.
The plugin automatically discovers all OpenShift templates in the repository by scanning for any YAML file containing kind: Template or apiVersion: template.openshift.io/v1. This includes files in subdirectories like ./openshift/.
When multiple templates are found, each is processed independently with the same set of parameters. The --ignore-unknown-parameters flag ensures that parameters not referenced by a given template are silently ignored.
Example template:
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: my-template
parameters:
- name: APP_NAME
description: Application name
required: true
- name: APP_NAMESPACE
description: Application namespace
required: true
- name: REPLICAS
description: Number of replicas
value: "3" # Default value
- name: IMAGE_TAG
description: Image tag
value: "latest" # Default value
objects:
- apiVersion: v1
kind: ConfigMap
metadata:
name: ${APP_NAME}-config
namespace: ${APP_NAMESPACE}The plugin handles template parameters as follows:
-
Parameters with default values: If a template parameter has a
valuefield (default),oc processwill automatically use it if the parameter is not provided viaplugin.parameters. -
Required parameters: If a template parameter has
required: trueand no default value, it must be provided viaplugin.parametersor the processing will fail. -
Parameter precedence: Parameters provided via
plugin.parameterswill override template default values. -
Unknown parameters: The plugin uses
--ignore-unknown-parameters, so if you pass a parameter that doesn't exist in the template, it will be ignored (useful for optional parameters).
Example with defaults:
# Template defines:
parameters:
- name: REPLICAS
value: "3" # Default
# If you don't provide REPLICAS in plugin.parameters, it will use "3"
# If you provide REPLICAS: "5", it will use "5"The plugin requires a container image containing the oc binary. The version of the oc binary should match the OpenShift cluster version where ArgoCD is running.
Build the image using Podman:
# Build with default OpenShift version (4.19.0)
podman build -t argocd-openshift-template-processor-simple:1.0 .
# Build for a specific OpenShift version
podman build \
--build-arg OPENSHIFT_VERSION=4.19.0 \
-t argocd-openshift-template-processor-simple:1.0 \
-f Dockerfile .
# Build and tag for a container registry
podman build \
--build-arg OPENSHIFT_VERSION=4.19.0 \
-t quay.io/myorg/argocd-openshift-template-processor-simple:1.0 \
-f Dockerfile .
# Load image into kind cluster (if using kind for local testing)
kind load docker-image argocd-openshift-template-processor-simple:1.0 --name <cluster-name>To determine which OpenShift version your cluster is running:
oc versionThe oc binary version should match your OpenShift cluster version. You can find available OpenShift client versions at:
https://mirror.openshift.com/pub/openshift-v4/clients/ocp/
-
Apply the ConfigMap containing the plugin definition:
oc apply -f configmap.yaml
-
Patch the ArgoCD repo-server deployment to add the sidecar container:
oc patch deployment argocd-repo-server -n argocd --patch-file repo-server-patch.yaml
-
Update the
imagefield inrepo-server-patch.yamlto point to your built image.
Create an ArgoCD Application that uses this plugin:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: my-app
spec:
source:
repoURL: https://github.com/myorg/myrepo
path: .
plugin:
name: openshift-template-processor
parameters:
- name: MY_PARAM
string: my-value
- name: ANOTHER_PARAM
string: another-valueThe plugin will automatically:
- Discover all template files in your repository
- Process each template independently
- Pass
APP_NAMEandAPP_NAMESPACEfrom ArgoCD - Pass any parameters you specify in
spec.source.plugin.parameters - Use default values from the template for parameters not explicitly provided
- Process each template with
oc process
Note: Parameters defined in the template with default values will be used automatically. You only need to provide parameters in plugin.parameters if you want to override the defaults or if the parameter is required.
The plugin supports templates from remote URLs. Use the TEMPLATE_NAME environment variable to specify a remote template:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: remote-template-app
spec:
source:
repoURL: https://github.com/myorg/myrepo
path: .
plugin:
name: openshift-template-processor-simple-v1.0
env:
- name: TEMPLATE_NAME
value: https://raw.githubusercontent.com/redhat-cop/openshift-templates/master/nexus/nexus-deployment-template.yml
parameters:
- name: APP_NAME
string: nexus
- name: APP_NAMESPACE
string: defaultThe plugin will automatically download the template from the URL and process it.
You can also load parameters from a file in your repository using the PARAM_FILE environment variable:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: app-with-params-file
spec:
source:
repoURL: https://github.com/jonmosco/openshift-template-argocd-cmp/examples/openshift
path: .
plugin:
name: openshift-template-processor-simple-v1.0
env:
- name: PARAM_FILE
value: app.params
parameters:
- name: APP_NAME
string: my-app
- name: APP_NAMESPACE
string: defaultThe parameter file should be in KEY=VALUE format:
REPLICAS=3
IMAGE=nginx:1.21
ENVIRONMENT=production
Parameters from the file will be merged with parameters from plugin.parameters (environment variables take precedence).
The plugin determines the template source in the following order:
- TEMPLATE_NAME environment variable - If set, uses this single template (can be URL or local path)
- Auto-discovery - Finds all YAML files in the repository containing
kind: TemplateorapiVersion: template.openshift.io/v1, including subdirectories
Repositories can contain multiple OpenShift templates. For example:
myrepo/
openshift/
deployment-template.yaml # Deployment, Service, ConfigMap
cronjob-template.yaml # CronJob for batch processing
monitoring-template.yaml # PrometheusRule, ServiceMonitor
The plugin discovers and processes all of them in a single ArgoCD Application. Each template receives the same parameters; parameters not referenced by a template are silently ignored via --ignore-unknown-parameters.
To process only a specific template, set the TEMPLATE_NAME environment variable in the ArgoCD Application spec.
- The plugin requires the
occommand-line tool to be installed in the container image. - The
ocbinary version must match the OpenShift cluster version where ArgoCD is running.