Skip to content

Commit 2ec71d4

Browse files
committed
ci(e2e): run HA operations with HTTPS gateway peers
Signed-off-by: Emilien Macchi <emacchi@redhat.com>
1 parent 101b655 commit 2ec71d4

6 files changed

Lines changed: 117 additions & 3 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ KUBECONFIG=kubeconfig helm upgrade openshell deploy/helm/openshell \
296296

297297
Use the IP that pods in that cluster use to reach listeners on the test host.
298298

299+
Use `mise run e2e:kubernetes:ha-tls` for the TLS HA lane. It layers
300+
`ci/values-high-availability-tls.yaml` so gateway pods serve TLS and mTLS and
301+
route peers over HTTPS with the chart CA, skips Envoy, registers an mTLS CLI
302+
gateway over the Service port-forward (`OPENSHELL_E2E_KUBE_POD_TLS=1`), and
303+
runs only `kubernetes_ha_operations`: one sandbox kept across scale-up,
304+
scale-down, graceful and forced owner loss, and a rolling restart, with each
305+
HA-tested operation class driven through non-owner replicas.
306+
299307
### BackendTLSPolicy (end-to-end TLS)
300308

301309
To enable end-to-end TLS between the Gateway proxy and the gateway pod, add

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,20 @@ jobs:
461461
e2e-task: e2e:kubernetes:credential-drivers
462462
conformance-artifact-prefix: openshell-conformance
463463

464+
kubernetes-ha-tls-e2e:
465+
needs: [pr_metadata, build-binaries, build-images]
466+
if: needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_kubernetes_ha_e2e == 'true'
467+
permissions:
468+
actions: read
469+
contents: read
470+
packages: read
471+
uses: ./.github/workflows/e2e-kubernetes-test.yml
472+
with:
473+
image-tag: ${{ github.sha }}
474+
job-name: Kubernetes HA E2E (TLS peers, operation inventory)
475+
e2e-task: e2e:kubernetes:ha-tls
476+
conformance-artifact-prefix: openshell-conformance
477+
464478
core-e2e-result:
465479
name: Core E2E result
466480
needs:
@@ -503,7 +517,7 @@ jobs:
503517

504518
kubernetes-ha-e2e-result:
505519
name: Kubernetes HA E2E result
506-
needs: [pr_metadata, kubernetes-ha-e2e]
520+
needs: [pr_metadata, kubernetes-ha-e2e, kubernetes-ha-tls-e2e]
507521
if: always() && needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_kubernetes_ha_e2e == 'true'
508522
runs-on: ubuntu-latest
509523
steps:

‎CI.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ Three opt-in labels enable the long-running E2E suites:
2929
with both managed and standalone compute drivers in `Branch E2E Checks`
3030
- `test:e2e-gpu` runs GPU E2E in `Branch E2E Checks`
3131
- `test:e2e-kubernetes` runs Kubernetes E2E with the HA Helm overlay
32-
(`replicaCount: 2` and bundled PostgreSQL) and the credential-driver suite
33-
(Kubernetes Secrets plus Vault) in `Branch E2E Checks`
32+
(`replicaCount: 2` and an external PostgreSQL fixture) in two lanes, plaintext
33+
pods behind Envoy (HA rebalancing tests) and TLS pods with HTTPS peer routing
34+
(HA operation inventory), plus the credential-driver suite (Kubernetes Secrets
35+
plus Vault) in `Branch E2E Checks`
3436

3537
When multiple labels are present, `Branch E2E Checks` builds each generic multi-architecture artifact set once and fans out enabled suites in parallel. Runtime-specific reusable workflows define the Docker, Podman, VM, and Kubernetes lanes. Composite actions own the replaceable Podman, KVM, kind, and mise setup. Each lane depends only on the artifact categories it consumes: VM does not wait for container-driver artifacts or supervisor images, and GPU does not wait for the gateway image. Docker, Podman, GPU, Rust, Python, MCP, and VM E2E reuse matching prebuilt gateway and CLI binaries instead of compiling debug binaries in test jobs. Standalone-driver lanes additionally reuse driver-free gateway and compute-driver artifacts. Kubernetes managed-driver lanes consume published gateway and supervisor images, while the standalone-driver lane composes its gateway image from prebuilt binaries.
3638
The `OpenShell / E2E` and `OpenShell / GPU E2E` required statuses are evaluated from separate suite result jobs inside that workflow. `test:e2e-kubernetes` is optional while Kubernetes HA and credential-driver behavior are under active iteration: failures are visible in the workflow run but do not publish a required CI gate status.

‎TESTING.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ Available task variants:
434434
| `e2e:kubernetes:workspace-operator` | Operator workspace mode (pre-provisioned namespaces) |
435435
| `e2e:kubernetes:v1alpha1` | Agent Sandbox v1alpha1 compatibility |
436436
| `e2e:kubernetes:external-driver` | External Kubernetes driver sidecar |
437+
| `e2e:kubernetes:ha-tls` | Two TLS and mTLS gateway replicas with HTTPS peer routing and external PostgreSQL: one sandbox kept across scale-up, scale-down, graceful and forced owner loss, and a rolling restart, with non-interactive and streamed-stdin exec, file transfer, TCP forwarding, policy updates, and provider attachment status through non-owner replicas |
437438

