Skip to content

Support DNS lookups for individual tasks. E.g. task-1.service #27080

@colinmollenhour

Description

@colinmollenhour

Current Docker Swarm Mode (1.12.2-rc1) supports DNS lookups for service which resolves the VIP and tasks.service which resolves all direct containers IPs in the service. I'm using a MariaDb Galera cluster but due to application design and Galera transaction isolation it is not safe to load balance writes to multiple masters in my application. This rules out using the VIP. I'd like to use something like HAProxy to direct write connections to a particular node (transaction isolation within a single node is correct). Since Galera is multi-master it doesn't matter which node as long as all clients choose the same one. However, I'd like to avoid having to update the configuration of the proxy whenever there is a status update of some sort. My idea is to configure the proxy like so:

listen galera-cluster-write
    bind 0.0.0.0:3306
    mode tcp
    option mysql-check user haproxy_check
    balance first
    server galera-1 task-1.galera:3306 check resolvers docker resolve-prefer ipv4
    server galera-2 task-2.galera:3306 check resolvers docker resolve-prefer ipv4
    server galera-3 task-3.galera:3306 check resolvers docker resolve-prefer ipv4
    server galera-4 task-4.galera:3306 check resolvers docker resolve-prefer ipv4

This way the HAProxy config does not need to be updated whenever node statuses change, it will always just direct to the first healthy node. However, the task-X.<service> DNS query is not implemented by Docker so currently this config is not possible without using a script to generate and re-generate the config using actual IPs which I'd like to avoid for simplicity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions