Skip to content

Commit 28d8e3f

Browse files
committed
Update readmes and makefiles (#3989)
Update READMEs and Makefiles to provide instructions for running the conformance tests on OpenShift clusters, and easy targets for same
1 parent f1cc404 commit 28d8e3f

File tree

5 files changed

+177
-5
lines changed

5 files changed

+177
-5
lines changed

operators/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ run: helm-operator ## Run against the configured Kubernetes cluster in ~/.kube/c
4949

5050
.PHONY: docker-build
5151
docker-build: ## Build docker image with the manager.
52-
docker build -f Dockerfile -t ${IMG} ..
52+
docker build --platform linux/$(ARCH) -f Dockerfile -t ${IMG} ..
5353

5454
.PHONY: docker-push
5555
docker-push: ## Push docker image with the manager.
@@ -89,7 +89,7 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
8989
$(KUSTOMIZE) build config/default | kubectl delete -f -
9090

9191
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
92-
ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
92+
ARCH ?= $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
9393

9494
.PHONY: kustomize
9595
KUSTOMIZE = $(shell pwd)/bin/kustomize

operators/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ For complete configuration options, see the [Helm Chart Documentation](https://g
6363
### Building and Testing the Operator Locally
6464

6565
```bash
66-
# Build the operator image
66+
# Build the operator image. If building for deploying on a cluster with different architecture from your local machine, append ARCH=<targetarch> e.g. `ARCH=amd64` to the below command
6767
make docker-build IMG=<your-registry>/nginx-gateway-fabric-operator:<tag>
6868

6969
# Push the image

tests/Makefile

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ NGF_VERSION ?= edge## NGF version to be tested
1313
PULL_POLICY = Never## Pull policy for the images
1414
NGINX_CONF_DIR = internal/controller/nginx/conf
1515
SUPPORTED_EXTENDED_FEATURES = HTTPRouteQueryParamMatching,HTTPRouteMethodMatching,HTTPRoutePortRedirect,HTTPRouteSchemeRedirect,HTTPRouteHostRewrite,HTTPRoutePathRewrite,GatewayPort8080,GatewayAddressEmpty,HTTPRouteResponseHeaderModification,HTTPRoutePathRedirect,GatewayHTTPListenerIsolation,GatewayInfrastructurePropagation,HTTPRouteRequestMirror,HTTPRouteRequestMultipleMirrors,HTTPRouteRequestPercentageMirror,HTTPRouteBackendProtocolWebSocket,HTTPRouteParentRefPort,HTTPRouteDestinationPortMatching,GatewayStaticAddresses
16+
SUPPORTED_EXTENDED_FEATURES_OPENSHIFT = HTTPRouteQueryParamMatching,HTTPRouteMethodMatching,HTTPRoutePortRedirect,HTTPRouteSchemeRedirect,HTTPRouteHostRewrite,HTTPRoutePathRewrite,GatewayPort8080,GatewayAddressEmpty,HTTPRouteResponseHeaderModification,HTTPRoutePathRedirect,GatewayHTTPListenerIsolation,GatewayInfrastructurePropagation,HTTPRouteRequestMirror,HTTPRouteRequestMultipleMirrors,HTTPRouteRequestPercentageMirror,HTTPRouteBackendProtocolWebSocket,HTTPRouteParentRefPort,HTTPRouteDestinationPortMatching
1617
STANDARD_CONFORMANCE_PROFILES = GATEWAY-HTTP,GATEWAY-GRPC
1718
EXPERIMENTAL_CONFORMANCE_PROFILES = GATEWAY-TLS
1819
CONFORMANCE_PROFILES = $(STANDARD_CONFORMANCE_PROFILES) # by default we use the standard conformance profiles. If experimental is enabled we override this and add the experimental profiles.
20+
SKIP_TESTS_OPENSHIFT = HTTPRouteServiceTypes # Doesn't work on OpenShift due to security restrictions
1921
SKIP_TESTS =
2022
CEL_TEST_TARGET =
2123

@@ -40,7 +42,7 @@ update-go-modules: ## Update the gateway-api go modules to latest main version
4042

4143
.PHONY: build-test-runner-image
4244
build-test-runner-image: ## Build conformance test runner image
43-
docker build -t $(CONFORMANCE_PREFIX):$(CONFORMANCE_TAG) -f conformance/Dockerfile .
45+
docker build --platform $(GOOS)/$(GOARCH) -t $(CONFORMANCE_PREFIX):$(CONFORMANCE_TAG) -f conformance/Dockerfile .
4446

4547
.PHONY: build-crossplane-image
4648
build-crossplane-image: ## Build the crossplane image
@@ -58,6 +60,26 @@ run-conformance-tests: ## Run conformance tests
5860
--report-output=output.txt; cat output.txt" | tee output.txt
5961
./scripts/check-pod-exit-code.sh
6062
sed -e '1,/CONFORMANCE PROFILE/d' output.txt > conformance-profile.yaml
63+
grpc_core_result=`yq '.profiles[0].core.result' conformance-profile.yaml`; \
64+
http_core_result=`yq '.profiles[1].core.result' conformance-profile.yaml`; \
65+
http_extended_result=`yq '.profiles[1].extended.result' conformance-profile.yaml`; \
66+
if [ "$$grpc_core_result" != "failure" ] && [ "$$http_core_result" != "failure" ] && [ "$$http_extended_result" != "failure" ] ; then \
67+
exit 0; \
68+
else \
69+
exit 2; \
70+
fi
71+
72+
.PHONY: run-conformance-tests-openshift
73+
run-conformance-tests-openshift: ## Run conformance tests on OpenShift (skips tests incompatible with OpenShift)
74+
kubectl apply -f conformance/conformance-rbac.yaml
75+
kubectl run -i conformance \
76+
--image=$(CONFORMANCE_PREFIX):$(CONFORMANCE_TAG) --image-pull-policy=Always \
77+
--overrides='{ "spec": { "serviceAccountName": "conformance" } }' \
78+
--restart=Never -- sh -c "go test -v . -tags conformance,experimental -args --gateway-class=$(GATEWAY_CLASS) \
79+
--supported-features=$(SUPPORTED_EXTENDED_FEATURES_OPENSHIFT) --version=$(NGF_VERSION) --skip-tests=$(SKIP_TESTS_OPENSHIFT) --conformance-profiles=$(CONFORMANCE_PROFILES) \
80+
--service-type=$(GW_SERVICE_TYPE) --report-output=output.txt; cat output.txt" | tee output.txt
81+
./scripts/check-pod-exit-code.sh
82+
sed -e '1,/CONFORMANCE PROFILE/d' output.txt > conformance-profile.yaml
6183
rm output.txt
6284
grpc_core_result=`yq '.profiles[0].core.result' conformance-profile.yaml`; \
6385
http_core_result=`yq '.profiles[1].core.result' conformance-profile.yaml`; \

tests/OPENSHIFT_CONFORMANCE.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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

tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ All the commands below are executed from the `tests` directory. You can see all
5656

5757
### Step 1 - Create a Kubernetes cluster
5858

59-
**Important**: Functional/conformance tests can only be run on a `kind` cluster. NFR tests can only be run on a GKE cluster.
59+
**Important**: Functional tests can only be run on a `kind` cluster. Conformance tests can be run on `kind` or OpenShift clusters (see [OPENSHIFT_CONFORMANCE.md](OPENSHIFT_CONFORMANCE.md) for OpenShift instructions). NFR tests can only be run on a GKE cluster.
6060

6161
To create a local `kind` cluster:
6262

0 commit comments

Comments
 (0)