Skip to content

Commit 3879ea2

Browse files
vyasgunpraveenkumar
authored andcommitted
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 1ac852f commit 3879ea2

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

createdisk.sh

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,38 @@ if podman manifest inspect quay.io/crcont/routes-controller:${OPENSHIFT_VERSION}
9494
image_tag=${OPENSHIFT_VERSION}
9595
fi
9696

97+
# create the tap device interface with specified mac address
98+
# this mac address is used to allocate a specific IP to the VM
99+
# when tap device is in use.
100+
${SSH} core@${VM_IP} 'sudo bash -x -s' <<EOF
101+
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
102+
EOF
103+
104+
97105
# Add gvisor-tap-vsock service
98106
${SSH} core@${VM_IP} 'sudo bash -x -s' <<EOF
99-
podman pull quay.io/crcont/gvisor-tap-vsock:latest
100-
cat > /etc/containers/systemd/gvisor-tap-vsock.container <<EOF1
107+
podman create --name=gvisor-tap-vsock quay.io/crcont/gvisor-tap-vsock:latest
108+
podman cp gvisor-tap-vsock:/vm /usr/local/bin/gvforwarder
109+
podman rm gvisor-tap-vsock
110+
tee /etc/systemd/system/gv-user-network@.service <<TEE
101111
[Unit]
102-
Description=gvisor-tap-vsock
103-
Before=nodeip-configuration.service
112+
Description=gvisor-tap-vsock Network Traffic Forwarder
113+
After=NetworkManager.service
114+
BindsTo=sys-devices-virtual-net-%i.device
115+
After=sys-devices-virtual-net-%i.device
104116
105-
[Container]
106-
Image=quay.io/crcont/gvisor-tap-vsock:latest
107-
Network=host
108-
PodmanArgs=--interactive --privileged --tty
109-
Volume=/etc/resolv.conf:/etc/resolv.conf
117+
[Service]
118+
Restart=on-failure
119+
Environment="GV_VSOCK_PORT=1024"
120+
EnvironmentFile=-/etc/sysconfig/gv-user-network
121+
ExecStart=/usr/local/bin/gvforwarder -preexisting -iface %i -url vsock://2:"\\\${GV_VSOCK_PORT}"/connect
110122
111123
[Install]
112-
WantedBy=default.target
113-
EOF1
124+
WantedBy=multi-user.target
125+
126+
TEE
127+
systemctl daemon-reload
128+
systemctl enable gv-user-network@tap0.service
114129
EOF
115130

116131
# Add dummy crio-wipe service to instance

0 commit comments

Comments
 (0)