Add configuration item of container.network #184

Merged
wolfogre merged 12 commits from sillyguodong/act_runner:feature/container_network into main 2023-05-16 06:47:00 +00:00
Member

Close #177
Related gitea/act#56

⚠️ Breaking

The container.network_mode is a deprecated configuration item. It may be removed after Gitea 1.20 released.
Previously, if the value of container.network_mode is bridge, it means that act_runner will create a new network for job.But bridge is easily confused with the bridge network created by Docker by default.
We recommand that using container.network to specify the network to which containers created by act_runner connect.

🆕 container.network

The configuration file of act_runner add a new item of contianer.network.(Please make sure that container.network_mode not exists in configuration file.)
In config.example.yaml:

container:
  # Specifies the network to which the container will connect.
  # Could be host, bridge or the name of a custom network.
  # If it's empty, act_runner will create a network automatically.
  network: ""

As the comment in the example above says, the purpose of the container.network is specifying the network to which containers created by act_runner will connect.

container.network accepts the following valid values:

  • host: All of containers (including job containers and service contianers) created by act_runner will be connected to the network named host which is created automatically by Docker. Containers will share the host’s network stack and all interfaces from the host will be available to these containers.
  • bridge: It is similar to host. All of containers created by act_runner will be connected to the network named bridge which is created automatically by Docker. All containers connected to the bridge (Perhaps there are containers that are not created by act_runner) are allowed to communicate with each other, while providing isolation from containers which are not connected to that bridge network.
  • <custom_network>: Please make sure that the <custom_network> network already exists firstly (act_runner does not detect whether the specified network exists currently. If not exists yet, will return error in the stage of docker create). All of containers created by act_runner will be connected to <custom_network>. After the job is executed, containers are removed and automatically disconnected from the <custom_network>.
  • empty: act_runner will create a new network for each job container and their service containers (if defined in workflow). So each job container and their service containers share a network environment, but are isolated from others container and the Docker host. Of course, these networks created by act_runner will be removed at last.

Others

  • If you do not have special needs, we highly recommend that setting container.network to empty string (and do not use container.network_mode any more). Because the containers created by act_runner will connect to the networks that are created by itself. This point will provide better isolation.
  • If you set contianer.network to empty string or <custom_network>, we can be access to service containers by <service-id>:<port> in the steps of job. Because we added an alias to the service container when connecting to the network.
