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

Network macvlan for containers #12

Merged
merged 13 commits into from
Jun 13, 2020
Merged

Network macvlan for containers #12

merged 13 commits into from
Jun 13, 2020

Conversation

stephdl
Copy link
Collaborator

@stephdl stephdl commented Jun 2, 2020

Macvlan must be created by filling some important parameters, the goal is to create a container with an IP on your network

macVlanGateway is the gateway of your network (192.168.12.1)
macVlanLocalNetwork is the full network of your router (192.168.12.0/24)
macVlanNetwork is the restricted IP for macVlan0 (192.168.12.192/27 here 32 IP for your container 192.168.12.193->192.168.12.222)
macVlanNic is the NIC where to run macvlan (eth0 here)

[root@ns7dev9 ~]# config setprop  docker macVlanGateway 192.168.12.1 macVlanLocalNetwork 192.168.12.0/24 macVlanNetwork 192.168.12.192/27 macVlanNic eth0
[root@ns7dev9 ~]# signal-event nethserver-docker-update 

create the container with an IP on your network here 192.168.12.211

docker run --net=macvlan -dit --name nginx-test-01 --ip=192.168.12.211 --restart=unless-stopped nginx:alpine nginx-debug -g 'daemon off;'

if all is good, the container is reachable locally and externally

[root@ns7dev9 ~]# curl 192.168.12.211
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

some debug command

  • check macvlan0 is created
    ip a
    must be inet 192.168.12.192/27
  • check docker macvlan network is created
    docker network ls
    b4f0244f07cb macvlan macvlan local

@nethbot
Copy link
Member

nethbot commented Jun 2, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 2, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 2, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 3, 2020

in 7.8.2003/nethforge-autobuild:

@stephdl stephdl requested a review from mrmarkuz June 3, 2020 13:32
Copy link
Member

@mrmarkuz mrmarkuz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's working as expected.
macvlan0 and docker macvlan network are created and the test container is curlable from host and local network.

@stephdl
Copy link
Collaborator Author

stephdl commented Jun 3, 2020

did you check after a server restart, does macvlan0 is created after the reboot, does the container is up ?

Did you check also after a shorewall restart, a docker restart ?

@mrmarkuz
Copy link
Member

mrmarkuz commented Jun 3, 2020

I need to recheck with a clean install, I tested too much and now the test machine hangs...
I can confirm that the route was recreated after reboot (I deleted it before) and macvlan0 was there...
EDIT:
The container is up and reachable from host and network even after restarting docker or shorewall or after reboot.

The ssh connection to the docker host freezes for some seconds about every 20 seconds after reboot of the docker host. When I restart shorewall the issue disappears.

A docker-ce update stops the test container and it's not startable anymore, I needed to remove and recreate.

Error response from daemon: failed to listen to abstract unix socket "/containerd-shim/moby/a9070b5aa314b7a4aa64b9d08263ca44a92dccb9ca1337c251278e6eece7d736/shim.sock": listen unix /containerd-shim/moby/a9070b5aa314b7a4aa64b9d08263ca44a92dccb9ca1337c251278e6eece7d736/shim.sock: bind: address already in use: unknown
Error: failed to start containers: a9070b5aa314

@stephdl
Copy link
Collaborator Author

stephdl commented Jun 3, 2020

I think we need to enable live-restore
https://docs.docker.com/config/containers/live-restore/

for what I tested it works well

@nethbot
Copy link
Member

nethbot commented Jun 3, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 3, 2020

in 7.8.2003/nethforge-autobuild:

@stephdl
Copy link
Collaborator Author

stephdl commented Jun 3, 2020

confirmed with live-restore the container is not hanged during the service restart nor the service upgrade

@mrmarkuz
Copy link
Member

mrmarkuz commented Jun 3, 2020

Great! It's working now even after docker upgrade.
The ssh freeze issue disappeared too.

@stephdl
Copy link
Collaborator Author

stephdl commented Jun 3, 2020

I ask myself if it could solve our issue with aeria ?

@pagaille
Copy link

