Control Plane repository defines the desired state of shared infrastructure components and enables self-service onboarding process for the application developer teams.
Repository contains the following directories:
- argocd - directory contains Argo CD instance configuration. The configuration includes RBAC settings and infrastructure application definitions.
- clusters - directory contains adminstrator level cluster configurations.
The idea is to leverage the GitOps approach and pull requests to allow application developer teams to self-onboard by proposing infrastructure changes via pull requests. To enable the GitOps process we just need to create an Argo CD application that manages Argo CD configuration and propogate repository changes to the Argo CD Kubernetes namespace.
Argo CD leverages Projects to separate teams from each other and to where the team can deploy their applications. This task is naturally done by the Argo CD administrator who is responsible for running the shared Argo CD. However, it does not mean application developers should create tickets to self-onboard. With GitOps, they can send a pull request that introduces requires Argo CD Projects.
To create project:
- Copy the
argocd/USERNAME-project.yaml
file and replaceUSERNAME
with your GitHub username. - Commit changes and create a pull request to the
main
branch.
Before starting to manage anything, application developer teams need a Kubernetes namespace. To be precise, a set of namespaces, one for each environment. Kubernetes namespaces are used to isolate application resources from each other and separate teams' permissions, so namespaces must be managed by administrators.
To create namespace:
- Copy the
clusters/argocon/USERNAME-namespaces.yaml
file and replaceUSERNAME
with your GitHub username. - Commit changes and create a pull request to the
main
branch.
Once we are done with configuring infrastructure it's time to use it and deploy something. Jump to https://github.com/argocon2022-workshop/demo-app repository to continue!
If you've noticed we've manually created two applications to install kyverno and external-secrets onto the managed cluster. Both kyverno and external-secrets are infrastructure components that are typically installed into all managed clusters. We might continue to manually create applications for each managed cluster, but this is error-prone and tedious. The process can be automated using config management tools and some scripting on top but there is a better way. Argo CD provides a first class support to cluster administrator use cases - ApplicationSet CRD. ApplicationSet automates application management and provide featutes to automatically create an app for each managed cluster:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: addons
spec:
generators:
- matrix:
generators:
- git:
repoURL: https://github.com/argocon2022-workshop/control-plane
revision: HEAD
directories:
- path: clusters/addons/*
- clusters:
selector:
matchExpressions:
- {key: 'akuity.io/argo-cd-cluster-name', operator: NotIn, values: [in-cluster]}
template:
metadata:
name: '{{path.basename}}-{{name}}'
spec:
project: default
source:
repoURL: https://github.com/argocon2022-workshop/control-plane
targetRevision: HEAD
path: '{{path}}'
destination:
server: '{{server}}'
namespace: '{{path.basename}}'