-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvnc.yaml
More file actions
63 lines (57 loc) · 1.57 KB
/
vnc.yaml
File metadata and controls
63 lines (57 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
apiVersion: v1
kind: Pod
metadata:
name: vnc-test-pod
namespace: default
spec:
containers:
- name: vnc-tester
image: python:3.9-slim
command: ["/bin/sh"]
args: ["-c", "pip install python-vnc-client && python /app/vnc_test.py"]
env:
- name: VNC_HOST
value: "10.66.42.155"
- name: VNC_PORT
value: "5900"
volumeMounts:
- name: script-volume
mountPath: /app
volumes:
- name: script-volume
configMap:
name: vnc-test-script
---
apiVersion: v1
kind: ConfigMap
metadata:
name: vnc-test-script
namespace: default
data:
vnc_test.py: |
import socket
import time
from vncdotool import api
VNC_HOST = "10.66.42.155"
VNC_PORT = 5900
def test_vnc_connection():
print(f"Attempting to connect to VNC server at {VNC_HOST}:{VNC_PORT}")
# First, test if the port is open
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((VNC_HOST, VNC_PORT))
if result == 0:
print("Port is open")
else:
print(f"Port is not open. Error code: {result}")
return
sock.close()
# Now, try to establish a VNC connection
try:
client = api.connect(f'{VNC_HOST}::{VNC_PORT}')
print("Successfully connected to VNC server")
client.disconnect()
except Exception as e:
print(f"Failed to connect to VNC server. Error: {str(e)}")
while True:
test_vnc_connection()
time.sleep(60) # Wait for 60 seconds before next attempt