Skip to content

Commit 0506c7d

Browse files
committed
test(supervisor): automate Kubernetes application listener e2e
Signed-off-by: Taylor Mutch <taylormutch@gmail.com>
1 parent d070d6c commit 0506c7d

11 files changed

Lines changed: 1537 additions & 23 deletions

File tree

‎.agents/skills/helm-dev-environment/SKILL.md‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,15 @@ above) instead of relying only on `OPENSHELL_GATEWAY_ENDPOINT`; some tests call
421421
### Kubernetes E2E Notes
422422

423423
Use `mise run e2e:kubernetes` for the standard Helm-backed Kubernetes suite.
424+
For the opt-in application listener, build/import matching branch images and run
425+
`mise run e2e:kubernetes:app-listener`; see `e2e/kubernetes/app-listener/README.md`
426+
for image, topology, delivery-mode and takeover inputs. The task owns an isolated
427+
Helm release/namespace, temporary TLS material, in-cluster clients, teardown and
428+
evidence under `results/app-listener/`. It checks policy denial, Pod-IP ingress without app Services, shared-owner takeover, gateway-outage expiry and disabled-listener
429+
gateway compatibility, without discovery or a proxy. CI runs four cases under
430+
`test:e2e` and includes them in `Core E2E result`. Its reusable kind setup installs
431+
pinned Calico only for this lane; other jobs retain kindnet. Local k3s already
432+
enforces policy. The lower-level `verify.py` can target a predeployed release.
424433
The kube e2e wrapper creates only one port-forward, to `svc/openshell`; it no
425434
longer forwards the unauthenticated health listener or runs a `/readyz` e2e
426435
target. `/readyz` remains covered by server unit/integration tests.
@@ -619,6 +628,6 @@ supervisor listener at port 9443 without discovery or a proxy. Provision the
619628
operator TLS Secret and an ingress-client NetworkPolicy first. Follow
620629
`e2e/kubernetes/app-listener/README.md` for direct in-cluster verification,
621630
shared-member selection, and the HA follow-up checks. Keep the fixture disabled
622-
in default profiles. Shared supervisors expose app ports on their Pod IPs
623-
without a shared app Service. Select the member owning the sandbox; automatic
631+
in default profiles. Dedicated and shared supervisors expose app ports on their
632+
Pod IPs without app Services. Select the member owning the sandbox; automatic
624633
owner selection belongs to the later discovery API.

‎.github/actions/setup-e2e-kind/action.yml‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ inputs:
2929
description: mise release to install
3030
required: false
3131
default: v2026.9.9
32+
enforce-network-policy:
33+
description: Replace kindnet with pinned Calico for NetworkPolicy assertions
34+
required: false
35+
default: "false"
3236

3337
runs:
3438
using: composite
@@ -45,11 +49,44 @@ runs:
4549
REGISTRY_PASSWORD: ${{ inputs.registry-password }}
4650
run: echo "$REGISTRY_PASSWORD" | docker login "${REGISTRY%%/*}" -u "$REGISTRY_USERNAME" --password-stdin
4751

52+
- name: Configure policy-enforcing kind network
53+
id: kind-config
54+
if: inputs.enforce-network-policy == 'true'
55+
shell: bash
56+
run: |
57+
set -euo pipefail
58+
config="$RUNNER_TEMP/kind-network-policy.yaml"
59+
cat > "$config" <<'YAML'
60+
kind: Cluster
61+
apiVersion: kind.x-k8s.io/v1alpha4
62+
networking:
63+
disableDefaultCNI: true
64+
podSubnet: 10.244.0.0/16
65+
YAML
66+
echo "path=$config" >> "$GITHUB_OUTPUT"
67+
4868
- name: Create kind cluster
4969
uses: helm/kind-action@ef37e7f390d99f746eb8b610417061a60e82a6cc # v1.14.0
5070
with:
5171
cluster_name: ${{ inputs.cluster-name }}
52-
wait: 120s
72+
# Nodes cannot become Ready until the following CNI installation.
73+
wait: ${{ inputs.enforce-network-policy == 'true' && '0s' || '120s' }}
74+
config: ${{ steps.kind-config.outputs.path }}
75+
76+
- name: Install policy-enforcing CNI
77+
if: inputs.enforce-network-policy == 'true'
78+
shell: bash
79+
env:
80+
CLUSTER_NAME: ${{ inputs.cluster-name }}
81+
run: |
82+
set -euo pipefail
83+
curl -fsSL https://raw.githubusercontent.com/projectcalico/calico/v3.30.3/manifests/calico.yaml \
84+
-o "$RUNNER_TEMP/calico.yaml"
85+
sed 's@192.168.0.0/16@10.244.0.0/16@g' "$RUNNER_TEMP/calico.yaml" > "$RUNNER_TEMP/calico-kind.yaml"
86+
kubectl --context "kind-$CLUSTER_NAME" apply -f "$RUNNER_TEMP/calico-kind.yaml"
87+
kubectl --context "kind-$CLUSTER_NAME" -n kube-system rollout status daemonset/calico-node --timeout=300s
88+
kubectl --context "kind-$CLUSTER_NAME" -n kube-system rollout status deployment/calico-kube-controllers --timeout=300s
89+
kubectl --context "kind-$CLUSTER_NAME" wait nodes --all --for=condition=Ready --timeout=120s
5390
5491
- name: Export kind kubeconfig to mise path
5592
shell: bash

