> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/troubleshooting-and-resources/knowledge-base-article/migrating-helm-deployment-from-cd-to-gitops.md).

# Migrate a Helm deployment from a CD pipeline to GitOps pipelines

Migrate a Helm Deployment from Harness CD Pipeline to Harness GitOps Pipelines.

Migrating Helm deployments from Harness CD Pipelines to Harness GitOps Pipelines does not need to be daunting. Whether you are a DevOps engineer or an administrator, this guide walks you through the transition. It ensures that deployments run smoothly in GitOps Pipelines while preserving the integrity of existing configurations.

## Before you begin

* You have an existing Helm deployment running in a Harness CD pipeline.
* You have access to a Harness GitOps Argo CD setup, or you plan to set one up.
* You have `kubectl` and `argocd` CLI access to the target cluster.

## Why migrate from Harness CD to Harness GitOps? <a href="#why-migrate-from-harness-cd-to-harness-gitops" id="why-migrate-from-harness-cd-to-harness-gitops"></a>

Organizations are increasingly moving to GitOps Argo CD pipeline to centralize their GitOps workflows. But why choose Harness GitOps Argo CD over Harness CD?

Here are a few compelling reasons:

**Centralized GitOps Workflows:** GitOps allows you to manage all your GitOps processes in one tool.

**Advanced Features:** GitOps offers multi-cluster management and automated rollbacks, giving you greater control over your deployments.

**Seamless Kubernetes Integration:** Since GitOps is Kubernetes-native, it fits perfectly into your existing infrastructure and integrates with Kubernetes tools.

## Steps to follow <a href="#steps-to-follow" id="steps-to-follow"></a>

**1. Retrieve Existing Helm Values from Harness CD**

Before migrating, retrieve the Helm values from your existing deployment. These configurations will form the backbone of your new GitOps deployment.

`helm get values release_name values.yaml`

By saving these values in a file, you ensure that the transition is seamless and consistent.

**2. Export Pipeline Configuration from Harness CD**

Export the pipeline configurations for reference during the migration. These are useful for comparison later to ensure everything remains aligned.

`harness pipeline export --name pipeline_name --output pipeline.yaml`

This pipeline export acts as a blueprint for reviewing the deployment transition and troubleshooting potential discrepancies.

**3. Prepare the GitOps Application Manifest**

Create the GitOps Application manifest using the values.yaml file retrieved from the Harness CD pipeline to define how GitOps manages the deployment.

The following is an example manifest:

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-helm-app
  namespace: argocd
spec:
  project: default
  source:
    repoURL: 'https://github.com/my-org/my-repo.git'
    targetRevision: HEAD
    path: 'helm/my-helm-app'
    helm:
      valueFiles:
        - values.yaml
  destination:
    server: 'https://kubernetes.default.svc'
    namespace: my-namespace
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
```

This YAML defines everything from the repository and path to the Helm values that Argo CD uses to manage the deployment. Double-check paths and namespaces to avoid potential misconfigurations.

**4. Apply the Manifest in GitOps**

Apply the manifest to GitOps. This command pushes the configuration into Argo CD, and the deployment is managed from here on.

`kubectl apply -f my-helm-app.yaml`

**5. Verify the Deployment in GitOps**

Now, verify that the deployment is working as expected. You can check the status of your application with a simple command:

`argocd app get my-helm-app`

Argo CD provides detailed insights into the state of your deployment, allowing you to catch any issues early.

**6. Compare Pipeline History and Cluster Values**

Confirm that everything in Harness Argo CD aligns with the history and values of the Harness CD pipeline. Use the following command to compare and identify any discrepancies:

`argocd app history my-helm-app`

This step ensures that deployments are consistent and error-free after migration.

## Future management tips <a href="#future-management-tips" id="future-management-tips"></a>

Now that the application is running on a Harness GitOps pipeline, here are a few tips to ensure future success:

**Automated Syncs**: Enable automated syncs to maintain a consistent application state with Git.

**RBAC and Permissions**: Review role-based access control (RBAC) policies to ensure secure management of the migrated app.

**Monitoring & Alerts**: Set up monitoring and alerts to stay on top of application health and status.

## Troubleshooting common issues <a href="#troubleshooting-common-issues" id="troubleshooting-common-issues"></a>

**Failed Syncs**: If syncs are failing, check GitOps logs for errors. Common issues include incorrect paths in values.yaml or missing permissions.

**Mismatched Values**: If the deployed application does not look as expected, compare the values.yaml files between the Harness CD pipeline and the Harness GitOps pipeline. A key configuration may have been missed during migration.

## Next steps <a href="#next-steps" id="next-steps"></a>

Migrating from the Harness CD pipeline to the Harness GitOps pipeline with Argo CD might seem like a big leap, but each step above is designed to make the transition smooth and manageable. After migration:

* Review the Future management tips above to keep the GitOps-managed application healthy.
* Monitor the first few sync cycles closely to confirm behavior matches the original CD pipeline.

{% @harness-feedback/feedback %}
