Mastering Cluster Bootstrapping with Argo CD
Cluster bootstrapping is essential for managing applications across multiple Kubernetes clusters efficiently. It solves the problem of manual deployment and configuration, allowing you to automate the process and ensure consistency. With Argo CD, you can use ApplicationSets to deploy applications based on cluster labels, making it easier to manage complex environments.
To bootstrap a cluster, follow the Declaratively setup guide. You can create a cluster, assign it labels, and add it to Argo CD. Any ApplicationSet that uses these labels will deploy the respective applications. The sync policy is set to automated with pruning enabled by default, which means that child apps are automatically created, synced, and deleted when the parent app's manifest changes. This is particularly useful when using the App of Apps pattern, which allows you to declaratively specify one Argo CD app that consists only of other apps. You also have access to all gotemplate functions and Sprig methods, eliminating the need for Helm templating.
In production, be aware that the App of Apps pattern is an admin-only tool, which may limit its use in certain scenarios. Additionally, consider modifying the bootstrapping behavior to deploy applications in waves, especially if you have a large number of apps. Starting from version 3.2, Argo CD ensures consistent deletion behavior, whether you delete from the Applications List or the parent application's Resource Tree. This can help prevent orphaned resources and streamline management.
Key takeaways
- →Utilize ApplicationSets to handle typical deployment scenarios in your cluster.
- →Set the sync policy to automated with pruning enabled for efficient app management.
- →Leverage the App of Apps pattern to manage multiple applications declaratively.
Why it matters
In production, automating cluster bootstrapping can significantly reduce deployment time and minimize human error. This leads to more reliable application delivery and better resource management across your Kubernetes environments.
Code examples
1apiVersion:argoproj.io/v1alpha1
2kind:ApplicationSet
3metadata:
4 name: eu-only-appset
5 namespace: argocd
6spec:
7 goTemplate: true
8 goTemplateOptions: ["missingkey=error"]
9 generators:
10 - matrix:
11 generators:
12 - git:
13 repoURL: <a git repo>
14 revision: HEAD
15 directories:
16 - path: my-eu-apps/*
17 - clusters:
18 selector:
19 matchLabels:
20 type: "workload"
21 region: "eu"
22 template:
23 metadata:
24 name: 'eu-only-{{index.path.segments1}}-{{.name}}'
25 spec:
26 project: default
27 source:
28 repoURL: <a git repo>
29 targetRevision: HEAD
30 path: '{{.path.path}}'
31 destination:
32 server: '{{.server}}'
33 namespace: 'eu-only-{{index.path.segments1}}'
34 syncPolicy:
35 syncOptions:
36 - CreateNamespace=true
37 automated:
38 prune: true
39 selfHeal: true1apiVersion:argoproj.io/v1alpha1
2kind:Application
3metadata:
4 name: guestbook
5 namespace: argocd
6finalizers:
7 - resources-finalizer.argocd.argoproj.io
8spec:
9 destination:
10 namespace: argocd
11 server: {{.Values.spec.destination.server}}
12 project: default
13 source:
14 path: guestbook
15 repoURL: https://github.com/argoproj/argocd-example-apps
16 targetRevision: HEAD
17 syncPolicy:
18 automated:
19 prune: true1argocd app create apps \
2 --dest-namespace argocd \
3 --dest-server https://kubernetes.default.svc \
4 --repo https://github.com/argoproj/argocd-example-apps.git \
5 --path apps \
6 argocd app sync appsWhen NOT to use this
The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.
Want the complete reference?
Read official docsDeploy any app in seconds — no infrastructure config, no DevOps overhead. Instant deployments from GitHub, built-in databases, and automatic scaling.
Start deploying free →Securing Open Source in the AI Era: Lessons from 50 Projects
In the rapidly evolving landscape of AI, security in open source projects is more critical than ever. The GitHub Secure Open Source Fund directly ties funding to measurable security outcomes, ensuring that maintainers can effectively tackle security challenges. Discover how this program can enhance your project's security posture.
Mastering GitHub Actions: Triggering Workflows Like a Pro
GitHub Actions workflows are powerful, but knowing how to trigger them effectively is crucial. You can specify which activity types will kick off a workflow run, giving you control over your CI/CD processes. Dive in to learn the ins and outs of workflow triggers.
Extending Malware Advisories Beyond npm: A Game Changer
Malware advisories are crucial for maintaining secure ecosystems. With the new OpenSSF importer, we can now validate and normalize malicious package data across multiple platforms. This article dives into how this process works and what you need to know for production.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.