Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Migrate GitOps to Fleet-Based Promotion

· 4 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Moving from per-cluster GitOps pipelines to fleet-based promotion lets you manage many Kubernetes clusters from one place, using a single source of truth and a clear promotion path. Instead of repeating the same deployment logic for each cluster, you define your fleet once and promote changes through environments like dev, staging, and production. This guide walks you through the migration step by step, covering what you need, common pitfalls, and how to fix things when they go wrong.

What You'll Need

  • Access to the Git repositories that currently hold your per-cluster manifests.
  • Fleet manager installed and configured (e.g., Rancher Fleet, Argo CD with ApplicationSets, or Flux with Kustomize).
  • A Kubernetes cluster to act as the fleet hub (if using a hub-based model).
  • kubectl and the appropriate CLI tools for your chosen fleet manager.
  • Familiarity with your current GitOps workflow and the structure of your cluster repositories.

Step-by-Step

  1. Audit your current per-cluster setup. List all clusters, the Git repositories they use, and the differences between them (e.g., cluster-specific configs, secrets, or environment variables). Identify what is truly cluster-specific versus what is shared.
  2. Choose a fleet-based model. Decide between a centralized hub (Fleet) or a decentralized approach (Argo CD ApplicationSets with Git generators). For most teams, a hub-based model simplifies management.
  3. Create a fleet repository structure. Organize your manifests into a single repo with folders per environment (e.g., dev/, staging/, prod/) and use overlays or kustomizations for cluster-specific tweaks.
  4. Define fleet targets. In Fleet, create ClusterGroup objects that group clusters by environment. For Argo CD, define ApplicationSets with generators that match cluster labels.
  5. Move shared manifests. Copy common manifests (deployments, services, configmaps) into the fleet repo, removing any cluster-specific hardcoding.
  6. Handle cluster-specific config. Use Kustomize overlays or Helm values files to inject per-cluster differences. Keep these in a separate folder (e.g., overlays/) and reference them in your fleet configuration.
  7. Set up promotion paths. Define promotion rules that move changes from dev to staging to prod. In Fleet, use Promotion resources or CI triggers. For Argo CD, use sync waves and manual approvals.
  8. Migrate one cluster at a time. Start with a low-risk cluster. Point its GitOps agent to the new fleet repo and verify that the desired state matches the current state.
  9. Update CI/CD pipelines. Change your CI to push to the fleet repo instead of per-cluster repos. Ensure that promotion is triggered by commits to the appropriate environment branch.
  10. Decommission per-cluster repos. Once all clusters are on the fleet, archive the old repos and remove any references in your GitOps agents.

Common Mistakes

  • Not accounting for cluster-specific secrets. Secrets often differ per cluster. Use external secret management (e.g., Sealed Secrets, Vault) and reference them in your fleet config, not in the repo.
  • Overcomplicating overlays. Trying to support every possible cluster variation with complex kustomize patches leads to maintenance hell. Keep overlays minimal and use them only for true differences.
  • Migrating all clusters at once. Doing a big-bang migration risks breaking everything. Incremental migration is safer and easier to troubleshoot.
  • Ignoring drift detection. Fleet-based tools often have drift detection. If you don't reconcile after migration, you might have silent drift.
  • Forgetting to update RBAC. Fleet agents need permissions to deploy to all target clusters. Ensure your service accounts have the right roles.

Tips

  • Use a monorepo for your fleet to simplify promotion and review.
  • Leverage Kustomize's commonLabels to keep resources consistent.
  • Use Git branches for environments (e.g., main for dev, staging branch, prod branch) to make promotion a simple merge.
  • Automate promotion with CI, but require manual approval for production.
  • Document your promotion process so that new team members understand the flow.

Troubleshooting

Clusters not showing up in fleet. Check that the fleet agent is installed and the cluster is registered. Verify network connectivity and that the agent's service account has the correct permissions.

Manifests not deploying. Look at the fleet manager's logs. Common causes: invalid YAML, missing dependencies, or incorrect target labels.

Promotion not triggering. Ensure your CI pipeline is configured to push to the correct branch and that promotion rules match your environment names.

Drift after migration. Run a manual reconcile and compare the live state with the desired state. Use kubectl diff to spot differences.

Cluster-specific config not applied. Double-check your overlay paths and that the fleet manager is referencing them correctly.

Frequently Asked Questions

Q: Can I keep using my existing Git repos for individual clusters?
A: Yes, but you'd lose the benefits of fleet-based promotion. It's better to consolidate into a single fleet repo.

Q: How do I handle clusters with very different configurations?
A: Use Kustomize overlays or Helm values files to isolate differences. Keep the base manifests shared.

Q: Does fleet-based promotion work with any GitOps tool?
A: Most modern tools support it. Fleet, Argo CD, and Flux all have mechanisms for multi-cluster management.

Q: What happens to my old per-cluster pipelines?
A: You'll decommission them once the migration is complete. Archive the repos and update any CI triggers.

Q: Is it safe to migrate in stages?
A: Yes, it's recommended. Start with a test cluster, validate, then move to production clusters.

Q: How do I roll back if something goes wrong?
A: Since Git is the source of truth, you can revert a commit or use the fleet manager's rollback feature to restore a previous state.