Git Product home page Git Product logo

argocd-git-override's Introduction

argocd-git-override

Admission Controller to modify the git source for ArgoCD Applications

The problem this webhooks solves is that when you are working with a parent ArgoCD Applications that deploy a child ArgoCD Applications, you might need to change something in the child ArgoCD Application using a forked repo, you can't edit the child ArgoCD Application CR on the cluster because the parent App will revert your edit back to what's in git.

You can avoid this by adding an ignoreDifference in the ArgoCD config, but when you are dealing with more than 20 ArgoCD Applications and between parent and children, and a combination of git repositories it becomes hard to first find the correct ArgoCD corresponding to your git repo, this webhook allows you to create a simple mapping configmap to make sure that any ArgoCD Application points to your fork repos, this avoids your fork repos being polluted with your git URLs and keeping the upstream URLs.

Install

  • If not using ArgoCD operator edit the argocd-cm configMap

    data:
      resource.customizations: |
        argoproj.io/Application:
          ignoreDifferences: |
            jsonPointers:
            - /spec/source/targetRevision
            - /spec/source/repoURL
        argoproj.io/AppProject:
          ignoreDifferences: |
            jsonPointers:
            - /spec/sourceRepos
  • If using the ArgoCD operator then edit the instance of kind ArgoCD

    spec:
      resourceCustomizations: |
        argoproj.io/Application:
          ignoreDifferences: |
            jsonPointers:
            - /spec/source/targetRevision
            - /spec/source/repoURL
        argoproj.io/AppProject:
          ignoreDifferences: |
            jsonPointers:
            - /spec/sourceRepos
  • Configure which git repository and/or branch/revision you would like to override. Create a configmap with an array of git repositories to match an upstream and replace with your origin, usually a forked repo and branch.

    cat <<EOF | oc apply -f -
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: argocd-git-override
      namespace: openshift-gitops
    data:
      map.yaml: |-
        map:
        - upstreamRepoURL: https://github.com/csantanapr/argocd-git-override.git
          originRepoUrL: https://github.com/fork/argocd-git-override.git
          originBranch: fork-branch
    EOF
  • Deploy the deployment and service to OpenShift in the openshift-gitops namespace, or another namespace

    oc create -n openshift-gitops  -f https://github.com/csantanapr/argocd-git-override/releases/download/v1.1.0/deployment.yaml
  • Deploy the MutatingWebhookConfiguration, edit the yaml to specify a different namespace for the target service if you used a different namespace than openshift-gitops replace it with the namespace used in the previous step

    oc create -f https://github.com/csantanapr/argocd-git-override/releases/download/v1.1.0/webhook.yaml
  • Activate webhook, by adding a label to the openshift-gitops namespace you deploy the webhook service

    oc label ns openshift-gitops cntk=experiment

Development

  • Change to the openshift-gitops namespace as context

    oc project openshift-gitops
    
  • Run dev mode

    skaffold dev
  • Test in another terminal to create an ArgoCD Application

    oc create -f test/child/argocd.yaml --dry-run=server -o yaml
  • Test in another terminal to create an ArgoCD Project

    oc create -f test/parent/argocd-project.yaml --dry-run=server -o yaml
  • To debug delete the quota in the openshift-gitops then run debug

    oc delete quota openshift-gitops-compute-resources -n openshift-gitops
    skaffold debug

    Then you would be able to attach a nodejs debugger

argocd-git-override's People

Contributors

csantanapr avatar ericsmalling avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.