|
| 1 | +# Running Gateway API Conformance Tests on OpenShift |
| 2 | + |
| 3 | +This document describes the steps required to run Gateway API conformance tests on an OpenShift cluster. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Access to an OpenShift cluster |
| 8 | +- `oc` CLI tool installed and configured |
| 9 | +- `kubectl` configured to access your OpenShift cluster |
| 10 | +- Docker/Podman for building images |
| 11 | +- Access to a container registry (e.g., quay.io) |
| 12 | +- NGF should be preinstalled on the cluster before running the tests. You can install using the Operator or Helm. |
| 13 | +**Note** : |
| 14 | + - the NGINX service type needs to be set to `ClusterIP` |
| 15 | + - the NGINX image referenced in the `NginxProxy` resource needs to be accessible to the cluster |
| 16 | + |
| 17 | +## Overview |
| 18 | + |
| 19 | +OpenShift has stricter security constraints than standard Kubernetes, requiring additional configuration to run the Gateway API conformance test suite. |
| 20 | + |
| 21 | +## Step 1: Check Gateway API Version |
| 22 | + |
| 23 | +OpenShift ships with Gateway API CRDs pre-installed. To find out which version is installed, run the following command: |
| 24 | + |
| 25 | + ```bash |
| 26 | + kubectl get crd gateways.gateway.networking.k8s.io -o jsonpath='{.metadata.annotations.gateway\.networking\.k8s\.io/bundle-version}' |
| 27 | + ``` |
| 28 | + |
| 29 | +### Updating NGF to Match OpenShift's Gateway API Version |
| 30 | + |
| 31 | +To run conformance tests that match the exact Gateway API version on OpenShift: |
| 32 | + |
| 33 | +1. Update Go modules: |
| 34 | + |
| 35 | + ```bash |
| 36 | + # Update parent module |
| 37 | + go get sigs.k8s.io/gateway-api@<OCP-version> |
| 38 | + go mod tidy |
| 39 | + |
| 40 | + # Update tests module |
| 41 | + cd tests |
| 42 | + go get sigs.k8s.io/gateway-api@<OCP-version> |
| 43 | + go mod tidy |
| 44 | + cd .. |
| 45 | + ``` |
| 46 | + |
| 47 | + **Important:** Due to the `replace` directive in `tests/go.mod`, you must update both the parent and tests modules for the version change to take effect. |
| 48 | + |
| 49 | +2. Update test configuration to remove features not available in the OCP-installed Gateway API version. |
| 50 | + |
| 51 | +For **Gateway API v1.2.1**, you must update tests/conformance/conformance_test.go to eliminate references to v1beta1.GatewayStaticAddresses. This field was only introduced in Gateway API v1.3.0, and leaving it in place will cause the test to fail to compile in a v1.2.1 environment. |
| 52 | + |
| 53 | +**Note:** This is separate from `SUPPORTED_EXTENDED_FEATURES_OPENSHIFT` in the Makefile, which controls which features are tested. This change is required because the conformance test code itself references v1.3.0+ features that don't exist in v1.2.1. |
| 54 | + |
| 55 | +## Step 2: Build and Push Conformance Test Image |
| 56 | + |
| 57 | +OpenShift typically runs on amd64 architecture. If you are building images from an arm64 machine, make sure to specify the target platform so the image is built for the correct architecture |
| 58 | + |
| 59 | +1. Build the conformance test runner image for amd64: |
| 60 | + |
| 61 | + ```bash |
| 62 | + make -C tests build-test-runner-image GOARCH=amd64 CONFORMANCE_PREFIX=<public-repo>/<your-org>/conformance-test-runner CONFORMANCE_TAG=<tag> |
| 63 | + ``` |
| 64 | + |
| 65 | +2. Push the image to your registry: |
| 66 | + |
| 67 | + ```bash |
| 68 | + docker push <public-repo>/<your-org>/conformance-test-runner:<tag> |
| 69 | + ``` |
| 70 | + |
| 71 | +## Step 3: Configure Security Context Constraints (SCC) |
| 72 | + |
| 73 | +OpenShift requires explicit permissions for pods to run with elevated privileges. To apply SCC permissions to allow coredns and other infrastructure pods, run: |
| 74 | + |
| 75 | + ```bash |
| 76 | + oc adm policy add-scc-to-group anyuid system:serviceaccounts:gateway-conformance-infra |
| 77 | + ``` |
| 78 | + |
| 79 | +**Note:** These permissions persist even if the namespace is deleted and recreated during test runs. |
| 80 | + |
| 81 | +## Step 4: Run Conformance Tests |
| 82 | + |
| 83 | +### Using the Makefile (Recommended) |
| 84 | + |
| 85 | +Run the OpenShift-specific conformance test target: |
| 86 | + |
| 87 | +```bash |
| 88 | +make -C tests run-conformance-tests-openshift \ |
| 89 | + CONFORMANCE_PREFIX=quay.io/your-org/conformance-test-runner \ |
| 90 | + CONFORMANCE_TAG=<OCP-version> \ |
| 91 | +``` |
| 92 | + |
| 93 | +This target: |
| 94 | + |
| 95 | +- Applies the RBAC configuration |
| 96 | +- Runs only the extended features supported on the GatewayAPIs shipped with OpenShift |
| 97 | +- Skips `HTTPRouteServiceTypes` test (incompatible with OpenShift) |
| 98 | +- Pulls the image from your registry |
| 99 | + |
| 100 | +## Step 5: Known Test Failures on OpenShift |
| 101 | + |
| 102 | +### HTTPRouteServiceTypes |
| 103 | + |
| 104 | +This test fails on OpenShift due to security restrictions on EndpointSlice creation: |
| 105 | + |
| 106 | +```text |
| 107 | +endpointslices.discovery.k8s.io "manual-endpointslices-ip4" is forbidden: |
| 108 | +endpoint address 10.x.x.x is not allowed |
| 109 | +``` |
| 110 | + |
| 111 | +**Solution:** Skip this test using `--skip-tests=HTTPRouteServiceTypes` |
| 112 | + |
| 113 | +This is expected behavior - OpenShift validates that endpoint IPs belong to approved ranges, and the conformance test tries to create EndpointSlices with arbitrary IPs. |
| 114 | + |
| 115 | +## Cleanup |
| 116 | + |
| 117 | +```bash |
| 118 | +kubectl delete pod conformance |
| 119 | +kubectl delete -f tests/conformance/conformance-rbac.yaml |
| 120 | +``` |
| 121 | + |
| 122 | +## Troubleshooting |
| 123 | + |
| 124 | +### coredns pod fails with "Operation not permitted" |
| 125 | + |
| 126 | +**Cause:** Missing SCC permissions |
| 127 | + |
| 128 | +**Solution:** Apply the anyuid SCC as described in Step 3 |
| 129 | + |
| 130 | +### DNS resolution failures for LoadBalancer services |
| 131 | + |
| 132 | +**Cause:** OpenShift cluster DNS cannot resolve external ELB/LoadBalancer hostnames |
| 133 | + |
| 134 | +**Solution:** Use `GW_SERVICE_TYPE=ClusterIP` |
| 135 | + |
| 136 | +### Architecture mismatch errors ("Exec format error") |
| 137 | + |
| 138 | +**Cause:** Image built for wrong architecture (e.g., arm64 instead of amd64) |
| 139 | + |
| 140 | +**Solution:** Rebuild with `GOARCH=amd64` as described in Step 3 |
| 141 | + |
| 142 | +## Summary |
| 143 | + |
| 144 | +The key differences when running conformance tests on OpenShift vs. standard Kubernetes: |
| 145 | + |
| 146 | +1. **SCC Permissions:** Required for coredns and infrastructure pods |
| 147 | +2. **Service Type:** Must use `ClusterIP` to avoid DNS issues |
| 148 | +3. **Architecture:** Explicit amd64 build required when building from arm64 machines |
| 149 | +4. **Test Skips:** HTTPRouteServiceTypes must be skipped due to EndpointSlice restrictions |
| 150 | +5. **Image Registry:** Images must be pushed to a registry accessible by OpenShift |
0 commit comments