* profile browser vnc support + fixes: - switch profile browser rendering to use VNC - frontend: add @novnc/novnc as dependency, create separate bundle novnc.js to load into vnc browser (to avoid loading from each container) - frontend: update proxy paths to proxy websocket, index page to crawler - frontend: allow browser profiles in all browsers, remove browser compatibility check - frontend: update webpack dev config, apply prettier - frontend: node version fix - backend: get vncpassword, build new URL for proxying to crawler iframe - backend: fix profile / crawl job pull policy from 'Always' -> 'Never', should use existing image for job - backend: fix kill signal to use bash -c to work with latest backend image - backend/chart: add 'profile_browser_timeout_seconds' to chart values to control how long profile browser to remain when idle (default to 60) - backend: remove utils.py, now using secret.token_hex() for random suffix Co-authored-by: sua yoo <sua@suayoo.com>
		
			
				
	
	
		
			56 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| """ k8s utils """
 | |
| 
 | |
| import os
 | |
| import yaml
 | |
| 
 | |
| from kubernetes_asyncio.utils import create_from_dict
 | |
| 
 | |
| 
 | |
| def get_templates_dir():
 | |
|     """return directory containing templates for loading"""
 | |
|     return os.path.join(os.path.dirname(__file__), "templates")
 | |
| 
 | |
| 
 | |
| async def create_from_yaml(k8s_client, doc, namespace):
 | |
|     """init k8s objects from yaml"""
 | |
|     yml_document_all = yaml.safe_load_all(doc)
 | |
|     k8s_objects = []
 | |
|     for yml_document in yml_document_all:
 | |
|         created = await create_from_dict(
 | |
|             k8s_client, yml_document, verbose=False, namespace=namespace
 | |
|         )
 | |
|         k8s_objects.append(created)
 | |
| 
 | |
|     return k8s_objects
 | |
| 
 | |
| 
 | |
| async def send_signal_to_pods(core_api_ws, namespace, pods, signame, func=None):
 | |
|     """send signal to all pods"""
 | |
|     command = ["bash", "-c", f"kill -s {signame} 1"]
 | |
|     signaled = False
 | |
| 
 | |
|     try:
 | |
|         for pod in pods:
 | |
|             if func and not func(pod.metadata):
 | |
|                 continue
 | |
| 
 | |
|             print(f"Sending {signame} to {pod.metadata.name}", flush=True)
 | |
| 
 | |
|             res = await core_api_ws.connect_get_namespaced_pod_exec(
 | |
|                 pod.metadata.name,
 | |
|                 namespace=namespace,
 | |
|                 command=command,
 | |
|                 stdout=True,
 | |
|             )
 | |
|             if res:
 | |
|                 print("Result", res, flush=True)
 | |
| 
 | |
|             else:
 | |
|                 signaled = True
 | |
| 
 | |
|     # pylint: disable=broad-except
 | |
|     except Exception as exc:
 | |
|         print(f"Send Signal Error: {exc}", flush=True)
 | |
| 
 | |
|     return signaled
 |