aschzero / hera

Automated secure tunnels for containers using Cloudflare Argo
MIT License
127 stars 18 forks source link

Ability to customize / namespace the labels hera looks for #11

Open pirate opened 4 years ago

pirate commented 4 years ago

Right now hera looks for hera.hostname and hera.port to configure the tunnels. I was wondering if it's possible to customize the lefthand side to be something other than hera so that we can namespace them a bit more, e.g. argo_zone1.hostname and argo_zone1.port.

The other question is whether it's possible to add a hera.upstream label so that we can use argo's SSH tunnelling feature and https endpoints e.g. hera.upstream: "https://localhost:32400" or hera.upstream: "ssh://localhost".

Another issue that could be fixed with additional namespacing options is the ability to have multiple exposed services from one container, e.g. hera.<servicename>.hostname/port.

Full example docker-compose.yml:

version: '3'

services:
    hera:
        image: aschzero/hera:latest
        container_name: hera_zone1
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
            - ./data/hera:/certs
        environment:
            - HERA_LABEL_PREFIX=zone1_argo   # specify the left-hand side of the label (defaults to "hera", the current behavior)
            - HERA_LABEL_SUBLABELS=true      # allow hera.<anything here>.port in order to support multiple tunnels per container
        networks:
            - zone1

    nginx:
        image: nginx:alpine
        volumes:
            - ./html/:/var/www/html
            - ./etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
        networks:
            - zone1
        expose:
            - 8080
            - 9090
        labels:
            zone1_argo.client_dashboard.hostname: dashboard.example.com
            zone1_argo.client_dashboard.port: 8080
            zone1_argo.admin_dashboard.hostname: admin.example.com
            zone1_argo.admin_dashboard.port: 9090
            zone1_argo.ssh.hostanme: ssh.example.com
            zone1_argo.ssh.upstream: "ssh://nginx:22"   # <- ability to support upstream in url form instead of just port

networks:
    zone1: