Skip to content

Latest commit

 

History

History
1110 lines (883 loc) · 52.7 KB

DEVELOPMENT.md

File metadata and controls

1110 lines (883 loc) · 52.7 KB

Local Development Environment

HyperShell deploys the same stack (API server, control plane, web console, Keycloak) on Kind or on an existing OpenShift cluster. Targets follow the same shape: make kind-<name> or make openshift-<name>. Kind creates a local cluster. OpenShift never creates a cluster; it deploys into the oc project you select.

Contents

Prerequisites

Tool Purpose Install
Docker or Podman Container engine OS package manager
Kind Local Kubernetes clusters (Kind path) brew install kind
kubectl Kubernetes CLI (Kind path) brew install kubectl
oc OpenShift CLI (OpenShift path) install oc
cloud-provider-kind LoadBalancer + Gateway API for Kind brew install cloud-provider-kind

The container engine is auto-detected (Podman preferred). Override with CONTAINER_ENGINE=docker or CONTAINER_ENGINE=podman.

Kind Development

Kind (Kubernetes in Docker) is the default single-tenant path. make kind-up creates the cluster and deploys every platform component so you can test changes end to end.

Quickstart

make kind-up

This creates a Kind cluster and deploys:

  1. Gateway API CRDs (experimental channel, includes BackendTLSPolicy)
  2. cloud-provider-kind (LoadBalancer + Gateway API controller)
  3. cert-manager (TLS certificate lifecycle)
  4. Keycloak (OIDC identity provider)
  5. Networking Gateway with wildcard TLS certificates
  6. HTTPRoutes for all services
  7. API server (with DB migration init container)
  8. Control plane (gRPC watcher + reconciler, provisions PostgreSQL)
  9. Web console (Node.js BFF + React SPA)

Expected Output

=== HyperShell is running! ===

  HTTP API:      https://api.hypershell.localhost
  Web Console:   https://console.hypershell.localhost
  Health:        https://health.hypershell.localhost
  Keycloak:      https://keycloak.hypershell.localhost (admin/admin)
  OIDC Issuer:   https://keycloak.hypershell.localhost/realms/hypershell

Services are accessed via .localhost hostnames routed through the networking Gateway. CoreDNS resolves all *.hypershell.localhost to loopback, and OS-level port forwarding (pfctl on macOS, iptables on Linux) redirects host port 443 to cloud-provider-kind's ephemeral Gateway port. The TLS certificate is self-signed -- trust it in your browser or use curl --cacert.

Kind make targets

make kind-up is idempotent: running it again on an existing cluster reapplies manifests and waits for readiness. Swapped components are preserved.

Target Use
make kind-up Create the Kind cluster, install prerequisites, deploy the stack, seed sample resources, and wait until ready.
make kind-down Remove the hypershell-system namespace and its resources. Leaves the Kind cluster running.
make kind-teardown Destroy the Kind cluster and stop cloud-provider-kind.
make kind-status Show cluster info, pods, services, and which components are swapped.
make kind-seed Re-run Gateway seeding. The local-kind ManagedCluster is not seeded: the control plane registers it itself, and seeding waits for that record (SEED_CLUSTER_WAIT_SECONDS, default 240) and uses its id. Reuses the existing named seed resource (dev-gateway) instead of creating duplicates. kind-up already seeds unless SKIP_SEED=true.
make kind-prereqs Build the pinned cloud-provider-kind binary into bin/. kind-up runs this; use it alone when the binary is missing.
make kind-env Print export statements for the current Kind make variables.
make kind-fix-ports Re-establish host port 443 forwarding to the Gateway's ephemeral port.
make kind-gateway-trust Write the cluster CA to bin/hypershell-ca.crt and print export SSL_CERT_FILE=... for the openshell CLI. Run eval "$(make kind-gateway-trust)".
make kind-openshell ARGS="-g <name> ..." Run the openshell CLI in a container on Kind's own podman network instead of installing it on the host. Needed when the deployed gateway's build has no native CLI release to install (a downstream image tag, e.g. v0.0.116-rhaiv.6) - the matching CLI is Linux-only, so this is the way to use it from macOS. <name> must already be a registered gateway (~/.config/openshell/gateways/<name>/).
make kind-grpc-tls-smoke Enable gRPC TLS on the Kind api-server with a cluster-CA certificate, point the controller at it through an external-looking name, and verify the TLS dial end to end (certificate chain, h2, plaintext refused, registration and gateway watch over TLS). Reverts to plaintext afterwards; KEEP=true keeps TLS on and ARGS=revert restores plaintext.
make kind-api-server-up Build the API server from the working tree and swap it into the cluster.
make kind-api-server-down Revert the API server to the baseline registry image.
make kind-control-plane-up Build the control plane from the working tree and swap it into the cluster.
make kind-control-plane-down Revert the control plane to the baseline registry image.
make kind-web-console-up Hot-reload the web console (default), or build and swap a full image when KIND_HOT_RELOAD=false.
make kind-web-console-down Revert the web console to the baseline registry image.

Per-component swap

Baseline images are pulled from the container registry. To build all baseline images locally instead (e.g. when registry access is unavailable), run:

LOCAL_IMAGES=true make kind-up

To test local changes, swap individual components:

# Build and deploy API server from working tree
make kind-api-server-up

# Build and deploy control plane from working tree
make kind-control-plane-up

# Start web console with hot reload (default)
make kind-web-console-up

# Start web console with full image rebuild
KIND_HOT_RELOAD=false make kind-web-console-up

The web console uses hot reload by default - kind-web-console-up starts a local Vite dev server and proxies through the cluster. Use KIND_HOT_RELOAD=false to build and deploy a full container image instead. API server and control plane rebuilds replace the running deployment; re-run after making changes to pick them up.

Revert to Baseline

