Skip to content

mstrzele/applicationset

 
 

Repository files navigation

Argo CD ApplicationSet CRD

The Argo CD ApplicationSet CRD and controller provides a formal solution to replace the app-of-apps pattern with the ultimate goal of introducing ApplicationSet as a first class supported object in Argo CD Core.

This project will initially be maintained separately from Argo CD, in order to allow quick iteration of the spec and implementation, without tying it to Argo CD releases. No promises of backwards compatibility are made, at least until merging into Argo CD proper.

Proposal:

Example Spec:

# This is an example of a typical ApplicationSet which uses the cluster generator.
# An ApplicationSet is comprised with two stanzas:
#  - spec.generator - producer of a list of values supplied as arguments to an app template
#  - spec.template - an application template, which has been parameterized
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: guestbook
spec:
  generators:
  - clusters: {}
  template:
    metadata:
      name: '{{name}}-guestbook'
    spec:
      source:
        repoURL: https://github.com/infra-team/cluster-deployments.git
        targetRevision: HEAD
        chart: guestbook
      destination:
        server: '{{server}}'
        namespace: guestbook

Additional examples are available in the examples directory.

Development

Running the ApplicationSet controller as an image within Kubernetes

The following assumes you have:

  1. Installed a recent version of kustomize (3.x+).
  2. Created a container repository for your development image.
  1. Ran docker login from the CLI, and provided your registry credentials.
  2. Deployed ArgoCD into the argocd namespace.

To build and push a container with your current code, and deploy Kubernetes manifests for the controller Deployment:

# Build and push the image to container registry
IMAGE="(username)/argocd-applicationset:v0.0.1" make image

# Deploy the ApplicationSet controller manifests
IMAGE="(username)/argocd-applicationset:v0.0.1" make deploy

The ApplicationSet controller should now be running in the argocd namespace.

Running the ApplicationSet Controller as a standalone process from the CLI

When iteratively developing a Kubernetes controller, it is often easier to run the controller process from your local CLI, rather than requiring a container rebuild and push for new code changes.

  1. First, setup a local Argo CD development environment:
  1. Ensure that port 8081 is exposed in the Argo CD test server container:
  • In the Makefile file at the root of the Argo CD repo:
    • Add the following to this location in the Makefile
    • Replace: -p 4000:4000 \
    • With: -p 4000:4000 -p 8081:8081 \
    • This exposes port 8081 (the repo-server listen port), which is required for ApplicationSet Git generator functionality.
  1. Start Argo CD and wait for startup completion:
  • Ensure your active namespace is set to argocd (for example, kubectl config view --minify | grep namespace:).
  • Run make start under the Argo CD dev environment.
  • Wait for the Argo CD processes to start within the container.
  • These processes should remaining running, alongside the local ApplicationSet controller, during the following steps.
  • Verify that:
    • You have exposed port 8081 in the Makefile (as described in prerequisites). docker ps should show port 8081 as mapped to an accessible IP.
  1. Apply the ApplicationSet CRDs into the argocd namespace, and build the controller:
kubectl apply -f manifests/crds/argoproj.io_applicationsets.yaml
make build
  1. Run the Application Set Controller from the CLI:
NAMESPACE=argocd ./dist/argocd-applicationset --metrics-addr=":18081" --probe-addr=":18082" --argocd-repo-server=localhost:8081 --debug  --namespace=argocd

On success, you should see the following(amongst other text):

INFO	controller-runtime.controller	Starting Controller	{"controller": "applicationset"}
INFO	controller-runtime.controller	Starting workers	{"controller": "applicationset", "worker count": 1}

About

Argo CD ApplicationSet

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 95.1%
  • Shell 2.3%
  • Makefile 2.1%
  • Dockerfile 0.5%