Close https://gitea.com/gitea/act_runner/issues/177 Related https://gitea.com/gitea/act/pulls/56 ### ⚠️ Breaking The `container.network_mode` is a deprecated configuration item. It may be removed after Gitea 1.20 released. Previously, if the value of `container.network_mode` is `bridge`, it means that `act_runner` will create a new network for job.But `bridge` is easily confused with the bridge network created by Docker by default. We recommand that using `container.network` to specify the network to which containers created by `act_runner` connect. ### 🆕 container.network The configuration file of `act_runner` add a new item of `contianer.network`.(**Please make sure that `container.network_mode` not exists in configuration file.**) In `config.example.yaml`: ```yaml container: # Specifies the network to which the container will connect. # Could be host, bridge or the name of a custom network. # If it's empty, act_runner will create a network automatically. network: "" ``` As the comment in the example above says, the purpose of the `container.network` is specifying the network to which containers created by `act_runner` will connect. `container.network` accepts the following valid values: - `host`: All of containers (including job containers and service contianers) created by `act_runner` will be connected to the network named `host` which is created automatically by Docker. Containers will share the host’s network stack and all interfaces from the host will be available to these containers. - `bridge`: It is similar to `host`. All of containers created by `act_runner` will be connected to the network named `bridge` which is created automatically by Docker. All containers connected to the `bridge` (Perhaps there are containers that are not created by `act_runner`) are allowed to communicate with each other, while providing isolation from containers which are not connected to that `bridge` network. - `<custom_network>`: Please make sure that the `<custom_network>` network already exists firstly (`act_runner` does not detect whether the specified network exists currently. If not exists yet, will return error in the stage of `docker create`). All of containers created by `act_runner` will be connected to `<custom_network>`. After the job is executed, containers are removed and automatically disconnected from the `<custom_network>`. - empty: `act_runner` will create a new network for each job container and their service containers (if defined in workflow). So each job container and their service containers share a network environment, but are isolated from others container and the Docker host. Of course, these networks created by `act_runner` will be removed at last. ### Others - If you do not have special needs, we highly recommend that setting `container.network` to empty string (and do not use `container.network_mode` any more). Because the containers created by `act_runner` will connect to the networks that are created by itself. This point will provide better isolation. - If you set `contianer.network` to empty string or `<custom_network>`, we can be access to service containers by `<service-id>:<port>` in the steps of job. Because we added an alias to the service container when connecting to the network.
sillyguodong added 1 commit 2023-05-12 08:35:25 +00:00
use container.NetworkMode
Some checks failed
checks / check and test (pull_request) Failing after 36s
4cd821b06d
sillyguodong added 1 commit 2023-05-12 08:53:02 +00:00
Merge branch 'main' into feature/container_network
Some checks failed
checks / check and test (pull_request) Failing after 36s
0f245aaa2c
sillyguodong added 1 commit 2023-05-12 08:55:18 +00:00
delete ,
Some checks failed
checks / check and test (pull_request) Failing after 34s
d4fc49b9e7
sillyguodong added 1 commit 2023-05-13 01:03:08 +00:00
control network by passing NeedCreate to act
Some checks failed
checks / check and test (pull_request) Failing after 35s
cb973caba1
sillyguodong added 1 commit 2023-05-13 01:14:57 +00:00
config return to double quote
Some checks failed
checks / check and test (pull_request) Failing after 33s
975d8494ee
sillyguodong added 1 commit 2023-05-13 01:15:52 +00:00
go mod
Some checks failed
checks / check and test (pull_request) Failing after 34s
7b04be5065
sillyguodong added 1 commit 2023-05-15 04:02:21 +00:00
be compatible with container.network_mode
Some checks failed
checks / check and test (pull_request) Failing after 49s
f68a560b32
sillyguodong changed title from Switch the type of `ContainerNetworkMode` to `container.NetworkMode` to Add configuration item of `container.network` 2023-05-15 06:40:09 +00:00
sillyguodong requested review from wolfogre 2023-05-15 06:58:17 +00:00
sillyguodong added 1 commit 2023-05-16 03:10:17 +00:00
fix if cond order
Some checks failed
checks / check and test (pull_request) Failing after 49s
76633e1836
wolfogre reviewed 2023-05-16 03:41:53 +00:00
@ -36,2 +36,3 @@
Container struct {
NetworkMode string `yaml:"network_mode"`
Network string `yaml:"network"`
NetworkMode string `yaml:"network_mode"` // leagcy, but will be abandoned in future, be replace by network.
Owner
NetworkMode   string `yaml:"network_mode"` // Deprecated: use Network instead. Could be removed after Gitea 1.20
```go NetworkMode string `yaml:"network_mode"` // Deprecated: use Network instead. Could be removed after Gitea 1.20 ```
wolfogre marked this conversation as resolved
sillyguodong added 1 commit 2023-05-16 05:47:18 +00:00
fix compatible logic
Some checks failed
checks / check and test (pull_request) Failing after 46s
37a9b8ec83
wolfogre approved these changes 2023-05-16 06:01:17 +00:00
sillyguodong added 2 commits 2023-05-16 06:29:30 +00:00
go mod
All checks were successful
checks / check and test (pull_request) Successful in 1m21s
5e36cb97e5
wolfogre added 1 commit 2023-05-16 06:46:06 +00:00
Merge branch 'main' into feature/container_network
All checks were successful
checks / check and test (pull_request) Successful in 40s
80a449e959
wolfogre merged commit 35596a182b into main 2023-05-16 06:47:00 +00:00
Sign in to join this conversation.
No description provided.