Skip to content

Commit abece15

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 <[email protected]>
1 parent 3afaaea commit abece15

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

createdisk.sh

+30-3
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,39 @@ 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 add type tun ifname tap0 con-name tap0 mode tap autoconnect yes 802-3-ethernet.cloned-mac-address 5A:94:EF:E4:0C:EE
105+
EOF
106+
107+
100108
# Add gvisor-tap-vsock service
101109
${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
110+
podman create --name=gvisor-tap-vsock quay.io/crcont/gvisor-tap-vsock:latest
111+
podman cp gvisor-tap-vsock:/vm /usr/local/bin/gvforwarder
112+
podman rm gvisor-tap-vsock
113+
tee /etc/systemd/system/[email protected] <<TEE
114+
[Unit]
115+
Description=gvisor-tap-vsock Network Traffic Forwarder
116+
After=NetworkManager.service
117+
BindsTo=sys-devices-virtual-net-%i.device
118+
After=sys-devices-virtual-net-%i.device
119+
120+
[Service]
121+
Environment=GV_VSOCK_PORT="1024"
122+
EnvironmentFile=-/etc/sysconfig/gv-user-network
123+
ExecStart=/usr/local/bin/gvforwarder -preexisting -iface %i -url vsock://2:\\\${GV_VSOCK_PORT}/connect
124+
125+
[Install]
126+
WantedBy=multi-user.target
127+
128+
TEE
104129
systemctl daemon-reload
105-
systemctl enable gvisor-tap-vsock.service
130+
systemctl enable [email protected]
131+
systemctl start [email protected]
132+
106133
EOF
107134

108135
# Add dummy crio-wipe service to instance

0 commit comments

Comments
 (0)