Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI route commands #357

Open
EnigmaCurry opened this issue Nov 3, 2024 · 1 comment · May be fixed by #360
Open

CLI route commands #357

EnigmaCurry opened this issue Nov 3, 2024 · 1 comment · May be fixed by #360

Comments

@EnigmaCurry
Copy link
Owner

EnigmaCurry commented Nov 3, 2024

To create layer 7 / layer 4 routes you have to go into the traefik config and find Advanced routing, and you're three menus deep. Let's make a CLI command to do it in one step.

## List Layer 7 and Layer 4 routes:
$ sentry route list

## Manage Layer 7 routes:
$ sentry route add DOMAIN DEST_IP DEST_PORT [--proxy-protocol true] [--restart true/false]
$ sentry route remove DOMAIN [--restart true/false]

## Manage Layer 4 routes with --layer4:
$ sentry route add ENTRYPOINT DEST_IP DEST_PORT --layer4 [--proxy-protocol true] [--restart true/false]
$ sentry route remove ENTRYPOINT --layer4 [--restart true/false]

## It should respond to the following environment variables found in .env_{CONTEXT}:
## Turns on proxy protocol by default for new routes:
DEFAULT_CLI_ROUTE_LAYER_7_PROXY_PROTOCOL=true
DEFAULT_CLI_ROUTE_LAYER_4_PROXY_PROTOCOL=true
@EnigmaCurry EnigmaCurry linked a pull request Nov 5, 2024 that will close this issue
@EnigmaCurry
Copy link
Owner Author

$ d route
Manage Traefik routes

Usage: d route {list|set|remove} ARGS [options]

Subcommands:
  list      - List all routes
  set       - Set a new route or update an existing one
      set (DOMAIN|ENTRYPOINT) DEST_IP DEST_PORT [OPTIONS...]
  remove    - Remove an existing route
      remove (DOMAIN|ENTRYPOINT) [OPTIONS...]

Options for set / remove:
  --layer7                       - create a Layer 7 route (default)
  --layer4                       - create a Layer 4 route
  --restart [true/false]         - Automatically restart Traefik or not
  --proxy-protocol [true/false]  - Turn on Proxy Protocol for the route or not
  --protocol [udp/tcp]           - TCP (default) or UDP

Examples:

List all routes:

 d list

Set Layer 7 route to HTTP(s) destination 192.168.1.2:8000
using the context default proxy protocol option:

 d route set --layer7 whoami.example.com 192.168.1.2 8000

Set Layer 7 route to HTTP(s) destination 192.168.1.2:8000
forcing the proxy protocol option ON:

 d route set --layer7 whoami.example.com 192.168.1.2 8000 --proxy-protocol true

Remove Layer 7 route:

 d route remove --layer7 whoami.example.com

Set Layer 4 route to TCP destination 192.168.1.2:9000
using an existing entrypoint named 'test'
using the context default proxy protocol option (or set --proxy-protocol true):

 d route set --layer4 test 192.168.1.2 9000

Remove Layer 4 route:

 d route remove --layer4 test

All examples will ask to restart Traefik, unless --restart true/false is set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant