Hello,

I had to destroy a Kubernetes cluster and recreate it, because it was in a completely broken state.

The cluster was associated with a DigitalOcean load balancer. I would rather not create a new load balancer with a different IP address, because I already have DNS records pointing to the existing load balancer. Is it possible to modify the existing load balancer to point to the new
Kubernetes cluster? I could not find a way to do this in documentation.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

Hi, what’s the structure (i.e. architecture) of your Kubernetes resources? Are you using a LoadBalancer in regards to your service resource definition? If this is the case, then you should never hard code an IP address here. Next, If you have created a DNS record that has an associated IP address, then I would create a Kubernetes Ingress resource using either Nginx or Traefik that sets the domain and not the IP.

e.g.

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: "foo"
  namespace: production
spec:
  rules:
    - host: some.example.com
      http:
        paths:
          - path: /
            backend:
              serviceName: some_service_1
              servicePort: 80

Note: The above is using Traefik apiVersion.

Well, I wish that the above information helps you and happy hacking.

Think different and code well,

-Conrad

  • Hi Conrad,

    Thank you for the answer. Sorry that there was insufficient information in the question, but the answer is not relevant. There is no hard-coding of IP addresses within the cluster. The issue is not within the cluster, but in the DNS records.
    The structure is:

    • An ingress-nginx controller, which then automatically creates a DigitalOcean load balancer, which is then automatically assigned a static IP address visible from outside (*).
    • Regular Ingress resources like the one you provided, no hard-coding of IP adresses.

    The issue is (*), the automatic creation of a load balancer and assignment of a static IP address visible from the outside. I would have preferred to use the old load balancer from the cluster I deleted, but the issue is that it seems we can’t assign a Kubernetes cluster to an existing load balancer.

    I tried updating the ingress-nginx configuration with the old load balancer ID, but this failed and just created another DO load balancer.

    • Hi, you should be able to add existing droplets to the existing DO load balancer by going to the DO load balancer’s detail page. Make sure that your droplets and load balancer exist within the same region. If you have Kubernetes service resources with type LoadBalancer, DO load balancers will be created when you apply these resources to your Kubernetes cluster. This is expected behavior and other providers would do something similar.

Hi there,

Looking at a LB service you should see they are provisioned with the loadbalancer id annotation.

To reuse a current already provisioned LB. You can use that annotation on the service that you want to take over the LB:

kubernetes.digitalocean.com/load-balancer-id: xxxxxx-blah-UUID-here-xxx

Please note that you should not have a LB being managed by two clusters as they will overwrite each others configurations.

Hope this helps!

Submit an Answer