Skip to content

Commit 53cf03b

Browse files
committed
gvforwarder as a systemd service
- Create a tap device using nmcli with a hardcoded mac address - Start gvforwarder systemd service which will use this device Signed-off-by: vyasgun <vyasgun20@gmail.com>
1 parent 3afaaea commit 53cf03b

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

ci_microshift.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ sudo yum install -y make golang
1010
# Set the zstd compression level to 10 to have faster
1111
# compression while keeping a reasonable bundle size.
1212
export CRC_ZSTD_EXTRA_FLAGS="-10"
13+
1314
./createdisk.sh crc-tmp-install-data
1415

1516
# Delete the crc domain which created by snc so it can created

createdisk.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,40 @@ if podman manifest inspect quay.io/crcont/routes-controller:${OPENSHIFT_VERSION}
9797
image_tag=${OPENSHIFT_VERSION}
9898
fi
9999

100+
# create the tap device interface with specified mac address
101+
# this mac address is used to allocate a specific IP to the VM
102+
# when tap device is in use.
103+
${SSH} core@${VM_IP} 'sudo bash -x -s' <<EOF
104+
nmcli connection delete tap0
105+
nmcli connection add type tun ifname tap0 con-name tap0 mode tap autoconnect yes 802-3-ethernet.cloned-mac-address 5A:94:EF:E4:0C:EE
106+
EOF
107+
108+
100109
# Add gvisor-tap-vsock service
101110
${SSH} core@${VM_IP} 'sudo bash -x -s' <<EOF
102-
podman create --name=gvisor-tap-vsock --privileged --net=host -v /etc/resolv.conf:/etc/resolv.conf -it quay.io/crcont/gvisor-tap-vsock:latest
103-
podman generate systemd --restart-policy=no gvisor-tap-vsock > /etc/systemd/system/gvisor-tap-vsock.service
111+
podman create --name=gvisor-tap-vsock quay.io/crcont/gvisor-tap-vsock:latest
112+
podman cp gvisor-tap-vsock:/vm /usr/local/bin/gvforwarder
113+
podman rm gvisor-tap-vsock
114+
tee /etc/systemd/system/gv-user-network@.service <<TEE
115+
[Unit]
116+
Description=gvisor-tap-vsock Network Traffic Forwarder
117+
After=NetworkManager.service
118+
BindsTo=sys-devices-virtual-net-%i.device
119+
After=sys-devices-virtual-net-%i.device
120+
121+
[Service]
122+
Environment=GV_VSOCK_PORT="1024"
123+
EnvironmentFile=-/etc/sysconfig/gv-user-network
124+
ExecStart=/usr/local/bin/gvforwarder -preexisting -iface %i -url vsock://2:\\\${GV_VSOCK_PORT}/connect -debug
125+
126+
[Install]
127+
WantedBy=multi-user.target
128+
129+
TEE
104130
systemctl daemon-reload
105-
systemctl enable gvisor-tap-vsock.service
131+
systemctl enable gv-user-network@tap0.service
132+
systemctl start gv-user-network@tap0.service
133+
106134
EOF
107135

108136
# Add dummy crio-wipe service to instance

gv-user-network@.service

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=gvisor-tap-vsock Network Traffic Forwarder
3+
After=NetworkManager.service
4+
BindsTo=sys-devices-virtual-net-%i.device
5+
After=sys-devices-virtual-net-%i.device
6+
[Service]
7+
Environment=GV_VSOCK_PORT="1024"
8+
EnvironmentFile=-/etc/sysconfig/gv-user-network
9+
ExecStart=/usr/libexec/podman/gvforwarder -preexisting -iface %i -url vsock://2:${GV_VSOCK_PORT}/connect
10+
[Install]
11+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)