pagaille commented Jun 3, 2020

Found a bug (I think)

To reproduce : set the prop macVlanNetwork to some subnet, apply by firing the nethserver-docker-update, then set the prop to another subnet and fire the event again.

Expected : last subnet is reported with ip a
Instead, the two subnets are present :

24: macvlan0@br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether 76:e0:32:98:bc:99 brd ff:ff:ff:ff:ff:ff
    inet 10.0.1.192/27 scope global macvlan0
       valid_lft forever preferred_lft forever
    inet 10.0.1.224/27 scope global macvlan0
       valid_lft forever preferred_lft forever

@stephdl
Copy link
Collaborator Author

stephdl commented Jun 3, 2020

aeria and macvlan cannot share the same bridge br0 :(

@mrmarkuz
Copy link
Member

mrmarkuz commented Jun 3, 2020

I tested aeria, it seems we have some more issues:

  • Portainer refuses to connect locally to /var/run/docker.sock, even without aeria.

  • Starting pihole with aeria is not working:

docker: Error response from daemon: failed to create endpoint pihole on network aeria: NetworkDriver.CreateEndpoint: ('Connection aborted.', ConnectionRefusedError(111, 'Connection refused')).

Both works with the stable nethserver-docker version, I retested it.

@stephdl
Copy link
Collaborator Author

stephdl commented Jun 3, 2020

Portainer is not so stable I think, maybe a version related issue, for pihole I think it works I am playing with it, but aeria alone, I think macvlan and aeria are incompatible or at least not on the same bridge

@stephdl
Copy link
Collaborator Author

stephdl commented Jun 3, 2020

the live-restore solved the upgrade issue with aeria, the container, aeria, docker are up after the upgrade

but if I restart the server, the service is down.... I think I want to switch pihole to macvlan

@pagaille
Copy link

pagaille commented Jun 3, 2020

On my side pihole works on Aeria but sometimes stop resolving anything for an unknown reason. Did try on aqua as well without success. Maybe I should delete the persistent volumes, it could be a configuration error.

@stephdl
Copy link
Collaborator Author

stephdl commented Jun 3, 2020

Maybe I should delete the persistent volumes, it could be a configuration error.

Yes it could be related when a container doesn't want to start

@mrmarkuz
Copy link
Member

mrmarkuz commented Jun 3, 2020

If pihole accepts a fixed IP it should work with macvlan.

The same portainer version works with stable nethserver-docker so I think there's an issue in this pull request...

@stephdl
Copy link
Collaborator Author

stephdl commented Jun 3, 2020

hum

testing portainer with default docker, it doesn't start even without created another docker network

[root@ns7dev9 ~]# rpm -qa | grep docker
docker-ce-cli-19.03.8-3.el7.x86_64
nethserver-docker-1.0.1-1.ns7.noarch
docker-ce-19.03.8-3.el7.x86_64
[root@ns7dev9 ~]# docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
6d0b30b4d351        aqua                bridge              local
f5fa42c2197e        host                host                local
328b3560ff4f        none                null                local

803e86fada17 portainer/portainer "/portainer" 2 minutes ago Restarting (2) 51 seconds ago portainer

not sure my version has changed something

@stephdl
Copy link
Collaborator Author

stephdl commented Jun 3, 2020

Removing everything under [root@ns7dev9 ~]# rm /var/lib/nethserver/portainer/* -rf and the container can be created

@nethbot
Copy link
Member

nethbot commented Jun 4, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 4, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 4, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 6, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 6, 2020

in 7.8.2003/nethforge-autobuild:

1 similar comment
@nethbot
Copy link
Member

nethbot commented Jun 10, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 10, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 13, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 13, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 13, 2020

in 7.8.2003/nethforge-autobuild:

@nethbot
Copy link
Member

nethbot commented Jun 13, 2020

in 7.8.2003/nethforge-autobuild:

@stephdl stephdl merged commit dca658b into NethServer:master Jun 13, 2020
@stephdl stephdl deleted the macvlan branch June 13, 2020 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants