#kubernetes#cluster#deploy
Using Argocd to Deploy Kubernetes Resources

Using Argocd to Deploy Kubernetes Resources

Deploying resources to Kubernetes clusters can be as simple as running:

kubectl apply -f <resource>.yaml

It's the standard way to deploy services and apps. When you start to deploy more complex applications you might use tools like kustomize and/or Helm which allow you to configure and adjust resources for your use.

Managing bigger clusters and/or having a bigger team makes this way of deployments a burden. You don't really know what has been deployed and which version of the services are deployed. You can of course use the API and kubectl to get that information back but this becomes tedious relatively quickly.

GitOps tools like ArgoCD are built to solve this issue. They give you discoverability (what is deployed where) and automation (how is it deployed). We recently started using it to get better control of our various deployments.

ArgoCD terminology

ArgoCD declares a couple of Concepts/CRDs which are helpful to know:

  • Application is a resource containing the definition on how to deploy other Kubernetes resources
  • AppProject represents a logical grouping of applications
  • Cluster credentials can be configured to let ArgoCD deploy resources on various Kubernetes clusters
  • Repository credentials can be configured to have different repositories which act as the source for ArgoCD

How we use ArgoCD

We're still exploring how to best structure the way we use ArgoCD but for now we settled on a central Git repository containing the following structure:

.
├── apps # per cluster a directory
│   └── infra # contains all Applications
# for the infra cluster
│   └── rendering
├── infrastructure
│   ├── argo # argo helm chart
│   ├── cluster-autoscaler
└── monitoring
   ├── grafana
└── prometheus

For example the Application to deploy argo (not to be confused with ArgoCD ;)) looks like this:

apiVersion: "argoproj.io/v1alpha1"
kind: Application
metadata:
name: argo
namespace: argo-cd
spec:
destination:
namespace: argo
name: infra
project: infra
source:
helm:
valueFiles:
- values-core-dev.yaml
path: infrastructure/argo
repoURL: git@gitrepository:group/argocd.git
targetRevision: HEAD
syncPolicy:
automated: {}
syncOptions:
- CreateNamespace=true

To deploy new applications we add the helm chart to the Git repository (using helm pull) and create an according Application configuration similar to the one above. ArgoCD checks the Git repository for changes and deploys the changes automatically.

We're using the App of Apps pattern so that all applications within e.g. the infra folder are picked up automatically.

argoCD Interface

Future development

ArgoCD itself we deployed using helmfile which is our previous way of deploying resources. We plan to move everything to ArgoCD, including ArgoCD itself. This is a work in progress though.

Our "App of Apps" and AppProjects are not yet recorded in the Git repository itself as well.

As you can see, we just started using ArgoCD. We have work to do until we're sure our setup is right. In small iterations we'll achieve the goal of having a reproducible and discoverable cluster setup.