Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zekker6/hosts-generator
Tool which is able to generate hosts file content for services discovered from different sources
https://github.com/zekker6/hosts-generator
caddy dns docker kubernetes networking routing traefik
Last synced: about 18 hours ago
JSON representation
Tool which is able to generate hosts file content for services discovered from different sources
- Host: GitHub
- URL: https://github.com/zekker6/hosts-generator
- Owner: zekker6
- Created: 2020-09-11T19:17:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-12-11T16:34:16.000Z (14 days ago)
- Last Synced: 2024-12-11T17:35:11.333Z (14 days ago)
- Topics: caddy, dns, docker, kubernetes, networking, routing, traefik
- Language: Go
- Homepage:
- Size: 249 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Hosts generator
A small tool which is able to generate hosts file content for services discovered from different sources:
* [Traefik](https://traefik.io)
* Kubernetes
* [Caddy](https://caddyserver.com/)Available as docker image:
- v0.6.0+ published [here](https://github.com/zekker6/hosts-generator/pkgs/container/hosts-generator)
- previous versions published [here](https://github.com/users/zekker6/packages/container/package/traefik-hosts-generator)# Usage
Initially it was developed to enhance local development toolchain which helps to work on several projects at the same time. Workflow suggested having multiple docker-compose apps running and having Traefik as reverse-proxy with dynamic discovery over docker socket.
Example config:
```yamlversion: "3"
services:
traefik:
image: traefik:v3.0.1
restart: unless-stopped
labels:
traefik.port: 8080
volumes:
- "./traefik.toml:/etc/traefik/traefik.toml"
- "/var/run/docker.sock:/var/run/docker.sock"
ports:
- "80:80"
networks:
- tk_webtk-hosts:
image: ghcr.io/zekker6/hosts-generator:v1.0.1
restart: unless-stopped
volumes:
- /etc/hosts:/hosts
command: "-platform=linux -traefikUrl=http://traefik:8080/api -file=/hosts -watch=true -freq=10"
networks:
- tk_web
depends_on:
- traefiknetworks:
tk_web:
external: true
```This config will use external network `tk_web` to establish communication with application container.
It is needed to add this network to all containers which will be connected via Traefik.You can create this network with the following command:
```sh
docker network create tk_web
```Fully working example can be found at [examples folder](example/).
## Command line flags
CLI flags will allow to override default behaviour such as line endings for different host operating systems(useful when using docker image), changing generated block postfix(to allow using several concurrent instances of traefik generator).
```
-caddyURL string
specify custom caddy API url, example: 'http://127.0.0.1:2019/config/'
-file string
specify custom hosts file location, example: '/etc/hosts_custom' (default "/etc/hosts")
-freq int
poll every N seconds (default 5)
-ip string
specify custom ip to use in hosts file, example: '192.168.33.10' (default "127.0.0.1")
-kubeconfig string
specify full path to kubeconfig (default "/home/zekker/.kube/config")
-platform string
change line-endings style for hosts file, default: '', available: darwin, windows, linux
-postfix string
use unique postfix if 2 parallel instances are running
-quiet
disable logging
-skipWildcard
remove wildcard entries in hosts file. Not all DNS servers support wildcard entries, so this option can be used to filter out unsupported entries.
-traefikUrl string
specify custom traefik API url, example: 'http://127.0.0.1:8080/api' (default "http://localhost:8080/api")
-watch
enable API polling mode: true/false
```