438439
Kubernetes e2e environment variables:
439440

@@ -448,6 +449,8 @@ Kubernetes e2e environment variables:
448449
| `GATEWAY_IMAGE` | Kubernetes gateway image repository or complete tagged/digest-pinned image reference; digests require `OPENSHELL_E2E_KUBE_BUILD_IMAGES=0` |
449450
| `SUPERVISOR_IMAGE` | Gateway/supervisor image repository or complete tagged/digest-pinned image reference; Kubernetes digests require `OPENSHELL_E2E_KUBE_BUILD_IMAGES=0` |
450451
| `SANDBOX_IMAGE` | Trusted sandbox runtime image repository or complete tagged/digest-pinned image reference |
452+
| `OPENSHELL_E2E_KUBE_POD_TLS` | Set to `1` when the extra values make the gateway pods serve TLS; the harness registers an mTLS CLI gateway over the Service port-forward. Not supported with Envoy or the database scenarios |
453+
| `OPENSHELL_E2E_KUBE_HA_OPS_BUDGET_SECS` | Overall budget in seconds for `kubernetes_ha_operations`; default `1020` |
451454

452455
Run a single test directly with cargo:
453456

‎e2e/with-kube-gateway.sh‎

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
# files, relative to the repository root or absolute, to layer additional chart
3333
# configuration on top of ci/values-skaffold.yaml.
3434
#
35+
# Set OPENSHELL_E2E_KUBE_POD_TLS=1 when the extra values turn gateway pod TLS
36+
# back on (for example ci/values-high-availability-tls.yaml). The harness then
37+
# port-forwards the gateway Service as usual but registers an mTLS CLI gateway
38+
# at https://localhost:<port> with the chart's openshell-client-tls material.
39+
# Envoy and the database scenarios still assume plaintext pods, so this mode
40+
# rejects them.
41+
#
3542
# Image source:
3643
# - Ephemeral k3d mode builds local
3744
# `openshell/{gateway,sandbox,supervisor}:${IMAGE_TAG}`
@@ -126,6 +133,8 @@ OPENSHIFT_ROUTE_HOST=""
126133
# Temp dir holding the client mTLS material extracted from openshell-client-tls
127134
# for the OpenShift Route transport. Removed by cleanup().
128135
OPENSHIFT_PKI_DIR="${WORKDIR}/openshift-pki"
136+
# Client mTLS material for OPENSHELL_E2E_KUBE_POD_TLS=1. Removed with WORKDIR.
137+
POD_TLS_PKI_DIR="${WORKDIR}/pod-tls-pki"
129138

130139
# Isolate CLI/SDK gateway metadata from the developer's real config.
131140
export XDG_CONFIG_HOME="${WORKDIR}/config"
@@ -825,6 +834,68 @@ openshift_register_route_gateway() {
825834
"${pki_dir}"
826835
}
827836

837+
use_pod_tls() {
838+
case "${OPENSHELL_E2E_KUBE_POD_TLS:-0}" in
839+
1 | true | TRUE | yes | YES) return 0 ;;
840+
*) return 1 ;;
841+
esac
842+
}
843+
844+
# OPENSHELL_E2E_KUBE_POD_TLS=1 only: port-forward the gateway Service, wait for
845+
# an mTLS handshake with the chart's client material, and register an mTLS CLI
846+
# gateway at https://localhost:<port>. localhost is a server SAN in both chart
847+
# PKI modes. Sets LOCAL_PORT, PORTFORWARD_PID, GATEWAY_NAME, GATEWAY_ENDPOINT.
848+
kube_register_pod_tls_gateway() {
849+
local pki_dir="${POD_TLS_PKI_DIR}"
850+
local elapsed=0 timeout=60
851+
852+
rm -rf "${pki_dir}"
853+
mkdir -p "${pki_dir}/client"
854+
kctl -n "${NAMESPACE}" get secret openshell-client-tls \
855+
-o jsonpath='{.data.ca\.crt}' | base64 -d >"${pki_dir}/ca.crt"
856+
kctl -n "${NAMESPACE}" get secret openshell-client-tls \
857+
-o jsonpath='{.data.tls\.crt}' | base64 -d >"${pki_dir}/client/tls.crt"
858+
kctl -n "${NAMESPACE}" get secret openshell-client-tls \
859+
-o jsonpath='{.data.tls\.key}' | base64 -d >"${pki_dir}/client/tls.key"
860+
861+
LOCAL_PORT="$(e2e_pick_port)"
862+
echo "Starting kubectl port-forward svc/${RELEASE_NAME} ${LOCAL_PORT}:8080 (pod TLS)..."
863+
kctl -n "${NAMESPACE}" port-forward "svc/${RELEASE_NAME}" \
864+
"${LOCAL_PORT}:8080" >"${PORTFORWARD_LOG}" 2>&1 &
865+
PORTFORWARD_PID=$!
866+
867+
while [ "${elapsed}" -lt "${timeout}" ]; do
868+
if ! kill -0 "${PORTFORWARD_PID}" 2>/dev/null; then
869+
echo "ERROR: kubectl port-forward exited before becoming reachable" >&2
870+
cat "${PORTFORWARD_LOG}" >&2 || true
871+
return 1
872+
fi
873+
if curl -s -o /dev/null --max-time 5 \
874+
--cacert "${pki_dir}/ca.crt" \
875+
--cert "${pki_dir}/client/tls.crt" \
876+
--key "${pki_dir}/client/tls.key" \
877+
"https://localhost:${LOCAL_PORT}/"; then
878+
break
879+
fi
880+
sleep 1
881+
elapsed=$((elapsed + 1))
882+
done
883+
if [ "${elapsed}" -ge "${timeout}" ]; then
884+
echo "ERROR: gateway did not complete an mTLS handshake on https://localhost:${LOCAL_PORT} within ${timeout}s" >&2
885+
cat "${PORTFORWARD_LOG}" >&2 || true
886+
return 1
887+
fi
888+
889+
GATEWAY_NAME="openshell-e2e-kube-${LOCAL_PORT}"
890+
GATEWAY_ENDPOINT="https://localhost:${LOCAL_PORT}"
891+
e2e_register_mtls_gateway \
892+
"${XDG_CONFIG_HOME}" \
893+
"${GATEWAY_NAME}" \
894+
"${GATEWAY_ENDPOINT}" \
895+
"${LOCAL_PORT}" \
896+
"${pki_dir}"
897+
}
898+
828899
# Start `kubectl port-forward svc/openshell` for the gRPC endpoint and wait for
829900
# it to accept TCP. Sets LOCAL_PORT and PORTFORWARD_PID. Prints the port-forward
830901
# log and returns non-zero on failure. Used for the vanilla-Kubernetes transport
@@ -891,6 +962,13 @@ require_cmd helm
891962
require_cmd kubectl
892963
require_cmd curl
893964