make kind-api-server-down
make kind-control-plane-down
make kind-web-console-down

Reverts the component to the registry baseline image. No-op if the component is already running the baseline.

Swap Status

make kind-status

Shows which components are running local builds vs. baseline images. Swap state is tracked in .kind-swaps (gitignored).

Hot reload

The web console supports hot reload by default. When you run make kind-web-console-up, the host source directory is mounted into the container and npm run dev runs in development mode. File changes on the host are reflected immediately without rebuilding.

To disable hot reload and use a full image rebuild instead:

KIND_HOT_RELOAD=false make kind-web-console-up

Hot reload is only supported for the web console. The API server and control plane are Go services that require a full rebuild (make kind-api-server-up / make kind-control-plane-up).

Keycloak

The local Keycloak instance mirrors the downstream Keycloak topology used in production.

Setting Value
Realm hypershell
Frontend client hypershell-frontend (public, standard flow + direct access grants)
CLI client hypershell-cli (public, standard flow + device authorization grant, used by hsctl login)
Provisioner client hypershell-provisioner (confidential, service account)
Control plane client hypershell-control-plane (confidential, service account, client_credentials)
Admin user admin / admin (roles: hypershell-admins, platform:admin, gateway:creator)
Developer user developer / developer (role: hypershell-users)
OIDC Issuer URL https://keycloak.hypershell.localhost/realms/hypershell
Admin Console https://keycloak.hypershell.localhost/admin/

Dashboard-operator access (operational dashboard, user inventory, managed inventory metrics) requires the platform:admin Keycloak realm role, which is JWT-synced to a platform:admin RoleBinding. The legacy hypershell-admins group alone does not grant dashboard access.

OIDC

Keycloak is configured with KC_HOSTNAME=https://keycloak.hypershell.localhost, which pins the OIDC issuer and all frontend URLs to HTTPS on port 443 -- matching production's issuer form. Keycloak itself stays plain HTTP internally (KC_HTTP_PORT=8080, KC_PROXY_HEADERS=xforwarded); the networking Gateway terminates TLS on its *.hypershell.localhost :443 listener with the cert-manager cert and forwards to keycloak-service:8080. The same OIDC issuer URL works from both the host browser and in-cluster pods: cluster CoreDNS is patched to resolve *.hypershell.localhost (including keycloak) to the Gateway LB IP, so pods reach the issuer through the same HTTPS listener. Gateway pods trust the self-signed CA via the gateway-trusted-ca ConfigMap (SSL_CERT_FILE), which make kind-up publishes from the hypershell-https-tls secret.

The control plane authenticates to the API server's gRPC endpoint using its own Keycloak service account (hypershell-control-plane client, confidential, client_credentials grant). make kind-up creates a hypershell-cp-oidc secret and patches the control plane deployment with OIDC_ISSUER, OIDC_CLIENT_ID, and OIDC_CLIENT_SECRET. When swapped locally, export those variables in your shell before running the control plane binary.

Port forwarding (pfctl/iptables) maps host port 443 to the Gateway's ephemeral HTTPS port. If port forwarding is not active (e.g. after a cluster restart), re-establish it with:

make kind-fix-ports

Verify the OIDC discovery endpoint (the cert is self-signed, hence --cacert or -k):

curl --cacert <(kubectl --context kind-hypershell-dev get secret hypershell-https-tls \
  -n hypershell-system -o go-template='{{index .data "ca.crt" | base64decode}}') \
  https://keycloak.hypershell.localhost/realms/hypershell/.well-known/openid-configuration

External Keycloak

To test against a shared downstream Keycloak instead of the local instance:

KIND_KEYCLOAK_URL=https://keycloak.example.com/realms/hypershell make kind-up

This skips the local Keycloak deployment and points the gateway OIDC issuer at the external URL.

OIDC authentication

The Kind cluster runs with OIDC authentication enabled. Keycloak is deployed as the identity provider and all components are configured for JWT validation and session management during make kind-up.

Browser login flow

  1. Navigate to https://console.hypershell.localhost
  2. The BFF redirects to https://console.hypershell.localhost/auth/login
  3. The login page redirects to Keycloak for authentication
  4. Sign in with admin/admin or developer/developer
  5. Keycloak redirects back to the web console with a valid session

hsctl login (management API)

Build the CLI with make build-cli (it regenerates the generated commands first, so it always matches the OpenAPI description), then authenticate against the Kind cluster:

./components/cli/hsctl login \
  --url https://api.hypershell.localhost/api/hypershell/v1 \
  --insecure

The API advertises its configured public issuer at /api/hypershell/v1/auth/config, so no issuer flag is needed. Use the direct API host, not the web console's browser-session proxy. For example, hyp2 uses:

hsctl login --url https://api.hyp2.infra.hypershell.app/api/hypershell/v1

Server-root URLs also work. Older API deployments without discovery still need --issuer-url https://keycloak.<instance>.infra.hypershell.app/realms/hypershell; --token-file remains available for existing bearer tokens.

For headless environments, add --no-browser to use the device authorization flow. The CLI stores tokens in ~/.config/hypershell/config.json (or ~/.hypershell.json if that legacy path already exists) and uses the hypershell-cli Keycloak client.

Check identity with hsctl whoami and log out with hsctl logout.

Run ./components/cli/hsctl tui for an interactive terminal view of every API resource that refreshes in place. Press ? inside it for key bindings. See CLI and Terminal UI for how it is generated.

Hot reload and OIDC

Web console hot reload (make kind-web-console-up) runs the Vite dev server directly on the host for fast iteration. This mode does not start the BFF, so OIDC authentication is unavailable during hot reload. Use the image-based swap when testing OIDC:

KIND_HOT_RELOAD=false make kind-web-console-up

CLI token acquisition for curl testing

Obtain an access token via Keycloak's direct access grants:

