Skip to content

Commit 363b3f5

Browse files
authored
Merge pull request #8759 from chrischdi/pr-gcve-debug-connectivity
gcve: add script to debug network connectivity to vsphere
2 parents da07d4e + 1479a80 commit 363b3f5

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

infra/gcp/terraform/k8s-infra-gcp-gcve/maintenance-jumphost/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,17 @@ NOTE: A replacement VM will have a new IP address; all the local machine config
3434

3535
```sh
3636
terraform destroy
37-
```
37+
```
38+
39+
# Debuggin network connectivity
40+
41+
The maintenance VM runs a small timer/cronjob every two minutes which tests the network connectivity to:
42+
43+
* vSphere
44+
* NSX-T
45+
46+
To inspect the logs, use:
47+
48+
```sh
49+
sudo journalctl -u check-gcve-connectivity.service
50+
```

infra/gcp/terraform/k8s-infra-gcp-gcve/maintenance-jumphost/cloud-config.yaml.tftpl

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,60 @@ write_files:
1010
content: |
1111
net.ipv4.ip_forward = 1
1212

13+
- path: /etc/systemd/system/check-gcve-connectivity.service
14+
permissions: "0755"
15+
content: |
16+
[Unit]
17+
Description=GCVE Connectivity Test
18+
# This ensures it doesn't run until the network is ready, remove if not needed
19+
Wants=network-online.target
20+
After=network-online.target
21+
22+
[Service]
23+
Type=oneshot
24+
# Replace this with your actual command or script
25+
ExecStart=/usr/local/bin/check-gcve-connectivity.sh
26+
27+
- path: /etc/systemd/system/check-gcve-connectivity.timer
28+
permissions: "0644"
29+
content: |
30+
[Unit]
31+
Description=Run check-gcve-connectivity every two minutes
32+
33+
[Timer]
34+
# Run every two minutes
35+
OnCalendar=*:0/2
36+
Persistent=true
37+
38+
[Install]
39+
WantedBy=timers.target
40+
41+
- path: /usr/local/bin/check-gcve-connectivity.sh
42+
permissions: "0644"
43+
content: |
44+
#!/bin/bash
45+
46+
function log() {
47+
echo "$(date '+%Y-%m-%d %H:%M:%S') ${1}"
48+
}
49+
50+
function test_connectivity() {
51+
curl -s "${2}" --connect-timeout 2 -k && RET=$? || RET=$?
52+
if [[ "$RET" -eq 0 ]]; then
53+
log "Successfully reached ${1} / ${2}"
54+
else
55+
log "Failed to reach ${1} / ${2}"
56+
fi
57+
}
58+
59+
test_connectivity VSphere "https://192.168.31.2/sdk"
60+
test_connectivity NSX "https://192.168.31.18/sdk"
61+
1362
runcmd:
1463
- apt-get update
1564
- apt install wireguard -q -y
1665
- sysctl -p /etc/sysctl.d/10-wireguard.conf
1766
- systemctl enable wg-quick@wg0
1867
- systemctl start wg-quick@wg0
68+
- systemctl enable check-gcve-connectivity.timer
69+
- systemctl start check-gcve-connectivity.timer

0 commit comments

Comments
 (0)