feat: allow all network properties to be globally set

Global settings are cool if managed in a standard way (ugh env vars) so we'll add them back for golang plugins as necessary.
This commit is contained in:
Jose Diaz-Gonzalez
2021-03-22 17:13:54 -04:00
parent 84907be0cd
commit 8d26d06f5e
5 changed files with 210 additions and 41 deletions

View File

@@ -148,12 +148,22 @@ dokku network:set node-js-app attach-post-deploy
dokku network:set node-js-app initial-network
```
Finally, the `initial-network` property can be set globally by using the `--global` flag in place of the app name.
The network properties can also be set globally. The global default is emty string, and the global value is used when no app-specific value is set.
```shell
dokku network:set --global attach-post-create global-create-network
dokku network:set --global attach-post-deploy global-deploy-network
dokku network:set --global initial-network global-network
```
The default value may be set by passing an empty value for the option.
```shell
dokku network:set --global attach-post-create
dokku network:set --global attach-post-deploy
dokku network:set --global initial-network
```
#### Network Aliases
When a container created for a deployment is being attached to a network - regardless of which `attach` property was used - a network alias of the pattern `APP.PROC_TYPE` will be added to all containers. This can be used to load-balance requests between containers. For an application named `node-js-app` with a process type of web, the network alias - or resolvable DNS record within the network - will be:
@@ -172,7 +182,7 @@ Dockerfile-based applications may listen on other ports. For more information on
#### Specifying a custom TLD
When attaching applications to networks, a custom TLD can be specified via the `network:set` command. This TLD is suffixed to the network alias for the application/process-type combination for _all_ networks to which the application is attached, and cannot be customized per network.
When attaching applications to networks, a custom TLD can be specified via the `network:set` command. This TLD is suffixed to the network alias for the application/process-type combination for _all_ networks to which the application is attached, and cannot be customized per network. The default value is an empty string.
To specify a TLD of `svc.cluster.local` for your application, run the following command:
@@ -189,6 +199,24 @@ node-js-app.web.svc.cluster.local
Note that this has no impact on container port handling, and users must still specify the container port when making internal network requests.
The default value may be set by passing an empty value for the option:
```shell
dokku network:set node-js-app tld
```
The `tld` property can also be set globally. The global default is emty string, and the global value is used when no app-specific value is set.
```shell
dokku network:set --global tld svc.cluster.local
```
The default value may be set by passing an empty value for the option.
```shell
dokku network:set --global tld
```
#### When to attach containers to a network
Containers can be attached to a network for a variety of reasons:
@@ -297,6 +325,18 @@ CONTAINER ID IMAGE COMMAND CREATED
d6499edb0edb dokku/node-js-app:latest "/bin/bash -c '/star About a minute ago Up About a minute 0.0.0.0:49153->5000/tcp node-js-app.web.1
```
The `bind-all-interfaces` property can also be set globally. The global default is `false`, and the global value is used when no app-specific value is set.
```shell
dokku network:set --global bind-all-interfaces true
```
The default value may be set by passing an empty value for the option.
```shell
dokku network:set --global bind-all-interfaces
```
### Displaying network reports for an app
You can get a report about the app's network status using the `network:report` command:
@@ -307,14 +347,56 @@ dokku network:report
```
=====> node-js-app network information
Network bind all interfaces: false
Network listeners: 172.17.0.1:5000
Network attach post create:
Network attach post deploy:
Network bind all interfaces: false
Network computed attach post create:
Network computed attach post deploy:
Network computed bind all interfaces:false
Network computed initial network:
Network computed tld:
Network global attach post create:
Network global attach post deploy:
Network global bind all interfaces:false
Network global initial network:
Network global tld:
Network initial network:
Network tld:
Network web listeners: 172.17.0.1:5000
=====> python-sample network information
Network bind all interfaces: false
Network listeners: 172.17.0.2:5000
Network attach post create:
Network attach post deploy:
Network bind all interfaces: false
Network computed attach post create:
Network computed attach post deploy:
Network computed bind all interfaces:false
Network computed initial network:
Network computed tld:
Network global attach post create:
Network global attach post deploy:
Network global bind all interfaces:false
Network global initial network:
Network global tld:
Network initial network:
Network tld:
Network web listeners: 172.17.0.2:5000
=====> ruby-sample network information
Network bind all interfaces: true
Network listeners:
Network attach post create:
Network attach post deploy:
Network bind all interfaces: false
Network computed attach post create:
Network computed attach post deploy:
Network computed bind all interfaces:false
Network computed initial network:
Network computed tld:
Network global attach post create:
Network global attach post deploy:
Network global bind all interfaces:false
Network global initial network:
Network global tld:
Network initial network:
Network tld:
Network web listeners:
```
You can run the command for a specific app also.
@@ -325,8 +407,22 @@ dokku network:report node-js-app
```
=====> node-js-app network information
Network bind all interfaces: false
Network listeners: 172.17.0.1:5000
Network attach post create:
Network attach post deploy:
Network bind all interfaces: false
Network computed attach post create:
Network computed attach post deploy:
Network computed bind all interfaces:false
Network computed initial network:
Network computed tld:
Network global attach post create:
Network global attach post deploy:
Network global bind all interfaces:false
Network global initial network:
Network global tld:
Network initial network:
Network tld:
Network web listeners: 172.17.0.1:5000
```
You can pass flags which will output only the value of the specific information you want. For example: