Skip to content

allyn-bottorff/OpenGTM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

104 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenGTM

Global Traffic Managment (GTM) service which can provide health check aware responses to DNS queries.

The Go version of this project is now located here: https://github.com/allyn-bottorff/OpenGTM-Go

Intended Use

This project is a proof-of-concept. It works, but has some limitations and sharp edges, especially in the gtm CoreDNS plugin.

Features
  • HTTP(S) health checks

    • Configurable HTTPS validity

    • Health status by HTTP return code or string matching

  • Fallback IP

  • TCP health checks

    • Connection success/failure

  • CoreDNS plugin

    • DNS responses based on the health_checker

Structure

  • Rust health checking service

    • Axum API framework

    • Tokio-based asynchronous health checking tasks

  • CoreDNS plugin

    • Makes API calls to the health checking service to determine the correct answer to a DNS query

Running

health_checker

The project expects a config file conf.json in the same directory of the binary. In the future, this path will be configurable.

cargo run

Health Checker currently uses env_logger for setting the log level. E.g.

RUST_LOG=info cargo run

CoreDNS

The second component of this service is a plugin for CoreDNS which takes DNS requests and translates them into HTTP API calls to the health checker service.

To add this plugin, you will need to build CoreDNS itself with a modified config file.

  1. Add gtm:gtm to the top plugin list in plugin.cfg

  2. Add a new directory for the GTM plugin: mkdir -p plugin/gtm

  3. Inside plugin/gtm symlink gtm.go from this repository into that directory.

  4. Build the coredns project (from the root of the repository):

    1. go generate

    2. go build

  5. Add a Corefile to the root of the repository with a configuration which adds the new gtm plugin (e.g.):

    Corefile: ./Corefile
    . {
      gtm
    }
  6. Run coredns: ./coredns

Important
As it is currently configured, the plugin assumes that the health checker is running at http://127.0.0.1:8080. In the future, that will be configurable via options in the Corefile. For now, however, if you need to change the running location the health_checker service, you’ll need to edit it directly in the plugin.

Health Checker Configuration

This sample config can be used to run the project.

Configuration: ./conf.json
{
  "pools": [
    {
      "name": "lbtests1",
      "port": 8080,
      "members": [
        "127.0.0.2",
        "127.0.0.3"
      ],
      "fallback_ip": "127.0.0.0",
      "interval": 30,
      "poll_type": "TCP"
    },
    {
      "send": "/health",
      "name": "lbtests2",
      "port": 8080,
      "members": [
        "127.0.0.4",
        "127.0.0.5"
      ],
      "fallback_ip": "127.0.0.0",
      "interval": 30,
      "poll_type": "HTTP",
      "http_options": {
        "send": "/health",
        "https_enabled": false,
        "https_require_validity": false,
        "receive_up": {
          "status_codes": [
            200,
            503
          ]
        }
      }
    },
    {
      "send": "/health",
      "name": "lbtests3",
      "port": 8080,
      "members": [
        "127.0.0.6",
        "127.0.0.7"
      ],
      "fallback_ip": "127.0.0.0",
      "interval": 30,
      "poll_type": "HTTP",
      "http_options": {
        "send": "/health",
        "https_enabled": false,
        "receive_up": {
          "string": "Healthy"
        }
      }
    }
  ]
}

About

Health Check aware DNS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published