Migrating Kubernetes Resources between ArgoCD Applications

Published on December 24, 2020, 00:00 UTC 1 minutes 6737 views

I’ve been using ArgoCD for a while now, and as time went by I started to splitting my Kubernetes resources into smaller ArgoCD Applications. However, I could not figure out clear guidelines on how to do it without downtime. Recently I figured it out and wanted to share the solution.

First, disable auto-syncing so that neither of your ArgoCD Application sync. Then, remove the relevant code on Git from the ArgoCD Application that you want to migrate it from and push it to Git. Now ArgoCD will mark the resource for deletion but won’t sync since auto syncing is disabled. Now, we can manually remove the ArgoCD label argocd.argoproj.io/instance and then it should be removed from ArgoCD’s state and in the ArgoCD UI you should see the Kubernetes resources disappear. Now we move the relevant code on Git from the old ArgoCD Application to the new. Enable auto-syncing and the ArgoCD will add the ArgoCD label argocd.argoproj.io/instance with the value of the new Application. It won’t change any of the Kubernetes resources unless you’ve explicitly done so when migrating the resources. Neither Applications will be out-of-sync and you can re-enable auto-syncing now.

Related Posts

GitOps with ArgoCD and Tanka

GitOps is becoming the standard of doing continuous delivery. Define your state in Git, automatically update and change the state when pull requests are merged. Within the Kubernetes ecosystem two tools have become very popular for doing this FluxCD and ArgoCD. Different in their own way, but both have the same goal - managing your continuous delivery life cycle.

GitOps Secret Management with Vault, ArgoCD and Tanka

Recently I wrote a blog post on how to use Grafana’s Tanka with ArgoCD which is my prefered way to write Kubernetes configuration in Jsonnet. However, the post does not go into detail on the last missing piece - how to manage secret credentials when using Tanka with ArgoCD.

ArgoCD Monitoring with Prometheus and Grafana

ArgoCD has by default support for notifying when an Application does not have the desired status through triggers. For example, when an application becomes OutOfSync or Unhealthy, a notification is sent to your configured notification service (e.g. Slack). This was my initial setup, but I found it to be flaky, where networking issues between the server and controller for a couple of seconds would send many Slack messages that the Application status is unknown. An application becoming unhealthy would instantly send alerts to Slack. To resolve this I wanted interval based alerts and as usual Prometheus was the solution to this. ArgoCD provides Prometheus metrics out of the box, and alongside the metrics there’s a Grafana dashboard for ArgoCD. The dashboard is good, but the project is lacking any open source alerting. Even more so, it does not have a monitoring mixin for providing dashboards and alerts to be consumed easily.

Shynet