mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-17 05:31:16 +08:00
Add a new navigator-vm library crate that boots k3s inside a libkrun microVM, accessible from the host via gvproxy port forwarding. Key components: - FFI bindings to libkrun C API (krun_create_ctx, krun_add_net_unixgram, etc.) - VmConfig with gateway() preset for k3s and custom exec mode - gvproxy integration: virtio-net via unixgram, DHCP, native HTTP port forwarding - gateway-init.sh: PID 1 init script with DHCP via udhcpc, mounts, k3s exec - build-rootfs.sh: builds Ubuntu 22.04 arm64 rootfs with k3s + busybox-static - Kubeconfig auto-extraction to ~/.kube/gateway.yaml - CLI integration as 'ncl gateway' with --exec, --port, --net flags - macOS codesigning and DYLD_FALLBACK_LIBRARY_PATH in ncl wrapper
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
"""Minimal HTTP server that responds with 'Hello from libkrun VM!' on port 8080."""
|
|
|
|
import json
|
|
import os
|
|
import platform
|
|
from http.server import HTTPServer, BaseHTTPRequestHandler
|
|
|
|
|
|
class HelloHandler(BaseHTTPRequestHandler):
|
|
def do_GET(self):
|
|
body = json.dumps(
|
|
{
|
|
"message": "Hello from libkrun VM!",
|
|
"hostname": platform.node(),
|
|
"platform": platform.platform(),
|
|
"arch": platform.machine(),
|
|
"pid": os.getpid(),
|
|
"path": self.path,
|
|
},
|
|
indent=2,
|
|
)
|
|
self.send_response(200)
|
|
self.send_header("Content-Type", "application/json")
|
|
self.send_header("Content-Length", str(len(body)))
|
|
self.end_headers()
|
|
self.wfile.write(body.encode())
|
|
|
|
def log_message(self, format, *args):
|
|
print(f"[hello-server] {args[0]}")
|
|
|
|
|
|
def main():
|
|
host = "0.0.0.0"
|
|
port = 8080
|
|
server = HTTPServer((host, port), HelloHandler)
|
|
print(f"Hello server listening on {host}:{port}")
|
|
try:
|
|
server.serve_forever()
|
|
except KeyboardInterrupt:
|
|
print("\nShutting down.")
|
|
server.server_close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|