‎.github/workflows/branch-e2e.yml‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,43 @@ jobs:
463463
agent-sandbox-version: ${{ matrix.agent_sandbox_version }}
464464
test-name: ${{ matrix.test_name }}
465465

466+
kubernetes-app-listener-e2e:
467+
needs: [pr_metadata, build-binaries, build-images]
468+
if: needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_core_e2e == 'true'
469+
strategy:
470+
fail-fast: false
471+
matrix:
472+
include:
473+
- topology: dedicated
474+
delivery: push
475+
takeover: graceful
476+
name: dedicated push
477+
- topology: dedicated
478+
delivery: poll
479+
takeover: graceful
480+
name: dedicated poll
481+
- topology: shared
482+
delivery: push
483+
takeover: graceful
484+
name: shared graceful takeover
485+
- topology: shared
486+
delivery: push
487+
takeover: abrupt
488+
name: shared abrupt takeover
489+
permissions:
490+
actions: read
491+
contents: read
492+
packages: read
493+
uses: ./.github/workflows/e2e-kubernetes-test.yml
494+
with:
495+
image-tag: ${{ github.sha }}
496+
job-name: Kubernetes app listener (${{ matrix.name }})
497+
e2e-task: e2e:kubernetes:app-listener
498+
enforce-network-policy: true
499+
listener-topology: ${{ matrix.topology }}
500+
listener-delivery: ${{ matrix.delivery }}
501+
listener-takeover: ${{ matrix.takeover }}
502+
466503
kubernetes-workspace-managed-e2e:
467504
needs: [pr_metadata, build-binaries, build-images]
468505
if: needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_core_e2e == 'true'
@@ -552,6 +589,7 @@ jobs:
552589
- podman-external-driver-e2e
553590
- vm-external-driver-e2e
554591
- kubernetes-e2e
592+
- kubernetes-app-listener-e2e
555593
- kubernetes-external-driver-e2e
556594
- kubernetes-workspace-managed-e2e
557595
- kubernetes-workspace-operator-e2e

‎.github/workflows/e2e-kubernetes-test.yml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,23 @@ on:
7777
required: false
7878
type: string
7979
default: "gateway sandbox supervisor"
80+
enforce-network-policy:
81+
description: "Install a policy-enforcing CNI for listener isolation checks"
82+
required: false
83+
type: boolean
84+
default: false
85+
listener-topology:
86+
required: false
87+
type: string
88+
default: "dedicated"
89+
listener-delivery:
90+
required: false
91+
type: string
92+
default: "push"
93+
listener-takeover:
94+
required: false
95+
type: string
96+
default: "graceful"
8097

8198
permissions:
8299
actions: read
@@ -129,6 +146,14 @@ jobs:
129146
registry-username: ${{ github.actor }}
130147
registry-password: ${{ secrets.GITHUB_TOKEN }}
131148
mise-version: ${{ inputs.mise-version }}
149+
enforce-network-policy: ${{ inputs.enforce-network-policy }}
150+
151+
- name: Preload listener workload and client fixture
152+
if: inputs.e2e-task == 'e2e:kubernetes:app-listener'
153+
run: |
154+
docker pull --platform linux/amd64 python:3.12-slim
155+
docker image save --platform linux/amd64 --output "$RUNNER_TEMP/listener-python.tar" python:3.12-slim
156+
kind load image-archive "$RUNNER_TEMP/listener-python.tar" --name "$KIND_CLUSTER_NAME"
132157
133158
- name: Run Kubernetes E2E
134159
env:
@@ -142,4 +167,15 @@ jobs:
142167
IMAGE_TAG: ${{ inputs.image-tag }}
143168
OPENSHELL_REGISTRY: ghcr.io/nvidia/openshell
144169
E2E_TASK: ${{ inputs.e2e-task }}
170+
OPENSHELL_E2E_APP_TOPOLOGY: ${{ inputs.listener-topology }}
171+
OPENSHELL_E2E_APP_DELIVERY: ${{ inputs.listener-delivery }}
172+
OPENSHELL_E2E_APP_TAKEOVER: ${{ inputs.listener-takeover }}
145173
run: mise run --no-deps --skip-deps "$E2E_TASK"
174+
175+
- name: Upload listener test evidence
176+
if: always() && inputs.e2e-task == 'e2e:kubernetes:app-listener'
177+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
178+
with:
179+
name: listener-${{ inputs.listener-topology }}-${{ inputs.listener-delivery }}-${{ inputs.listener-takeover }}
180+
path: results/app-listener/
181+
if-no-files-found: warn

