livecycle / preevy

Quickly deploy preview environments to the cloud!

Home Page:https://preevy.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

coherent format of container labels describing proxy behavior

royra opened this issue · comments

Current labels:

  • preevy.access
  • preevy.inject_script
  • preevy.expose

Goals:

  • support multiple ports per container
  • support multiple behavior properties per port: private/public, injection
  • support multiple routes (aliases) per container port, each with its own behavior
  • sane defaults
  • consistent naming and scheme for labels
  • given a set of labels, the proxy agent can print the normalized configuration labels which is complete (like e.g, docker compose config)

Example 1 - defaults

services:
  my-service:
    ports:
    - 3000
    - 8080:8080
    - 8081:8081

can be normalized into:

services:
  my-service:
    ports:
    - 3000
    - 8080:8080
    - 8081:8081

    labels:
      preevy.routes.[3000].port: 3000
      preevy.routes.[3000].access: public
      preevy.routes.[8080].port: 8080
      preevy.routes.[8080].access: public
      preevy.routes.[8081].port: 8081
      preevy.routes.[8081].access: public

and results the following routes:

  • my-service-3000: port 3000, public
  • my-service-8080: port 8080, public
  • my-service-8081: port 8081, public

Example 2

services:
  my-service:
    ports:
    - 3000
    - 8080:8080
    - 8081:8081
    
    labels:
      # global default
      preevy.access: private 

      preevy.routes.[8080].access: public

      preevy.routes.web.port: 3000

      preevy.routes.web-with-tool.port: 3000
      preevy.routes.web-with-tool.inject_script.x.src: http://my-script.com

can be normalized into:

services:
  my-service:
    ports:
    - 3000
    - 8080:8080
    - 8081:8081
    
    labels:
      preevy.routes.web.port: 3000
      preevy.routes.web.access: private
      preevy.routes.web-with-tool.port: 3000
      preevy.routes.web-with-tool.access: private
      preevy.routes.web-with-tool.inject_script.x.src: http://my-script.com
      preevy.routes.[8080].port: 8080
      preevy.routes.[8080].access: public
      preevy.routes.[8081].port: 8081
      preevy.routes.[8081].access: private

and results the following routes:

  • web: port 3000, public
  • web-with-tool: port 3000, private, injects script http://my-script.com
  • my-service-8080: port 8080, public
  • my-service-8081: port 8081, private

note that the default route for port 3000 my-service-3000 is not created because its port is specified in the web and web-with-tool routes.

Edge cases

Missing port

    labels:
      preevy.routes.web.access: private    

This configuration is invalid: there is no preevy.routes.web.port label, can't determine the port for route web.

Redirecting default routes

    labels:
      preevy.routes.[8080].port: 3000

This configuration is valid albeit confusing. It creates the route my-service-8080 with port 3000 and disables the default route for port 3000 my-service-3000.

I really like this format. It seems flexible enough and can be augmented with new features. I believe it would satisfy all my use cases in #421