Resolving "ReplicationController already exists in DB" Error When Deploying Services
If you encounter a Terraform error stating that a ReplicationController already exists in the Duplo database when trying to deploy a service, this typically indicates a drift between your Terraform state and the actual resources in your cluster. Understanding the Error This error occurs when: A Kubernetes deployment was created manually or through native Kubernetes Terraform providers outside of DuploCloud The service exists in DuploCloud's control plane database but not properly managed by Terraform There's a mismatch between what Terraform expects and what actually exists in the cluster Resolution Steps Step 1: Check for Existing Kubernetes Resources First, verify if the deployment exists in your Kubernetes cluster: kubectl get deployment [service-name] kubectl get pod -l app=[service-name] Step 2: Delete Manually Created Resources If the resources were created outside of DuploCloud (manually or through native Kubernetes Terraform), you'll need to remove them: For manually created resources: kubectl delete deployment [service-name] For Terraform-managed resources (using native Kubernetes provider): terraform destroy -target=[resource-name] Step 3: Re-run Your Terraform Deployment After removing the conflicting resources, run your Terraform deployment again. DuploCloud should now be able to create the service properly through the duplocloud_duplo_service resource. Prevention To avoid this issue in the future: Always use DuploCloud's Terraform provider ( duplocloud_duplo_service ) for managing services Avoid creating Kubernetes resources manually or through native Kubernetes Terraform providers when using DuploCloud If you need to migrate existing resources, plan the migration carefully to avoid conflicts Note that resources created outside of DuploCloud will show "Editing is not allowed because this service was created outside of DuploCloud" in the portal, indicating they need to be managed through their original creation method.
Last updated
Was this helpful?

