DigitalOcean Kubernetes (DOKS) is a managed Kubernetes service that lets you deploy Kubernetes clusters without the complexities of handling the control plane and containerized infrastructure. Clusters are compatible with standard Kubernetes toolchains, integrate natively with DigitalOcean Load Balancers and volumes, and can be managed programmatically using the API and command line. For critical workloads, add the high-availability control plane to increase uptime with 99.95% SLA.
When you migrate an application from a Kubernetes cluster to another, you can also migrate the associated load balancer service to the target cluster. Doing so preserves the external IP address of the load balancer that your application’s DNS record points to.
To migrate a load balancer, you first disown the load balancer service from the existing service and then reference the load balancer’s ID in the service of the new cluster. Disowning the load balancer from the existing service turns all mutating actions, such as load balancer creates, updates and deletes, that are driven through the service into no-ops.
Use the following workflow to migrate a load balancer from one cluster to another. Suppose you have a load balancer service named
app that is associated with a
production-v1 cluster and you want to move it to another cluster
Ensure that there are no load balancer-related error events in your existing service by running the following command:
kubectl describe service <service-name>
Fix any reported errors to bring the service into a stable state.
Disown the load balancer by adding the following annotation in the service config file and setting it to
kind: Service apiVersion: v1 metadata: name: app annotations: kubernetes.digitalocean.com/load-balancer-id: c16b0b29-217b-48eb-907e-93cf2e01fb56 service.kubernetes.io/do-loadbalancer-disown: "true" spec: selector: name: app ports: - name: http protocol: TCP port: 80 type: LoadBalancer
load-balancer-idis set by the DigitalOcean cloud control manager when you first provision the load balancer.
kubectl apply to apply the update to the config file. Verify that the change applied correctly by running
kubectl describe service <service-name> again.
Once the change applies, all mutating requests directed at the load balancer and driven through the service are ignored.
Create a new service config file in the
production-v2 cluster to use the
load-balancer-id from the previous service config file.
kind: Service apiVersion: v1 metadata: name: app annotations: kubernetes.digitalocean.com/load-balancer-id: c16b0b29-217b-48eb-907e-93cf2e01fb56 spec: selector: name: app ports: - name: http protocol: TCP port: 80 type: LoadBalancer
If you have other load balancer configuration annotations that you want to transfer to the new service, add them to the config file.
Check the service events again to ensure that the DigitalOcean cloud control manager has finished reconciling the update.
Once complete, the load balancer is owned by the new service and the traffic is routed to the new cluster.
Delete the service from the old cluster or change it to another Kubernetes service type.