Skip to main content

Controller for exposing pod nodeIPs via DNS on DigitalOcean.

Project description

do-pod-dns-controller

What is it?

This is a simple controller written in Python that will configure a DNS A record on DigitalOcean with the external IP of each node that annotated pods are running on. The purpose is to allow exposing services via hostPort for situations such as UDP services where a LoadBalancer service won't work, and where a service with externalIPs isn't desirable due to performance or because it loses the client's IP.

This will probably be most useful with ingress controller pods, but it can be used with any pod that exposes services via hostPorts.

How does it work?

The controller lists your nodes and pods every 10 seconds. It looks for pods with the annotation do-pod-dns-controller.literati.org/hostname. It collects the external IPs of each node that a pod with a given hostname annotation is running on, then makes it so that the given hostname has A records for exactly those external IPs, deleting any extraneous A records. It will not touch any other records.

How do I use it?

The latest build (using a Debian-based image) is on Dockerhub.

Use a manifest similar to the one under examples. Generate a DigitalOcean token and set that in a secret that ends up as DIGITALOCEAN_TOKEN in the controller's environment. Make sure you've already set up each domain name you want to use in DigitalOcean's domain settings, then add --domain=<domain> to the controller's args, for each domain. Annotate each pod (via spec.template.metadata.annotations in Deployments, DaemonSets, etc) with the key do-pod-dns-controller.literati.org/hostname and the FQDN you want to set the DNS for, for example:

apiVersion: apps/v1
kind: Deployment
...
spec:
  template:
    metadata:
	  annotations:
	    do-pod-dns-controller.literati.org/hostname: www.example.com
...

Then watch the logs for the controller pod. You should see logs indicating that it's configured DNS, or an error telling you what went wrong. You can add --log-level=debug to the args to get more logging.

Code of conduct

Any interactions with the community relating to this software are governed by the code of conduct.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

do_pod_dns_controller-0.1.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file do_pod_dns_controller-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: do_pod_dns_controller-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for do_pod_dns_controller-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 583dfec6a6b4d6600818d8db6d7dac79b68ec16bd349f11c18d665ef8e1324ce
MD5 a453c785cd3d512cc5f34cc4c329ebb3
BLAKE2b-256 77ec59d34c2461e116bb353494612445d04cd93778a298e215db0dbb4abb70d2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page