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 →Mastering Blue Green Deployments: Strategies for Zero-Downtime Releases
Blue Green Deployment is a game-changer for achieving zero-downtime releases. By managing traffic between old and new versions, you can ensure seamless transitions. Learn how to configure auto-promotion and scale down delays effectively.
How GitHub Responded to Internal Repository Breaches
Unauthorized access to internal repositories can cripple an organization. GitHub's response to a compromised employee device involved a malicious VS Code extension, showcasing the need for rapid incident response. Discover how they contained the threat and what it means for your security practices.
Securing Docker Engine: Best Practices for Container Safety
Docker Engine security is crucial for protecting your applications in production. With features like Kernel namespaces and Control Groups, you can isolate processes and manage resources effectively. Dive into the specifics of securing your Docker environment.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.