‎e2e/kubernetes/app-listener/README.md‎

Lines changed: 105 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,101 @@ images. This fixture exercises the listener without discovery or the reference
55
proxy. The opt-in Helm values are
66
`deploy/helm/openshell/ci/values-app-listener.yaml`.
77

8+
## Repeatable local checks
9+
10+
The local and CI entry point creates an isolated Helm release, temporary TLS
11+
Secret and client resources, runs the checks, and removes the release/namespace:
12+
13+
```shell
14+
KUBECONFIG="$PWD/kubeconfig" \
15+
IMAGE_TAG=dev OPENSHELL_REGISTRY=openshell \
16+
OPENSHELL_E2E_APP_TOPOLOGY=shared \
17+
OPENSHELL_E2E_APP_TAKEOVER=abrupt \
18+
mise run e2e:kubernetes:app-listener
19+
```
20+
21+
Build and import matching `openshell/gateway:dev`, `openshell/supervisor:dev`,
22+
and `openshell/sandbox:dev` images first, or set the registry/tag to images
23+
already loaded into the cluster. Build the CLI or set `OPENSHELL_BIN` to it.
24+
Set `OPENSHELL_E2E_KUBE_CONTEXT` to select a context explicitly. The cluster must
25+
enforce NetworkPolicy; the local k3s default does. The task installs the pinned
26+
Agent Sandbox controller only when its CRD is absent.
27+
Set `OPENSHELL_E2E_KUBECONFIG` when testing a separate cluster whose kubeconfig
28+
differs from the repository's mise environment.
29+
30+
`OPENSHELL_E2E_APP_TOPOLOGY` accepts `dedicated` (default) or `shared`;
31+
`OPENSHELL_E2E_APP_DELIVERY` accepts `push` (default) or `poll`;
32+
`OPENSHELL_E2E_APP_TAKEOVER` accepts `graceful` (default) or `abrupt` for shared
33+
supervisors. Dedicated runs include gateway-outage expiry. Every run also
34+
disables the listener and verifies absent app sockets/TLS mounts/Services and
35+
continued gateway application ingress. Logs, events, and resource summaries
36+
are written under `results/app-listener/`, without TLS private keys or Secrets.
37+
38+
GitHub Actions runs four matrix cases under the existing `test:e2e` label:
39+
dedicated push/poll and shared graceful/abrupt takeover. These jobs use the
40+
reusable Kubernetes workflow, with kindnet replaced by pinned Calico for policy
41+
enforcement, and participate in `Core E2E result`. CI uploads the evidence even
42+
on failure. They still require the normal current-head `/ok to test <SHA>`
43+
approval mirror.
44+
45+
### Checking an already deployed release
46+
47+
Build the gateway, supervisor, sandbox, and CLI from the branch under test and
48+
deploy them through the local Helm development workflow. Use an isolated release
49+
namespace with gateway TLS, unauthenticated development API access, and the app
50+
listener enabled. Provide the application TLS Secret before installing the
51+
release. The workload and client fixture use `python:3.12-slim`.
52+
53+
Run from the repository root, supplying the public application certificate/CA:
54+
55+
```shell
56+
KUBECONFIG="$PWD/kubeconfig" uv run --no-project python \
57+
e2e/kubernetes/app-listener/verify.py \
58+
--namespace listener-review-shared \
59+
--gateway-endpoint https://localhost:29203 \
60+
--forward-gateway service/listener-review \
61+
--app-ca /path/to/app-ca.crt \
62+
--network-policy \
63+
--takeover graceful
64+
```
65+
66+
Use the actual namespace and gateway Service name of the test release. The
67+
runner maintains its API port-forward across gateway restarts; application
68+
traffic originates in client Pods and uses cluster networking. Application TLS
69+
verifies the supplied CA and hostname. The development API connection uses
70+
`--gateway-insecure` with an isolated temporary CLI configuration.
71+
72+
The runner creates and cleans up its sandboxes, client Pods, public-CA ConfigMap,
73+
and ingress policies. It checks named/unnamed HTTP routes, public Host/Origin and
74+
cookies, credential stripping and explicit bearer passthrough, unknown routes,
75+
Host/SNI mismatch, quiet WebSockets beyond 30 seconds, selective withdrawal, and
76+
re-exposure without restarting the application. Both topologies use supervisor
77+
Pod IPs and verify that no per-sandbox app Services are created.
78+
79+
`--network-policy` requires an enforcing cluster network implementation, such as
80+
the local k3s default. A default kind cluster needs a policy-enforcing CNI before
81+
this assertion can establish isolation.
82+
83+
For a two-member shared pool, `--takeover graceful` deletes the owning Pod and
84+
checks that its sandbox keeps its Pod UID, runtime generation, process, and
85+
in-memory state, while another owner's WebSocket survives. `--takeover abrupt`
86+
first SIGKILLs the supervisor container through the local k3d/kind node's Docker
87+
container, preventing a graceful leave; it requires access to that Docker engine.
88+
These options deliberately interrupt test resources in the supplied namespace.
89+
90+
For dedicated topology, omit `--takeover`. Add
91+
`--expire-gateway statefulset/listener-review` (using the actual workload name)
92+
to scale the isolated gateway to zero, verify route/stream expiry, restore its
93+
original replica count, and check application survival. Repeat with gateway
94+
`config_delivery_mode` set to `push` and `poll`.
95+
96+
The lower-level runner leaves the Helm release and TLS Secret in place. Use
97+
`--disabled --gateway-service <service>` instead of takeover/expiry flags to
98+
check an already disabled release. Configuration rejection and the additional
99+
deployment cleanup scenarios remain in the manual checklist below.
100+
101+
## Manual deployment and additional scenarios
102+
8103
Before deployment, provide an operator-owned `openshell-app-tls` Secret in the
9104
supervisor namespace with `tls.crt` and `tls.key` for
10105
`*.services.example.com`. Keep private keys outside the checkout. Allow a labeled
@@ -20,12 +115,12 @@ this stage. Use these direct-listener hostnames instead:
20115
- `default--<sandbox>.services.example.com` for the unnamed service.
21116
- `default--<sandbox>--web.services.example.com` for the named service.
22117