TOKEN=$(curl -sk -X POST \
  "https://keycloak.hypershell.localhost/realms/hypershell/protocol/openid-connect/token" \
  -d "grant_type=password" \
  -d "client_id=hypershell-frontend" \
  -d "username=admin" \
  -d "password=admin" | python3 -c "import json,sys; print(json.load(sys.stdin)['access_token'])")

curl -s -H "Authorization: Bearer ${TOKEN}" \
  https://api.hypershell.localhost/api/hypershell/v1/gateways

Private registry pull secret

If your baseline images live in a private registry, provide a pull secret:

PULL_SECRET=/path/to/pull-secret.yaml make kind-up

KIND_PULL_SECRET is still accepted as an alias. The YAML file is applied into the target namespace with kubectl apply. It should contain a kubernetes.io/dockerconfigjson Secret. OpenShift component swaps use the same file to log the container engine into SWAP_REGISTRY.

Offline development

Build all component images from the local working tree instead of pulling from the container registry:

LOCAL_IMAGES=true make kind-up

This builds api-server, control-plane, and web-console images locally and loads them into Kind. The Dockerfiles drop the local rh-trex-ai replace directive at build time, so no external dependency checkout is needed.

Controller image OpenShell release label

Every built controller (control-plane) image carries one label, app.hypershell.openshell.version, naming the single OpenShell gateway and supervisor release that build supports (for example v0.1.8-rhaiv.0). The value always holds exactly one release identifier - never a list, range, or wildcard. It is distinct from org.opencontainers.image.version, which is the controller's own version.

The value is sourced from OPENSHELL_TAG in OPENSHELL_VERSION (the same source the deployment manifests use). make build-controller reads it straight from the file, and make sync-openshell-version stamps it into the Konflux pipeline build args, so OPENSHELL_VERSION stays the single source of truth. make check-openshell-version fails if the label value drifts or is missing.

Read the value from a built image configuration (not the Dockerfile) with any container tool, for example:

# Locally built image
podman inspect --format '{{ index .Config.Labels "app.hypershell.openshell.version" }}' \
  localhost/hypershell-controller:dev

# Published multi-arch image
skopeo inspect --config docker://<controller-image-ref> \
  | jq -r '.config.Labels["app.hypershell.openshell.version"]'

To validate a published image's label across every architecture variant against OPENSHELL_TAG, run:

make check-controller-image-label IMAGE=<controller-image-ref>

Kind environment variables

Variable Default Description
KIND_CLUSTER_NAME hypershell-dev Kind cluster name
KIND_NAMESPACE hypershell-system Target namespace for swap and teardown
KIND_HOT_RELOAD true Hot reload for the web console
KIND_HOST_MOUNT_PATH Repository root Host directory mounted into Kind nodes
KIND_KEYCLOAK_URL (unset) External Keycloak URL; skips local deploy
KEYCLOAK_OIDC_ISSUER https://keycloak.hypershell.localhost/realms/hypershell OIDC issuer URL
PULL_SECRET (unset) Path to a kubernetes.io/dockerconfigjson Secret YAML for private registries. Used by Kind kind-up and OpenShift swaps.
KIND_PULL_SECRET (unset) Alias for PULL_SECRET.
IMAGE_REGISTRY quay.io/redhat-services-prod/hcm-eng-prod-tenant/hypershell-main Container registry for baseline images
IMAGE_TAG latest Image tag for baseline images
LOCAL_IMAGES (unset) Set to true to build baseline images from the working tree
KIND_COVERAGE (unset) Set to true to build coverage-instrumented images and mount a coverage volume (implies LOCAL_IMAGES=true). See Coverage.
CONTAINER_ENGINE Auto-detected podman or docker
GATEWAY_API_VERSION v1.5.1 Gateway API CRD version
CLOUD_PROVIDER_KIND_REPO https://github.com/squizzi/cloud-provider-kind.git cloud-provider-kind git repo
CLOUD_PROVIDER_KIND_BRANCH hypershell cloud-provider-kind branch to build
CERT_MANAGER_VERSION v1.21.1 cert-manager version
KIND_DB_IMAGE registry.access.redhat.com/hi/postgresql:18.4@sha256:9b19... Database image for Gateway; override for OSS dev
KIND_NO_SUDO (unset) Set to true to skip sudo operations
KIND_DNS_PORT 5553 Host port for CoreDNS container
SKIP_SEED (unset) Set to true to skip seeding on make kind-up. KIND_SKIP_SEED is still accepted.
SEED_STRICT (unset) Set to true to fail make kind-up / make kind-seed if seeding is incomplete. KIND_SEED_STRICT is still accepted.

OpenShift Development

make openshift-up deploys the same stack into the current oc project on an OpenShift cluster selected by kubeconfig. It does not create the cluster. An administrator must already have provisioned the shared Gateway, GatewayClass, certificate issuer, and wildcard certificate (see deploy/openshift/infrastructure/GATEWAY-SETUP.md).

OpenShift quickstart

The platform namespace is the current oc project. Select it first, then bring the environment up:

oc project alice
make openshift-up

OPENSHIFT_NAMESPACE overrides that project when you need to target a namespace other than the one oc project -q reports:

OPENSHIFT_NAMESPACE=alice make openshift-up

The name must be a valid RFC 1123 DNS label of at most 54 characters so the companion Keycloak namespace ${name}-keycloak stays within the 63-character limit. If no project is selected and OPENSHIFT_NAMESPACE is unset, the command stops with an error.

OpenShift make targets

