Skip to content

Commit 0c68848

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 207dbb8 commit 0c68848

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

createdisk.sh

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +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 create --name=gvisor-tap-vsock --privileged --net=host -v /etc/resolv.conf:/etc/resolv.conf -it quay.io/crcont/gvisor-tap-vsock:latest
100-
podman generate systemd --restart-policy=no gvisor-tap-vsock > /etc/systemd/system/gvisor-tap-vsock.service
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
111+
[Unit]
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
116+
117+
[Service]
118+
Environment=GV_VSOCK_PORT="1024"
119+
EnvironmentFile=-/etc/sysconfig/gv-user-network
120+
ExecStart=/usr/local/bin/gvforwarder -preexisting -iface %i -url vsock://2:\\\${GV_VSOCK_PORT}/connect
121+
122+
[Install]
123+
WantedBy=multi-user.target
124+
125+
TEE
101126
systemctl daemon-reload
102-
systemctl enable gvisor-tap-vsock.service
127+
systemctl enable gv-user-network@tap0.service
128+
103129
EOF
104130

105131
# Add dummy crio-wipe service to instance

0 commit comments

Comments
 (0)