{"id":16927802,"url":"https://github.com/dirien/rancher-argocd-plugins","last_synced_at":"2026-04-29T14:37:35.614Z","repository":{"id":41904724,"uuid":"484160077","full_name":"dirien/rancher-argocd-plugins","owner":"dirien","description":"How to use plugins in ArgoCd","archived":false,"fork":false,"pushed_at":"2022-04-23T09:50:22.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T06:44:05.382Z","etag":null,"topics":["argocd","kubernetes","rancher"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dirien.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-21T18:19:51.000Z","updated_at":"2022-04-26T04:52:54.000Z","dependencies_parsed_at":"2022-08-11T20:50:11.708Z","dependency_job_id":null,"html_url":"https://github.com/dirien/rancher-argocd-plugins","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirien%2Francher-argocd-plugins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirien%2Francher-argocd-plugins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirien%2Francher-argocd-plugins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirien%2Francher-argocd-plugins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dirien","download_url":"https://codeload.github.com/dirien/rancher-argocd-plugins/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244728187,"owners_count":20500023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argocd","kubernetes","rancher"],"created_at":"2024-10-13T20:35:08.978Z","updated_at":"2026-04-29T14:37:30.587Z","avatar_url":"https://github.com/dirien.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# How To create an Argo CD Plugin? \n\n## Motivation\n\nThe recent tweet from the argoproj, was the motivation to get my hands \"dirty\" and play a little with `kbld`. But I install thought about try to integrate `kbld` with the Argo CD management plugin system. Always wanted to do something with this interesting looking functionality.\n\n%[https://twitter.com/argoproj/status/1517201502246301696?s=20\u0026t=4fLiid2JaBZnFPapSvIFYQ]\n\n## About kbld\n\n[kbld](https://carvel.dev/kbld/docs/v0.33.0/) is a tool for building Docker images and resolving image references. We are not using in this tutorial the building part of `kbld`. Instead, we focus on the image references resolving part.\n\nWhen you apply `kbld` an on existing manifest, you will see that image digest reference (e.g.\nindex.docker.io/your-username/your-repo@sha256:\n4c8b96...) was used inserted instead of a tagged reference (e.g. kbld:docker-io...).\n\nBecause tags are mutable, they have a certain disadvantages when you use them to deploy an image:\n\nIn Kubernetes, deploying by tag can result in unexpected behaviours. For example, assume that you have an existing `Deployment` resource that references a container image by tag 0.0.1. To fix a bug or make a small change, your build process creates a new image but with the same tag 0.0.1\n\nNew `Pods` that are created from your Deployment resource can end up using either the old or the new image, even if you don't change your Deployment resource specification.\n\nDigest references are preferred to other image reference forms as they are immutable, hence provide a guarantee that exact version of built software will be deployed.\n\n## What Are Argo CD Plugins?\n\nArgo CD allows us to integrate more config management tools using config management plugins. Most prominent inbuilt tools are helm and kustomize.\n\nWe have to option, when it comes to create our own `Config Management Plugin` (CMP):\n\n1. Add the plugin config to the main Argo CD ConfigMap. Our repo-server container will then run the plugin's commands.\n\nAccording tho the official documentation of Argo CD this is a good option for a simple plugin that requires only a few lines of code. As it would still nicely fit into the Argo CD ConfigMap.\n\n2. Add the plugin as a sidecar to the repo-server Pod.\n\nThis option is the way to go for more complex plugins, which would bloat our Argo CD ConfigMap.\n\n## How To Crate The kbld Plugin?\n\nIn this blog, I am going to use the option 1. And I will use the helm chart to deploy Argo CD.\n\nTha means I going to to add the following lines to my `values.yaml` file:\n\n```yaml\n  config:\n    configManagementPlugins: |\n      - name: kbld\n        generate:                 \n          command: [\"bash\", \"-c\"]\n          args: ['helm template --release-name \"$ARGOCD_APP_NAME\" -f \u003c(echo \"$HELM_VALUES\") . \u003e kbld.yaml \u0026\u0026 kbld -f kbld.yaml \u003e\u003e final.yaml \u0026\u0026 cat final.yaml']\n```\nKeep in mind, that a plug consist of the commands: `init` and `generate`. The `init` command is optional and takes care to initialize application source directory.\n\nThe `generate` command must print a valid YAML or JSON stream to stdout.\n\nIf you need both, your definition would look like this:\n\n```yaml\n...\n    - name: pluginName\n      init:                        \n        command: [\"sample command\"]\n        args: [\"sample args\"]\n      generate:                     \n        command: [\"sample command\"]\n        args: [\"sample args\"]\n...\n```\n\nTo pass any helm values, I created the `HELM_VALUES` environment variable. The other variable `ARGOCD_APP_NAME` is one of the default [environment variables](https://argo-cd.readthedocs.io/en/stable/user-guide/build-environment/) of Argo CD.\n\nThe second part we need now to do now, to get this plugin to work is to download the `kbld` binary and add it to the `argocd_repo_server`\n\nFor this, we're going to use an init container and a shared volume.\n\nThe init container will download the `kbld` binary and save it to shared volume. The shared volume will be then mounted to the `argocd_repo_server` container.\n\n```yaml\nrepoServer:\n  initContainers:\n    - name: download-tools\n      image: busybox:1.35.0\n      command: [ sh, -c ]\n      env:\n        - name: KBLD_VERSION\n          value: \"0.33.0\"\n      args:\n        - wget -q https://github.com/vmware-tanzu/carvel-kbld/releases/download/v${KBLD_VERSION}/kbld-linux-amd64 \u0026\u0026\n          mv kbld-linux-amd64 /custom-tools/kbld \u0026\u0026\n          chmod +x /custom-tools/kbld\n      volumeMounts:\n        - mountPath: /custom-tools\n          name: custom-tools\n  volumes:\n    - name: custom-tools\n      emptyDir: { }\n  volumeMounts:\n    - mountPath: /usr/local/bin/kbld\n      name: custom-tools\n      subPath: kbld\n```\n\nIf you prefer to use option 2, providing the CMP as a sidecar to the repo-server Pod check out the [Argo CD docs](https://argo-cd.readthedocs.io/en/stable/user-guide/config-management-plugins/#option-2-configure-plugin-via-sidecar)\n\n## Rancher Desktop\n\nFor this example, I am going to use the [Rancher Desktop](https://rancherdesktop.io/) for my local Kubernetes cluster.\n\nDepending on your operating system, you may have a different way of installing Rancher Desktop. Check the installation guide on their website. -\u003e https://docs.rancherdesktop.io/getting-started/installation\n\n## Install The ArgoCD Helm chart\n\nI put both snippets into a values file (`argocd-values.yaml`) and installed the ArgoCD Helm chart.\n\n```bash\nhelm upgrade -i  my-argo-cd argo/argo-cd --version 4.5.4 -f argocd-values.yaml\n```\n\n## Test The Plugin\n\nSo let's test the plugin. All we need to do is to create a new application in Argo CD. The application manifest will look like this:\n\n```yaml\napiVersion: argoproj.io/v1alpha1\nkind: Application\nmetadata:\n  name: test\n  namespace: default\nspec:\n  destination:\n    namespace: default\n    server: https://kubernetes.default.svc\n  project: default\n  source:\n    chart: minecraft-exporter\n    plugin:\n      env:\n        - name: HELM_VALUES\n          value: |\n            replicaCount: 1\n      name: kbld\n    repoURL: https://dirien.github.io/minecraft-prometheus-exporter\n    targetRevision: 0.5.0\n```\n\nTake note of the new `plugin` section. We are using here the name of the plugin we created earlier. And as mentioned before, we are using the `HELM_VALUES` environment variable to pass any helm values.\n\nIf everything is working, you should see  all the images tags are replaced with their image digest reference.\n\n```yaml\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  annotations:\n    kbld.k14s.io/images: |\n      - origins:\n        - resolved:\n            tag: 0.13.0\n            url: ghcr.io/dirien/minecraft-exporter:0.13.0\n        url: ghcr.io/dirien/minecraft-exporter@sha256:4a6a3acd7fdcdf7f93817dcba54b2928aa02b33b132b44ddcc608f693f8e8723\n  labels:\n    app: minecraft-exporter\n...\nspec:\n  containers:\n    - image: \u003e-\n        ghcr.io/dirien/minecraft-exporter@sha256:4a6a3acd7fdcdf7f93817dcba54b2928aa02b33b132b44ddcc608f693f8e8723\n      imagePullPolicy: IfNotPresent\n...\n```\n\n## Wrap Up\n\nThis is just one little example, on how to use the Argo CD CMP functionality. And its actually a quite good example, because we avoid using the tag reference, but instead use the digest reference.\n\nFeel free to check the Argo CD docs for more information about the [usage of plugins](https://argo-cd.readthedocs.io/en/stable/user-guide/config-management-plugins/#plugins)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirien%2Francher-argocd-plugins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirien%2Francher-argocd-plugins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirien%2Francher-argocd-plugins/lists"}