Target Use
make openshift-up Deploy the stack into the current oc project (OPENSHIFT_NAMESPACE override) and companion ${name}-keycloak. Does not create an OpenShift cluster. Waits for component rollouts, then seeds unless SKIP_SEED=true.
make openshift-down Delete the platform and Keycloak projects, then delete gateway namespaces labeled hypershell.redhat.io/instance=<platform ns>. If project deletion is forbidden, strip HyperShell resources and leave the projects. Without ownership labels the command refuses; FORCE=true make openshift-down overrides that check. Reserved names (default, kube-*, openshift-*) stay refused.
make openshift-teardown Same as openshift-down. There is no OpenShift cluster to destroy.
make openshift-status Show namespaces, pods, Routes, the shared Gateway, and swap state.
make openshift-seed Re-run Gateway seeding via API and Keycloak Routes from this machine, against the local-openshift ManagedCluster the control plane registered itself (seeding waits for it and never creates it). Reuses the existing named seed resource (dev-gateway) instead of creating duplicates. openshift-up already seeds unless SKIP_SEED=true.
make openshift-api-server-up Build, push an immutable image to SWAP_REGISTRY, and point the API server Deployment at that ref. Requires SWAP_REGISTRY.
make openshift-api-server-down Revert the API server to the baseline registry image.
make openshift-control-plane-up Build, push, and swap the control plane.
make openshift-control-plane-down Revert the control plane to the baseline registry image.
make openshift-web-console-up Build, push, and swap the web console. There is no Kind-style Vite hot reload.
make openshift-web-console-down Revert the web console to the baseline registry image.
make openshift-test Run scripts/cluster/lib_test.sh on the laptop (overlay rewrite tests). Does not talk to a cluster.

make openshift-up deploys into the project you selected. It does not ask for confirmation, and it does not require permission to label the namespace. When the account can patch namespaces, the scripts stamp HyperShell ownership labels. When it cannot, the scripts warn and continue. Namespaces that already belong to a different HyperShell environment, and reserved names (default, kube-*, openshift-*), are still refused.

The companion Keycloak project ${name}-keycloak is created with oc new-project when it does not exist (developers can ProjectRequest; they typically cannot oc create namespace). The scripts switch to that project to apply Keycloak, then switch back to the platform project for the rest of the stack. OpenShift's default project NetworkPolicies only allow ingress from the same namespace and from openshift-ingress, so the overlay also applies keycloak-allow-platform in the Keycloak project. That policy lets the API server load JWKS and the control plane call the Admin API over the in-cluster Service.