965+
if use_pod_tls; then
966+
if use_envoy_gateway || [ "${OPENSHELL_E2E_KUBE_DB_SCENARIOS:-0}" = "1" ]; then
967+
echo "ERROR: OPENSHELL_E2E_KUBE_POD_TLS=1 does not support Envoy or the database scenarios" >&2
968+
exit 2
969+
fi
970+
fi
971+
894972
if [ -n "${OPENSHELL_E2E_KUBE_CONTEXT:-}" ]; then
895973
KUBE_CONTEXT="${OPENSHELL_E2E_KUBE_CONTEXT}"
896974
echo "Using existing kubectl context: ${KUBE_CONTEXT}"
@@ -1407,6 +1485,9 @@ else
14071485
# OpenShift: reach the gateway over the passthrough Route with mTLS so the
14081486
# SSH-relay `sandbox connect` suites work (port-forward stalls them).
14091487
openshift_register_route_gateway || exit 1
1488+
elif use_pod_tls; then
1489+
# Vanilla Kubernetes with pod TLS: mTLS over the Service port-forward.
1490+
kube_register_pod_tls_gateway || exit 1
14101491
else
14111492
# Vanilla Kubernetes: reach the gateway in plaintext over port-forward.
14121493
start_gateway_portforward || exit 1

‎tasks/test.toml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ env = { OPENSHELL_E2E_KUBE_EXTRA_VALUES = "deploy/helm/openshell/ci/values-works
252252
depends = ["e2e:conformance:build"]
253253
run = "OPENSHELL_CONFORMANCE_BIN=\"${OPENSHELL_CONFORMANCE_BIN:-$PWD/target/debug/openshell-conformance}\" e2e/rust/e2e-kubernetes.sh"
254254

255+
["e2e:kubernetes:ha-tls"]
256+
description = "Run the Kubernetes HA operation inventory against two gateway replicas that serve TLS and mTLS, route peers over HTTPS, and use external PostgreSQL"
257+
env = { OPENSHELL_E2E_KUBE_EXTERNAL_POSTGRES_SECRET = "openshell-ha-pg", OPENSHELL_E2E_KUBE_EXTRA_VALUES = "deploy/helm/openshell/ci/values-high-availability.yaml:deploy/helm/openshell/ci/values-high-availability-tls.yaml", OPENSHELL_E2E_KUBE_POD_TLS = "1", OPENSHELL_E2E_KUBE_USE_ENVOY = "0", OPENSHELL_E2E_KUBE_TEST = "kubernetes_ha_operations", OPENSHELL_E2E_KUBERNETES_FEATURES = "e2e,e2e-host-gateway,e2e-kubernetes,e2e-kubernetes-ha" }
258+
depends = ["e2e:conformance:build"]
259+
run = "OPENSHELL_CONFORMANCE_BIN=\"${OPENSHELL_CONFORMANCE_BIN:-$PWD/target/debug/openshell-conformance}\" e2e/rust/e2e-kubernetes.sh"
260+
255261
["e2e:vm"]
256262
description = "Start openshell-gateway with the VM compute driver and run VM e2e tests"
257263
depends = ["e2e:conformance:build"]

0 commit comments

Comments
 (0)