Repository navigation
Commit de999a9
committed
PoC: feat(sandbox): add publish_ports ingress - expose sandbox services via K8s Service
Adds a --publish PORT flag to sandbox create that makes services
running inside the sandbox network namespace reachable from outside.
Changes by layer:
proto: add publish_ports to SandboxTemplate and DriverSandboxTemplate
server: copy publish_ports through driver_sandbox_template_from_public
driver-kubernetes:
- Set OPENSHELL_PUBLISH_PORTS env var and containerPort declarations
on the agent container so the supervisor knows which ports to expose
- Inject openshell.ai/sandbox-id label into every pod template so
Services can select pods by a stable, openshell-controlled label
- After creating the Sandbox CR, create an <name>-inbound ClusterIP
Service exposing the published ports; roll back the Sandbox CR if
Service creation fails so nothing is left in a half-created state
- Delete the -inbound Service on sandbox teardown
sandbox (netns): add publish_ports() which sets up in the pod primary
network namespace:
- PREROUTING DNAT to sandbox netns IP (10.200.0.x)
- OUTPUT DNAT for loopback-originated traffic (kubectl port-forward)
- POSTROUTING MASQUERADE so return traffic from the sandbox netns
has a valid source address
- FORWARD ACCEPT for forwarded packets
- ip_forward=1 and route_localnet=1 (required for OUTPUT DNAT from
127.0.0.1 to route through non-loopback interfaces)
sandbox (lib): read OPENSHELL_PUBLISH_PORTS at startup and call
publish_ports() after the network namespace is configured
cli: add --publish/-p PORT (repeatable), --env KEY=VALUE (repeatable),
and --expose PORT flags to sandbox create; wire publish_ports into
SandboxTemplate
helm/role: grant create/delete/get/list on services to the gateway
service account (required for -inbound Service lifecycle management)
The -inbound Service naming is a workaround for the upstream
kubernetes-sigs/agent-sandbox controller creating the primary headless
Service without a field for additional ports. The correct long-term fix
is to contribute a servicePorts field upstream (NVIDIA#994).
Known limitations:
- No per-sandbox NetworkPolicy for inbound ports (any pod in the
cluster can reach published ports)
- publish_ports not yet declarable in policy YAML or provider profiles1 parent adf18c0 commit de999a9
9 files changed
Lines changed: 378 additions & 12 deletions
File tree
- crates
- openshell-cli/src
- openshell-driver-kubernetes/src
- openshell-sandbox/src
- sandbox/linux
- openshell-server/src/compute
- deploy/helm/openshell/templates
- proto
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1212 | 1212 | | |
1213 | 1213 | | |
1214 | 1214 | | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
1215 | 1221 | | |
1216 | 1222 | | |
1217 | 1223 | | |
| |||
2332 | 2338 | | |
2333 | 2339 | | |
2334 | 2340 | | |
| 2341 | + | |
2335 | 2342 | | |
2336 | 2343 | | |
2337 | 2344 | | |
| |||
2439 | 2446 | | |
2440 | 2447 | | |
2441 | 2448 | | |
| 2449 | + | |
2442 | 2450 | | |
2443 | 2451 | | |
2444 | 2452 | | |
| |||
2464 | 2472 | | |
2465 | 2473 | | |
2466 | 2474 | | |
| 2475 | + | |
2467 | 2476 | | |
2468 | 2477 | | |
2469 | 2478 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1930 | 1930 | | |
1931 | 1931 | | |
1932 | 1932 | | |
| 1933 | + | |
1933 | 1934 | | |
1934 | 1935 | | |
1935 | 1936 | | |
| |||
1963 | 1964 | | |
1964 | 1965 | | |
1965 | 1966 | | |
| 1967 | + | |
1966 | 1968 | | |
1967 | 1969 | | |
1968 | 1970 | | |
| |||
2021 | 2023 | | |
2022 | 2024 | | |
2023 | 2025 | | |
| 2026 | + | |
2024 | 2027 | | |
2025 | 2028 | | |
2026 | 2029 | | |
| |||
2115 | 2118 | | |
2116 | 2119 | | |
2117 | 2120 | | |
2118 | | - | |
2119 | | - | |
2120 | | - | |
2121 | | - | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
2122 | 2134 | | |
2123 | 2135 | | |
2124 | 2136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
331 | 332 | | |
332 | 333 | | |
333 | 334 | | |
334 | | - | |
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
343 | | - | |
| 343 | + | |
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
| 352 | + | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
356 | 470 | | |
357 | 471 | | |
358 | 472 | | |
| |||
364 | 478 | | |
365 | 479 | | |
366 | 480 | | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
367 | 490 | | |
368 | 491 | | |
369 | 492 | | |
| |||
1057 | 1180 | | |
1058 | 1181 | | |
1059 | 1182 | | |
1060 | | - | |
1061 | | - | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
1062 | 1194 | | |
1063 | 1195 | | |
1064 | 1196 | | |
| |||
1091 | 1223 | | |
1092 | 1224 | | |
1093 | 1225 | | |
1094 | | - | |
| 1226 | + | |
1095 | 1227 | | |
1096 | 1228 | | |
1097 | 1229 | | |
| |||
1104 | 1236 | | |
1105 | 1237 | | |
1106 | 1238 | | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
1107 | 1250 | | |
1108 | 1251 | | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
1109 | 1264 | | |
1110 | 1265 | | |
1111 | 1266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
402 | 419 | | |
403 | 420 | | |
404 | 421 | | |
| |||
0 commit comments