How do I set DNS records for Kubernetes with a load balancer?

January 3, 2019 14.2k views
Kubernetes Load Balancing DNS DigitalOcean

I am using Helm to create a Kubernetes deployment. In front of this, there is a load balancer and an ingress server - see below for an abridged version of helm status auth

==> v1/Service
NAME               TYPE          CLUSTER-IP      EXTERNAL-IP   PORT(S)       AGE
auth-mongodb       ClusterIP     10.245.186.209  <none>        27017/TCP     74s
auth-redis-master  ClusterIP     10.245.34.39    <none>        6379/TCP      74s
auth-redis-slave   ClusterIP     10.245.213.27   <none>        6379/TCP      74s
auth               LoadBalancer  10.245.82.177   46.101.65.69  80:32645/TCP  74s

==> v1beta1/Ingress
NAME  HOSTS                                  ADDRESS  PORTS  AGE
auth  auth.feature-deploy.example.com  80       74s

I’m happy enough with all this and it works great on DO. The only thing I can’t work out is how to update the DNS A record.

The domain name is managed on the DO control panel. If I manually set auth.feature-deploy.example.com and point to the load balancer, it all works fine. However, if I destroy/update the deployment, I’ll need to do this again manually.

Is there a way of getting Kubernetes to set a DNS A record that I’m missing, have I found an issue with the DO K8S stack or am I missing something?

Thanks

Ingress definition

# Source: auth/templates/ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: auth
  labels:
    app.kubernetes.io/name: auth
    helm.sh/chart: auth-0.1.0
    app.kubernetes.io/instance: auth
    app.kubernetes.io/managed-by: Tiller
spec:
  rules:
    - host: "auth.feature-deploy.example.com"
      http:
        paths:
          - path: /
            backend:
              serviceName: auth
              servicePort: http
2 Answers

I’ve sort of moved away from this now. Rather than managing my own ingress, I’ve wired it up with GitLab and let them manage my ingress.

If I’d wanted to do this as my own ingress, I would need nginx-ingress controller on it’s own namespace that would then proxy to the individual service

just curious why you have a ingress here? i think you can do it with just Service of type LoadBalancer. if you were using a Service of type ClusterIP or NodePort then I think you would use ingress?

in any case the host in your INgress rules is not for actually going out and creating an A record, rather that is where you would put the value for the A record (created elsewhere somehow) such that the Ingress Controller could match on an incoming request by means of the HTTP Host: heador or TLS server name indication

but as to your original question I am not sure what if anything the DO kubernetes LoadBalancer does with DNS or if you are just given an externalIP and then you have to do the manual steps for the DNS zone wherever that may be hosted including DO.

Have another answer? Share your knowledge.