This renders kustomize build deploy/openshift/, maps hypershell-system to that platform namespace and keycloak to ${platform}-keycloak, applies the overlay ClusterRole and ClusterRoleBinding with names prefixed ${namespace}-dev-* (so an environment does not patch stage's hypershell-controller), plus the privileged SCC RoleBinding, applies the manifests (with prune scoped to this environment), registers the web-console Route as the Keycloak hypershell-frontend redirect URI, seeds a ManagedCluster and Gateway from this machine against the API and Keycloak Routes (the API server image has no curl), and prints the API, web-console, and Keycloak Routes. The overlay sets API_ENV=development_oidc on the API server so --enable-jwt=true is not clobbered by the default development environment. Route-derived OIDC values (KC_HOSTNAME, console redirect URIs, gateway issuer) are applied after the Routes exist. The gateway base domain is read from the shared Gateway's listener hostname, not from GATEWAY_API_BASE_DOMAIN. When ClusterRole create is forbidden, the command binds ${namespace}-dev-hypershell-controller to the existing cluster-wide ClusterRole hypershell-controller if that ClusterRole exists. Only if that fallback also fails does it warn and continue. It never applies unprefixed hypershell-controller. make openshift-down deletes this environment's ${namespace}-dev-* ClusterRoles and ClusterRoleBindings and does not delete stage's hypershell-controller.

make openshift-down and make openshift-teardown are the same command. There is no OpenShift cluster to destroy. Both delete the platform project and the companion ${name}-keycloak project. If project deletion is forbidden, they delete HyperShell resources inside both projects (including unlabeled Keycloak) and leave the projects. Labels are not required.

OpenShift per-component swap

make openshift-api-server-up
make openshift-control-plane-up
make openshift-web-console-up

Each swap builds from the working tree, pushes an immutable image (commit + namespace tag) to SWAP_REGISTRY, and updates the Deployment image refs to the registry digest from that push (not the local image digest). Images are built for the OpenShift node architecture (SWAP_PLATFORM, or detected from the cluster) via --platform linux/<arch>. Component Dockerfiles pin HI bases per architecture. SWAP_REGISTRY is the org prefix only (quay.io/<org>). Repo names default to hypershell-api-server, hypershell-controller, and hypershell-web-console; set SWAP_REPOSITORY to override the repo for the current swap. SWAP_REGISTRY is required; swaps do not use IMAGE_REGISTRY. Matching -down targets revert to the baseline registry image. Registry login uses PULL_SECRET (KIND_PULL_SECRET still works). make openshift-status reports which components run a working-tree build and the exact image each one uses. Swap state is tracked per namespace in .openshift-swaps/ (gitignored). A subsequent make openshift-up preserves active swaps.

OpenShift environment variables

Variable Default Description
OPENSHIFT_NAMESPACE oc project -q Override for the platform namespace. Unset, the current oc project is used. Max 54 chars; Keycloak lands in ${name}-keycloak.
GATEWAY_API_GATEWAY_NAME openshell-grpc-gateway Pre-existing shared Gateway name
GATEWAY_API_GATEWAY_NAMESPACE openshift-ingress Namespace of the shared Gateway
SWAP_REGISTRY (required for swaps) Registry org prefix only, for example quay.io/<org>. Swaps push ${SWAP_REGISTRY}/hypershell-api-server (and hypershell-controller, hypershell-web-console). Must be laptop-reachable; the OpenShift internal registry is refused. IMAGE_REGISTRY is not used.
SWAP_REPOSITORY (component default) Optional repo name override for the current swap. Default is hypershell-api-server, hypershell-controller, or hypershell-web-console.
SWAP_PLATFORM (cluster nodes) Target platform for swap images, linux/amd64 or linux/arm64. Unset, the scripts use the architecture of the cluster nodes.
PULL_SECRET (unset) Path to a kubernetes.io/dockerconfigjson Secret YAML used to log the container engine into SWAP_REGISTRY. KIND_PULL_SECRET is still accepted.
IMAGE_REGISTRY quay.io/redhat-services-prod/hcm-eng-prod-tenant/hypershell-main Container registry for baseline images
IMAGE_TAG latest Image tag for baseline images
CONTAINER_ENGINE Auto-detected podman or docker
SKIP_SEED (unset) Set to true to skip seeding on make openshift-up. KIND_SKIP_SEED is still accepted.
SEED_STRICT (unset) Set to true to fail make openshift-up / make openshift-seed if seeding is incomplete. KIND_SEED_STRICT is still accepted.

Gateway Access

The control plane provisions openshell-gateway pods that serve gRPC over TLS using cert-manager-issued certificates. Accessing these gateways from the host depends on the environment.

Kind (port-forward)

In Kind, the simplest method is kubectl port-forward. This connects directly to the gateway pod's TLS endpoint, bypassing the networking Gateway entirely:

kubectl --context kind-hypershell-dev port-forward \
  -n <gateway-namespace> svc/openshell-gateway 7443:8080 &

Then register the gateway with the openshell CLI:

openshell gateway add \
  --name my-gateway \
  --oidc-issuer https://keycloak.hypershell.localhost/realms/hypershell \
  --oidc-client-id hypershell-frontend \
  https://localhost:7443

This opens a browser for Keycloak login. Use admin/admin or developer/developer.

The OIDC issuer URL must be https://keycloak.hypershell.localhost/realms/hypershell (not the ephemeral port). Keycloak embeds this URL as the iss claim in tokens, so the issuer passed to openshell gateway add must match exactly. This requires host port 443 to be forwarded -- if it isn't, run make kind-fix-ports first.

The functional e2e suite is the Go E2ESuite (tests/e2e/, make e2e), which auto-detects the OpenShift driver (tests/e2e/driver/openshift.go) from the KUBECONFIG context. The canonical pull-request OpenShift e2e path runs it with E2E_INFRA_DRIVER=openshift make e2e, driven automatically by the ephemeral pull-request environment workflow (see Ephemeral OpenShift PR environments). The legacy components/pr-test/e2e-openshell.sh script and the Bash functional suite it superseded have been removed (HYPERSHELL-250). The Bash tests/e2e/drivers/*.sh remain only for the retained browser (e2e-console.sh) and smoke (smoke.sh) suites.

OpenShift (automatic)

On OpenShift, the control plane automatically creates networking resources when a gateway is provisioned (every gateway is routed):

  1. A per-namespace Gateway with openshift-default gateway class
  2. A GRPCRoute routing to openshell-gateway:8080
  3. A BackendTLSPolicy for TLS re-encryption to the backend (the OpenShift router terminates external TLS, then re-encrypts to the pod using the gateway's cert-manager CA)
  4. A NetworkPolicy allowing ingress from openshift-ingress router pods

The gateway becomes reachable at grpcs://<openshell-gateway-NAMESPACE>.<GATEWAY_API_BASE_DOMAIN>:443 with no port-forward needed. The control plane writes this address back to the API server's route_address field.

Gateway TLS in Kind

The networking Gateway's *.gw.localhost listener uses TLS Terminate mode, which strips the external TLS and forwards plaintext to the backend. openshell-gateway pods expect TLS connections (they serve gRPC with their own cert-manager certificates). BackendTLSPolicy instructs the gateway implementation to re-encrypt traffic to the backend. The kind-prereqs target builds cloud-provider-kind from a fork that adds BackendTLSPolicy support, so per-tenant gateways work without port-forward workarounds.

Creating a gateway with OIDC

make kind-up seeds a ManagedCluster but does not create a Gateway. The gateway database server needs no API resource: the control plane reads the hypershell-gateway-database-admin Secret that kind-up creates. Create a Gateway via the API; cluster_id is not a request field, create takes a required placement intent and the provider/kind capability selector selects the seeded ManagedCluster:

# Create a gateway with OIDC
curl -s -X POST http://localhost:8000/api/hypershell/v1/gateways \
  -H "Content-Type: application/json" \
  -d "{
    \"name\": \"dev-gateway\",
    \"placement\": {\"selector\": [\"provider/kind\"]},
    \"oidc\": \"{\\\"issuer\\\":\\\"https://keycloak.hypershell.localhost/realms/hypershell\\\",\\\"audience\\\":\\\"hypershell-frontend\\\",\\\"roles_claim\\\":\\\"groups\\\",\\\"admin_role\\\":\\\"hypershell-admins\\\",\\\"user_role\\\":\\\"hypershell-users\\\"}\"
  }"

Wait ~30s for the control plane to reconcile, then port-forward and register.

CLI and Terminal UI

Most of hsctl is generated from the API's OpenAPI description (components/api-server/openapi/) by the rh-trex-ai generators. Roughly half of the files in components/cli are generated; the rest are hand-written.

Part Source Where
list, get, create, update, delete commands per resource, login (static token and OIDC), logout, whoami, config, completion, version, shared packages (pkg/config, pkg/connection, pkg/oidc, pkg/output and others) rh-trex-ai cli-generator components/cli/cmd/hsctl/..., components/cli/pkg/...
Terminal UI descriptor rh-trex-ai tui-generator components/cli/data/generated/tui/
apply, revoke, the service account commands, the tui wrapper, main.go hand-written components/cli/cmd/hsctl/..., pkg/serviceaccount, pkg/gatewayconnect

The extension kinds (AgentRuntime, SandboxTemplate, ProviderSpec, ProviderBinding, InferenceRoute, SecretSource) are served under /api/hypershell/ext/, but the generator handles a single API prefix and produces only the /api/hypershell/v1/ kinds. Their commands (create, get, list, delete) are therefore hand-written in the same shape, their URLs are in pkg/urls/ext.go, and cmd/hsctl/extgroup registers them and splits the help of get, list, create and delete into a core section and an experimental extensions section. They have no update command. A new extension kind needs its command files, a line in each ext_registration.go, its paths in ext.go, and an entry in HAND_MAINTAINED_COMMANDS in scripts/generate-cli.sh.

update and delete exist only for resources whose OpenAPI description declares the operation. delete asks for confirmation and fails without a terminal unless --yes is given; update sends only the flags that are set, or a --body JSON file.

Regenerating

After changing anything under components/api-server/openapi/:

make generate-cli    # hsctl commands and the terminal UI descriptor
make generate-tui    # only the terminal UI descriptor

Commit the result. Never edit a generated file by hand. make check, the git hooks and CI fail when a generated file differs from a fresh generation (make generate-cli-check, make generate-tui-check), and when a resource command is left behind after its resource or operation left the spec.

The generators run from a checkout of rh-trex-ai at the commit in scripts/rh-trex-ai.ref, cached in ~/.cache/hypershell/rh-trex-ai (override with TREX_CACHE, TREX_REPO, or TREX_REF for one run). The first run needs network access. The cache is refused if its files were modified, so remove the directory when that happens.

Updating the rh-trex-ai pin

The generators and the terminal UI runtime must come from the same commit:

  1. Put the full 40 character commit SHA in scripts/rh-trex-ai.ref.
  2. Set the rh-trex-ai/components/api-server version in components/cli/go.mod to the matching pseudo-version, then run go mod tidy in components/cli.
  3. Run make generate-cli, review the diff, and run cd components/cli && go test ./... and make check.

Pin a commit on the upstream main branch of openshift-online/rh-trex-ai. The framework publishes no tag for this module, so go.mod uses a pseudo-version (go get github.com/openshift-online/rh-trex-ai/components/api-server@<sha> prints it). A commit younger than the 14 day dependency minimum age needs an exception in dependency-age-allowlist.json with a reason and compensating verification; remove it once the commit is old enough, or when a newer pin replaces it.

components/api-server pins the framework separately in its own go.mod, because it links the server framework, not the generators. It may be on a different commit than the CLI, so check that it still builds before moving it. For a feature such as API-driven login discovery, update both pins: regenerating hsctl alone cannot add the server endpoint. Run the API tests and build as well.

After the downstream change merges, Konflux builds the changed API server and CLI components. The managed release's final pipeline publishes the OCI release bundle and a matching GitHub release with five hsctl downloads and SHA256SUMS; binaries are extracted from the released CLI image rather than rebuilt. Before promoting a bundle through GitOps, verify that it contains both the new API and CLI component revisions, since a bundle can reuse earlier builds for unchanged components. Deploy the updated API before asking users to rely on issuer discovery. Existing public issuer and route configuration does not need to change. See hsctl-release.spec.md for release details.

Customizing generated code

Generated files are never patched. scripts/generate-cli.sh passes two options to the generator instead:

  • --config-name hypershell: the config file is $HYPERSHELL_CONFIG, ~/.hypershell.json, or ~/.config/hypershell/config.json, so logins saved by earlier versions keep working.
  • --oidc-client-id hypershell-cli: the HyperShell Keycloak client becomes the login --client-id default.

Token refresh, OIDC login and logout, and whoami come from the generator (pkg/oidc, pkg/connection, pkg/config), including saving a rotated refresh token. The terminal UI reuses the generated token provider (connection.NewConfigTokenProvider). Hooks (config.SetStore, connection.SetHTTPClientFactory, connection.SetTokenProviderFactory) are available if a future need arises.

Generated commands are registered by the generated cmd/hsctl/generated_commands.go, which main.go calls once (addGeneratedCommands(root)); a new resource needs no edit to main.go. A hand-written command is registered from main.go (or a registration file next to the generated parent, as delete/service_account_registration.go does). A hand-written resource command that lives beside generated ones must also be listed in HAND_MAINTAINED_COMMANDS in scripts/generate-cli.sh, or the drift check will report it as left over. Files the generator must not overwrite are listed in HAND_MAINTAINED in the same script.

The terminal UI behavior is specified in specs/platform/hsctl-terminal-ui.spec.md.

Testing

Unit tests

Run the full local unit test suite (API server, control plane, CLI, SDK generator, frontend packages, and shell tests) before pushing:

make unit-test-all
Target Runs
make unit-test-all Every unit test suite: install-js, make ci-test, components/api-server (make test), components/control-plane (go test ./...), components/cli, scripts/sdk-generator (go test ./...), and pnpm run test:web (frontend packages)
make ci-test Only the auto-discovered *_test.sh shell unit tests (see below)

Component-scoped runs are also available:

cd components/api-server && make test              # Go tests (spins up PostgreSQL via testcontainers-go; requires Docker/Podman)
cd components/api-server && make test-integration   # Same, scoped to ./plugins/...
cd components/control-plane && go test ./...        # Go unit tests

Shell unit tests (*_test.sh, e.g. scripts/kind/lib_test.sh) are auto-discovered by make ci-test and scripts/run-shell-unit-tests.sh - adding a new *_test.sh file next to the script it tests is enough; no Makefile or CI allowlist update is needed.

CI

Two independently-triggered, top-level workflows run on every pull request, push to main, and merge-queue entry: .github/workflows/checks.yml (static/whole-repo checks) and .github/workflows/tests.yml (unit tests and e2e). They each show as their own entry in the PR checks list and run fully concurrently - GitHub Actions needs: only orders jobs within one workflow file, so the two cannot gate each other without a cross-workflow poller, which this repo deliberately avoids. Each therefore runs its own detect-changes job rather than sharing one.

.github/workflows/checks.yml covers per-component lint jobs, repository policy (make check, unconditional), and OpenAPI SDK drift (gated on the sdk_go/sdk_typescript detection outputs) - all sharing that workflow's single detect-changes pass instead of each re-detecting changes on their own trigger the way the old standalone repository-policy.yml and sdk-drift-check.yml did. Its checks-gate job (Checks CI Gate) runs with if: always(), reads every other job's rolled-up result, and fails unless detect-changes succeeded and no job failed or was cancelled (a path-filtered skip still passes the gate).

.github/workflows/tests.yml detects changed components once (its detect-changes job) and calls unit and e2e as reusable workflows, passing the detection results in as inputs and wiring the stages with native needs: edges: unit depends only on detect-changes, and e2e joins on unit (needs: [detect-changes, unit]). GitHub Actions skips a job by default if any needed job failed or was skipped, so e2e also carries an explicit if: ${{ !cancelled() && needs.detect-changes.result == 'success' && needs.unit.result != 'failure' }} - without it, a PR touching only e2e-owned paths (every unit job path-filtered away, so the unit caller job itself resolves to skipped) would silently skip e2e too. e2e is the expensive stage - it provisions Kind and runs the full test matrix - so gating it behind the cheap unit stage means Kind is never created for a SHA whose unit tests failed, and such a failure shows up as a clean red Tests CI Gate check instead of a misleading e2e environment failure. Nothing sits polling for a preceding gate. .github/workflows/unit-tests.yml runs the same suites as make unit-test-all, split into per-component jobs that only run when their inputs changed.

.github/workflows/tests.yml's tests-gate job (Tests CI Gate) covers the unit and e2e stages together, since they're both "running the code" stages as opposed to checks.yml's static checks. Each stage's jobs appear as Unit / <job> and E2E / <job> checks, so there is no single check named just Unit/E2E; the gate rolls both up into one always-present required check the same way checks.yml's gate does.

The two gate jobs are named distinctly (Checks CI Gate, Tests CI Gate) rather than both plain CI Gate: this repo's branch protection is a ruleset whose required_status_checks match by (context name, integration_id) only, not by workflow file, and both workflows' checks share the same "GitHub Actions" integration_id - identically-named gates from the two workflows would be indistinguishable to the ruleset, and either one succeeding could satisfy the requirement while the other silently failed. Mark both Checks CI Gate and Tests CI Gate as required checks in branch protection. Note the trade-off of running the two workflows concurrently: a lint/policy/drift failure in checks.yml no longer blocks tests.yml's e2e stage from spinning up Kind - only a unit-test failure does.

On origin pull requests whose e2e-relevant paths changed, the e2e stage also runs Tests / E2E / Deploy OpenShift Environment and Tests / E2E / OpenShift against a per-PR namespace on the shared CI cluster. That cycle is ephemeral by default. See Ephemeral OpenShift PR environments for /pr-extend and /pr-destroy.

E2E tests

See specs/platform/e2e-testing.spec.md for the e2e and performance test suites (make e2e, make e2e-performance), which run against Kind or an existing OpenShift cluster. Origin pull-request OpenShift e2e is the ephemeral PR environment described below.

Coverage

make coverage runs every test layer and writes one combined report. It measures which code the unit tests and the e2e suites run, and merges the results (specs/platform/local-development.spec.md, DEV-LOC-18).

  1. Deploy a Kind cluster with instrumented images:

    KIND_COVERAGE=true make kind-up

    The API server and controller are built with go build -cover. The web console BFF is built with source maps. All three write coverage data to a shared volume (deploy/kind/code-coverage).

  2. Run the tests and build the report:

    make coverage

    This runs, in order:

    • The Go unit tests (API server, control plane, CLI) with -coverprofile. The API server tests start PostgreSQL with testcontainers, like make test.
    • The frontend unit tests with vitest coverage over all source files, not only the files each package's CI gate lists.
    • make e2e against the cluster. It reaches the ingress on the cloud-provider-kind proxy's published port, so it does not need the port-443 redirect either.
    • The hsctl smoke test (tests/e2e/e2e-hsctl.sh) with an hsctl built by go build -cover. It writes coverage to a local folder, because hsctl runs on your machine, and keeps its login in a temporary config file, so your own hsctl login is untouched.
    • make e2e-console against the cluster, in short mode like CI (set E2E_MODE to override). When the Kind nodes' container network exists, it runs in a Playwright container on that network (see below), so it needs neither port 443 forwarding nor browser libraries on your machine.

    It then stops the instrumented pods so they write their data, copies it off the Kind node, and starts the pods again.

  3. Read the report:

    • coverage/report/summary.md: unit, e2e and combined numbers per component and per Go package.
    • coverage/report/go/<component>.html: line-by-line Go coverage.
    • coverage/report/bff-e2e/index.html: BFF coverage from the e2e run.

A failing test step does not stop the run. The report is still built and names the failed steps at the top, because their numbers are incomplete. make coverage exits non-zero at the end. Logs are in coverage/logs/.

Variable Default Description
COVERAGE_DIR coverage Output directory
COVERAGE_UNIT true Run the Go and frontend unit tests
COVERAGE_E2E true Run make e2e and collect the cluster data. Set to false for unit tests only (no cluster needed).
COVERAGE_HSCTL_E2E true Also run the hsctl smoke test with an instrumented hsctl
COVERAGE_CONSOLE_E2E true Also run make e2e-console
COVERAGE_CONSOLE_CONTAINER auto Run the console suite in a Playwright container on the Kind network: auto (when that network exists), true, or false

make coverage-report rebuilds the report from the data of the last run.

Notes:

  • The console suite can run without host port 443 or browser libraries: E2E_CONSOLE_CONTAINER=true make e2e-console runs it inside the official Playwright image on the kind network, where the gateway answers on 443 directly. make coverage does this automatically. The first run pulls the image (about 2 GB).
  • On a machine with podman but no Docker socket (a Linux VM, for example), the API server tests run testcontainers through podman's socket automatically.
  • Without the container (COVERAGE_CONSOLE_CONTAINER=false), the console suite runs on your machine: host port 443 must reach the cluster (make kind-fix-ports), and on Linux Chromium needs system libraries. If the e2e-console-browser step fails, its log shows the command that installs them (sudo pnpm exec playwright install-deps, run in components/web-console).
  • Generated code (OpenAPI and gRPC clients) is reported separately from hand-written code.
  • Browser-side React code is not measured during e2e.
  • Swapping a component (make kind-api-server-up and siblings) with KIND_COVERAGE=true keeps it instrumented.

Ephemeral OpenShift PR environments

Origin pull requests that change e2e-relevant paths get a live OpenShift environment on the shared CI cluster. CI deploys into hypershell-ci-pr-<number> (Keycloak in hypershell-ci-pr-<number>-keycloak), runs Tests / E2E / OpenShift against it, then destroys the environment in the same run unless you opt in. Fork pull requests and merge-queue entries do not get an environment.

Tests / E2E / Deploy OpenShift Environment posts one marked comment on the pull request and updates it in place. When the environment is ready, that comment has the namespaces, OpenShift console URL, API URL, web-console URL, and an oc login --web template. Log in through the web console with your GitHub account; you must be a member of the configured organization or on its allowlist.

Keep or destroy the environment

By default the environment is destroyed once e2e testing concludes, including on a failed or cancelled run. The marked access comment then updates in place to say the environment is gone and to comment /pr-extend to redeploy it. To keep the environment as a debug target instead, comment /pr-extend on the pull request. The command must start the comment body. Trailing text is allowed:

/pr-extend
/pr-extend keep this up so I can inspect the failing gateway

/pr-extend requires write, maintain, or admin permission on the origin repository. It adds the pr-environment/pr-extended label, deploys (or redeploys) the current head if nothing is up, and skips in-run teardown on later commits. You do not need to comment /pr-extend again after each push.

To free a retained environment early and return the pull request to the ephemeral default:

/pr-destroy

Closing or merging the pull request also tears the environment down, whether or not it was retained.

The latest authorized command wins. If you comment /pr-extend, then /pr-destroy, then /pr-extend again, the pull request stays retained. A comment from someone without write access is acknowledged and ignored; it does not flip the state.

A retained environment is renewed on every commit and reclaimed after 72 hours of inactivity unless you /pr-destroy or close the pull request. The access comment shows that UTC expiry. Unretained deploys that miss in-run teardown are reaped after 6 hours.

See specs/platform/ephemeral-pr-environments.spec.md for the full contract.

Troubleshooting

Container engine not running

Cannot connect to the Docker daemon

Start Docker Desktop or Podman:

# Docker
open -a Docker
# Podman
podman machine start

Image pull failures

If the container registry is unreachable, use offline mode:

LOCAL_IMAGES=true make kind-up

cloud-provider-kind not found

make kind-prereqs

DNS resolution not working

make kind-up runs a CoreDNS container (hypershell-dns) for wildcard *.hypershell.localhost resolution. If hostnames don't resolve:

# Check if the DNS container is running
docker ps --filter name=hypershell-dns

# Restart it
docker restart hypershell-dns

# Verify resolution
dig @127.0.0.1 -p 5553 api.hypershell.localhost

OIDC discovery fails

Authentication failed: error sending request for url (https://keycloak.hypershell.localhost/...)

Host port 443 is not forwarded to the Gateway's ephemeral HTTPS port, or the gateway pod does not trust the self-signed CA. Re-establish port forwarding:

make kind-fix-ports

If the gateway logs a TLS/certificate error, confirm the gateway-trusted-ca ConfigMap exists in hypershell-system (published from hypershell-https-tls by make kind-up); the reconciler mounts it into each gateway as SSL_CERT_FILE.

If you see an issuer mismatch error, you are likely using the ephemeral port directly instead of port 443. The OIDC issuer URL must always be https://keycloak.hypershell.localhost/realms/hypershell because Keycloak embeds that URL in the token's iss claim.

Keycloak admin console redirect loop

If the Keycloak admin console (/admin/) redirects in a loop, verify that the KC_HOSTNAME env var patched by deploy/kind/keycloak/kustomization.yaml is set to https://keycloak.hypershell.localhost. Restart the Keycloak deployment after changes:

kubectl --context kind-hypershell-dev rollout restart deployment/keycloak -n keycloak

Pods stuck in ImagePullBackOff

The baseline images require access to quay.io. If behind a firewall, use offline mode or configure a pull secret:

# Offline: build from local working tree
LOCAL_IMAGES=true make kind-up

# Or: provide registry credentials
PULL_SECRET=/path/to/pull-secret.yaml make kind-up

OpenShift swap cannot push

Swaps build on the laptop and push to SWAP_REGISTRY, then update the Deployment image refs. They do not use IMAGE_REGISTRY or the OpenShift internal registry. If SWAP_REGISTRY is unset, the swap stops with an error.

PULL_SECRET=/path/to/pull-secret.yaml SWAP_REGISTRY=quay.io/<org> make openshift-api-server-up

That logs the container engine in with the pull secret and pushes quay.io/<org>/hypershell-api-server:<commit>-<namespace>. Override the repo name with SWAP_REPOSITORY when it is not the default. KIND_PULL_SECRET is still accepted if PULL_SECRET is unset.