Added the additional_ports configuration
ISSUE: https://github.com/mrsked/mrsk/issues/98
This commit is contained in:
36
README.md
36
README.md
@@ -426,6 +426,42 @@ traefik:
|
|||||||
host_port: 8080
|
host_port: 8080
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Additional entrypoints for traefik
|
||||||
|
|
||||||
|
You can configure additional ports and entrypoints for traefik list so:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
traefik:
|
||||||
|
additional_ports:
|
||||||
|
- 9000
|
||||||
|
- 9001
|
||||||
|
args:
|
||||||
|
entrypoints.myentrypoint.address: ":9000"
|
||||||
|
entrypoints.otherentrypoint.address: ":9001"
|
||||||
|
```
|
||||||
|
|
||||||
|
Be aware, a lot of the out-of-the-box magic of mrsk is provided by traefik defaults so going down this path requires more manual configuration, like so:
|
||||||
|
|
||||||
|
A more complete example including entrypoints would be:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
service: myservice
|
||||||
|
|
||||||
|
labels:
|
||||||
|
traefik.tcp.routers.other.rule: 'HostSNI(`*`)'
|
||||||
|
traefik.tcp.routers.other.entrypoints: otherentrypoint
|
||||||
|
traefik.tcp.services.other.loadbalancer.server.port: 9000
|
||||||
|
traefik.http.routers.myservice.entrypoints: web
|
||||||
|
traefik.http.services.myservice.loadbalancer.server.port: 8080
|
||||||
|
|
||||||
|
traefik:
|
||||||
|
additional_ports:
|
||||||
|
- 9000
|
||||||
|
args:
|
||||||
|
'entrypoints.web.address=:80': true
|
||||||
|
'entrypoints.otherentrypoint.address=:9000': true
|
||||||
|
```
|
||||||
|
|
||||||
### Configuring build args for new images
|
### Configuring build args for new images
|
||||||
|
|
||||||
Build arguments that aren't secret can also be configured:
|
Build arguments that aren't secret can also be configured:
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
|
|||||||
"--restart", "unless-stopped",
|
"--restart", "unless-stopped",
|
||||||
"--log-opt", "max-size=#{MAX_LOG_SIZE}",
|
"--log-opt", "max-size=#{MAX_LOG_SIZE}",
|
||||||
"--publish", port,
|
"--publish", port,
|
||||||
|
*additional_ports,
|
||||||
"--volume", "/var/run/docker.sock:/var/run/docker.sock",
|
"--volume", "/var/run/docker.sock:/var/run/docker.sock",
|
||||||
"traefik",
|
"traefik",
|
||||||
"--providers.docker",
|
"--providers.docker",
|
||||||
@@ -54,6 +55,14 @@ class Mrsk::Commands::Traefik < Mrsk::Commands::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
def additional_ports
|
||||||
|
if args = config.raw_config.dig(:traefik, "additional_ports")
|
||||||
|
args.collect { |value| "--publish #{value}:#{value}" }.compact
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def cmd_option_args
|
def cmd_option_args
|
||||||
if args = config.traefik["args"]
|
if args = config.traefik["args"]
|
||||||
optionize args, with: "="
|
optionize args, with: "="
|
||||||
|
|||||||
@@ -19,6 +19,17 @@ class CommandsTraefikTest < ActiveSupport::TestCase
|
|||||||
new_command.run.join(" ")
|
new_command.run.join(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "run with additional entrypoints" do
|
||||||
|
assert_equal \
|
||||||
|
"docker run --name traefik --detach --restart unless-stopped --log-opt max-size=10m --publish 80:80 --volume /var/run/docker.sock:/var/run/docker.sock traefik --providers.docker --log.level=DEBUG --accesslog.format \"json\" --metrics.prometheus.buckets \"0.1,0.3,1.2,5.0\"",
|
||||||
|
new_command.run.join(" ")
|
||||||
|
|
||||||
|
@config[:traefik]["additional_ports"] = %w[9000 9001]
|
||||||
|
assert_equal \
|
||||||
|
"docker run --name traefik --detach --restart unless-stopped --log-opt max-size=10m --publish 80:80 --publish 9000:9000 --publish 9001:9001 --volume /var/run/docker.sock:/var/run/docker.sock traefik --providers.docker --log.level=DEBUG --accesslog.format \"json\" --metrics.prometheus.buckets \"0.1,0.3,1.2,5.0\"",
|
||||||
|
new_command.run.join(" ")
|
||||||
|
end
|
||||||
|
|
||||||
test "run without configuration" do
|
test "run without configuration" do
|
||||||
@config.delete(:traefik)
|
@config.delete(:traefik)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user