23-
Inspect supervisor Pods. Dedicated supervisors optionally expose
24-
`os-app-<sandbox-id>`; inspect that Service's EndpointSlices. Shared supervisors
25-
have no app Service: select the Pod IP actually owning the sandbox and use its
26-
configured app port. Do not select an arbitrary member when more than one is
27-
present. Check ownership through supervisor admission/release logs in this
28-
stage; automated owner selection belongs to the later discovery API.
118+
Inspect supervisor Pods. Both dedicated and shared supervisors expose the
119+
listener directly on their Pod IPs without app Services. Select the Pod IP
120+
actually owning the sandbox and use its configured app port. Do not select an
121+
arbitrary member when more than one is present. Check ownership through
122+
supervisor admission/release logs in this stage; automated owner selection
123+
belongs to the later discovery API.
29124

30125
From a permitted client Pod, mount only the public app certificate/CA and run:
31126

@@ -35,9 +130,8 @@ curl --cacert /test/app-ca.crt \
35130
https://default--demo--web.services.example.com/
36131
```
37132

38-
For a dedicated supervisor, repeat using its headless Service DNS name instead
39-
of the Pod IP. Verify both paths through ordinary cluster networking. A
40-
port-forward alone does not verify Service selection or NetworkPolicy.
133+
Verify this path through ordinary cluster networking. A port-forward alone does
134+
not verify NetworkPolicy.
41135

42136
Verify HTTP and WebSockets, public Host/Origin, application session cookies,
43137
unknown SNI, mismatched Host, undeclared services, bearer stripping/passthrough,
@@ -53,17 +147,9 @@ the remaining freshness lease once session loss is detected.
53147

54148
Run with listener configuration omitted, explicitly disabled despite complete
55149
TLS/port options, and explicitly enabled. Disabled deployments have no app port,
56-
TLS mount, or app Service. Retain the dedicated driver `create_service` option
57-
while disabling and recreating a sandbox to verify cleanup of its previously
58-
owned endpoint. Confirm gateway ingress still works in each mode.
59-
60-
Dedicated endpoint reconciliation runs more than once during creation. Verify
61-
that it accepts its own non-controller Sandbox owner reference and has Service
62-
`patch`/`delete` permissions when `create_service` is configured. Foreign-owned
63-
Services must be left untouched, and cleanup uses UID/resource-version
64-
preconditions.
150+
TLS mount, or app Service. Confirm gateway ingress still works in each mode.
65151

66-
For HA pool validation after integration with #4864, use at least two supervisor
152+
For HA pool validation, use at least two supervisor
67153
members with distinct sandbox owners. Move one owner through graceful downscale
68154
and abrupt loss. Existing streams may disconnect; after selecting the new owner,
69155
new HTTP/WebSocket connections must work without restarting the workload.

0 commit comments

Comments
 (0)