Skip to content

Commit

Permalink
Update Gateway API to v1.0.0 (nginxinc#1250)
Browse files Browse the repository at this point in the history
Problems:
- NGF does not support v1.0.0 of Gateway API.
- NGF does not use the official PartiallyInvalid 
condition from Gateway API SDK.
- The Gateway API validating webhook should 
only be installed when Kubernetes version is <1.25

Solutions:
- Update to v1.0.0 of Gateway API
- Replace custom PartiallyInvalid condition with 
the Gateway API condition.
- Add logic to pipeline and conformance scripts 
to conditionally install the webhook.

Co-authored-by: Ciara Stacke <[email protected]>
  • Loading branch information
kate-osborn and ciarams87 authored Nov 16, 2023
1 parent 76c9cb8 commit d939535
Show file tree
Hide file tree
Showing 133 changed files with 1,968 additions and 1,848 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ jobs:
make create-kind-cluster KIND_KUBE_CONFIG=${kube_config}
echo "KUBECONFIG=${kube_config}" >> "$GITHUB_ENV"
kind load docker-image ${{ steps.ngf-meta.outputs.tags }} ${{ steps.nginx-meta.outputs.tags }}
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml
kubectl wait --for=condition=complete job/gateway-api-admission-patch job/gateway-api-admission -n gateway-system
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml
- name: Install Chart
run: >
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ jobs:
ngf_prefix=$(echo ${{ steps.ngf-meta.outputs.tags }} | cut -d ":" -f 1)
ngf_tag=$(echo ${{ steps.ngf-meta.outputs.tags }} | cut -d ":" -f 2)
if [ ${{ github.event_name }} == "schedule" ]; then export GW_API_VERSION=main; fi
if [ ${{ startsWith(matrix.k8s-version, '1.23') || startsWith(matrix.k8s-version, '1.24') }} == "true" ]; then export INSTALL_WEBHOOK=true; fi
make install-ngf-local-no-build NGF_PREFIX=${ngf_prefix} NGF_TAG=${ngf_tag}
working-directory: ./conformance

Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ from the main branch.
The table below summarizes the options regarding the images, manifests, documentation and examples and gives your links
to the correct versions:

| Version | Description | Installation Manifests | Documentation and Examples |
|----------------|------------------------------------------|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Latest release | For production use | [Manifests](https://github.com/nginxinc/nginx-gateway-fabric/tree/v1.0.0/deploy). | [Documentation](https://github.com/nginxinc/nginx-gateway-fabric/tree/v1.0.0/docs). [Examples](https://github.com/nginxinc/nginx-gateway-fabric/tree/v1.0.0/examples). |
| Version | Description | Installation Manifests | Documentation and Examples |
|----------------|------------------------------------------|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Latest release | For production use | [Manifests](https://github.com/nginxinc/nginx-gateway-fabric/tree/v1.0.0/deploy). | [Documentation](https://github.com/nginxinc/nginx-gateway-fabric/tree/v1.0.0/docs). [Examples](https://github.com/nginxinc/nginx-gateway-fabric/tree/v1.0.0/examples). |
| Edge | For experimental use and latest features | [Manifests](https://github.com/nginxinc/nginx-gateway-fabric/tree/main/deploy). | [Documentation](https://github.com/nginxinc/nginx-gateway-fabric/tree/main/docs). [Examples](https://github.com/nginxinc/nginx-gateway-fabric/tree/main/examples). |

### Versioning
Expand All @@ -61,15 +61,15 @@ the [Issue Lifecycle](ISSUE_LIFECYCLE.md) document for information on issue crea
The following table lists the software versions NGINX Gateway Fabric supports.

| NGINX Gateway Fabric | Gateway API | Kubernetes | NGINX OSS |
|--------------------------|-------------|------------|-----------|
| Edge | 0.8.1 | 1.23+ | 1.25.2 |
| 1.0.0 | 0.8.1 | 1.23+ | 1.25.2 |
| 0.6.0 | 0.8.0 | 1.23+ | 1.25.2 |
| 0.5.0 | 0.7.1 | 1.21+ | 1.25.x * |
| 0.4.0 | 0.7.1 | 1.21+ | 1.25.x * |
| 0.3.0 | 0.6.2 | 1.21+ | 1.23.x * |
| 0.2.0 | 0.5.1 | 1.21+ | 1.21.x * |
| 0.1.0 | 0.5.0 | 1.19+ | 1.21.3 |
|----------------------|-------------|------------|-----------|
| Edge | 1.0.0 | 1.23+ | 1.25.3 |
| 1.0.0 | 0.8.1 | 1.23+ | 1.25.2 |
| 0.6.0 | 0.8.0 | 1.23+ | 1.25.2 |
| 0.5.0 | 0.7.1 | 1.21+ | 1.25.x * |
| 0.4.0 | 0.7.1 | 1.21+ | 1.25.x * |
| 0.3.0 | 0.6.2 | 1.21+ | 1.23.x * |
| 0.2.0 | 0.5.1 | 1.21+ | 1.21.x * |
| 0.1.0 | 0.5.0 | 1.19+ | 1.21.3 |

\*the installation manifests use the minor version of NGINX container image (e.g. 1.25) and the patch version is not
specified. This means that the latest available patch version is used.
Expand Down
2 changes: 1 addition & 1 deletion cmd/gateway/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

const (
// nolint:lll
// Regex from: https://github.com/kubernetes-sigs/gateway-api/blob/v0.8.1/apis/v1beta1/shared_types.go#L551
// Regex from: https://github.com/kubernetes-sigs/gateway-api/blob/v1.0.0/apis/v1/shared_types.go#L640
controllerNameRegex = `^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\/[A-Za-z0-9\/\-._~%!$&'()*+,;=:]+$` //nolint:lll
)

Expand Down
8 changes: 4 additions & 4 deletions conformance/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NGF_TAG = edge
NGF_PREFIX = nginx-gateway-fabric
NGINX_IMAGE_NAME = $(NGF_PREFIX)/nginx
GW_API_VERSION ?= 0.8.1
GW_API_VERSION ?= 1.0.0
GATEWAY_CLASS = nginx
SUPPORTED_FEATURES = HTTPRoute,HTTPRouteQueryParamMatching,HTTPRouteMethodMatching,HTTPRoutePortRedirect,HTTPRouteSchemeRedirect,GatewayClassObservedGenerationBump
KIND_IMAGE ?= $(shell grep -m1 'FROM kindest/node' <tests/Dockerfile | awk -F'[ ]' '{print $$2}')
Expand All @@ -13,6 +13,7 @@ CRDS=../deploy/manifests/crds/
STATIC_MANIFEST=provisioner/static-deployment.yaml
PROVISIONER_MANIFEST=provisioner/provisioner.yaml
NGINX_IMAGE=$(shell yq '.spec.template.spec.containers[1].image as $$nginx_ver | $$nginx_ver' $(STATIC_MANIFEST))
INSTALL_WEBHOOK ?= false
.DEFAULT_GOAL := help

.PHONY: help
Expand Down Expand Up @@ -47,8 +48,7 @@ load-images: ## Load NGF and NGINX images on configured kind cluster

.PHONY: prepare-ngf-dependencies
prepare-ngf-dependencies: update-ngf-manifest ## Install NGF dependencies on configured kind cluster
./scripts/install-gateway.sh $(GW_API_VERSION)
kubectl wait --for=condition=available --timeout=60s deployment gateway-api-admission-server -n gateway-system
./scripts/install-gateway.sh $(GW_API_VERSION) $(INSTALL_WEBHOOK)
kubectl apply -f $(CRDS)
kubectl apply -f $(NGF_MANIFEST)

Expand Down Expand Up @@ -93,7 +93,7 @@ uninstall-ngf: uninstall-k8s-components undo-manifests-update ## Uninstall NGF o
.PHONY: uninstall-k8s-components
uninstall-k8s-components: ## Uninstall installed components on configured kind cluster
-kubectl delete -f $(NGF_MANIFEST)
./scripts/uninstall-gateway.sh $(GW_API_VERSION)
./scripts/uninstall-gateway.sh $(GW_API_VERSION) $(INSTALL_WEBHOOK)
kubectl delete clusterrole nginx-gateway-provisioner
kubectl delete clusterrolebinding nginx-gateway-provisioner

Expand Down
35 changes: 18 additions & 17 deletions conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,24 @@ update-ngf-manifest Update the NGF deployment manifest image names an

**Note:** The following variables are configurable when running the below `make` commands:

| Variable | Default | Description |
|-------------------------|---------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| TAG | latest | The tag for the conformance test image |
| PREFIX | conformance-test-runner | The prefix for the conformance test image |
| NGF_TAG | edge | The tag for the locally built NGF image |
| NGF_PREFIX | nginx-gateway-fabric | The prefix for the locally built NGF image |
| GW_API_VERSION | 0.8.1 | Tag for the Gateway API version to check out. Set to `main` to get the latest version |
| KIND_IMAGE | Latest kind image, as defined in the tests/Dockerfile | The kind image to use |
| KIND_KUBE_CONFIG | ~/.kube/kind/config | The location of the kubeconfig |
| GATEWAY_CLASS | nginx | The gateway class that should be used for the tests |
| SUPPORTED_FEATURES | HTTPRoute,HTTPRouteQueryParamMatching, HTTPRouteMethodMatching,HTTPRoutePortRedirect, HTTPRouteSchemeRedirect | The supported features that should be tested by the conformance tests. Ensure the list is comma separated with no spaces. |
| EXEMPT_FEATURES | ReferenceGrant | The features that should not be tested by the conformance tests |
| NGINX_IMAGE | as defined in the provisioner/static-deployment.yaml file | The NGINX image for the NGF deployments |
| NGF_MANIFEST | ../deploy/manifests/nginx-gateway.yaml | The location of the NGF manifest |
| SERVICE_MANIFEST | ../deploy/manifests/service/nodeport.yaml | The location of the NGF Service manifest |
| STATIC_MANIFEST | provisioner/static-deployment.yaml | The location of the NGF static deployment manifest |
| PROVISIONER_MANIFEST | provisioner/provisioner.yaml | The location of the NGF provisioner manifest |
| Variable | Default | Description |
|----------------------|---------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| TAG | latest | The tag for the conformance test image |
| PREFIX | conformance-test-runner | The prefix for the conformance test image |
| NGF_TAG | edge | The tag for the locally built NGF image |
| NGF_PREFIX | nginx-gateway-fabric | The prefix for the locally built NGF image |
| GW_API_VERSION | 1.0.0 | Tag for the Gateway API version to check out. Set to `main` to get the latest version |
| KIND_IMAGE | Latest kind image, as defined in the tests/Dockerfile | The kind image to use |
| KIND_KUBE_CONFIG | ~/.kube/kind/config | The location of the kubeconfig |
| GATEWAY_CLASS | nginx | The gateway class that should be used for the tests |
| SUPPORTED_FEATURES | HTTPRoute,HTTPRouteQueryParamMatching, HTTPRouteMethodMatching,HTTPRoutePortRedirect, HTTPRouteSchemeRedirect | The supported features that should be tested by the conformance tests. Ensure the list is comma separated with no spaces. |
| EXEMPT_FEATURES | ReferenceGrant | The features that should not be tested by the conformance tests |
| NGINX_IMAGE | as defined in the provisioner/static-deployment.yaml file | The NGINX image for the NGF deployments |
| NGF_MANIFEST | ../deploy/manifests/nginx-gateway.yaml | The location of the NGF manifest |
| SERVICE_MANIFEST | ../deploy/manifests/service/nodeport.yaml | The location of the NGF Service manifest |
| STATIC_MANIFEST | provisioner/static-deployment.yaml | The location of the NGF static deployment manifest |
| PROVISIONER_MANIFEST | provisioner/provisioner.yaml | The location of the NGF provisioner manifest |
| INSTALL_WEBHOOK | false | Install the Gateway API Validating Webhook. Necessary for Kubernetes versions < 1.25. |

### Step 1 - Create a kind Cluster

Expand Down
14 changes: 13 additions & 1 deletion conformance/scripts/install-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@ if [ -z $1 ]; then
exit 1
fi

if [ -z $2 ]; then
echo "install webhook argument not set; exiting"
exit 1
fi

if [ $1 == "main" ]; then
temp_dir=$(mktemp -d)
cd ${temp_dir}
curl -s https://codeload.github.com/kubernetes-sigs/gateway-api/tar.gz/main | tar -xz --strip=2 gateway-api-main/config
kubectl apply -f webhook
kubectl apply -f crd/standard
if [ $2 == "true" ]; then
kubectl apply -f webhook
kubectl wait --for=condition=available --timeout=60s deployment gateway-api-admission-server -n gateway-system
fi
rm -rf ${temp_dir}
else
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v$1/standard-install.yaml
if [ $2 == "true" ]; then
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v$1/webhook-install.yaml
kubectl wait --for=condition=available --timeout=60s deployment gateway-api-admission-server -n gateway-system
fi
fi
7 changes: 6 additions & 1 deletion conformance/scripts/uninstall-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ if [ $1 == "main" ]; then
temp_dir=$(mktemp -d)
cd ${temp_dir}
curl -s https://codeload.github.com/kubernetes-sigs/gateway-api/tar.gz/main | tar -xz --strip=2 gateway-api-main/config
kubectl delete -f webhook
kubectl delete -f crd/standard
if [ $2 == "true" ]; then
kubectl delete -f webhook
fi
rm -rf ${temp_dir}
else
kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v$1/standard-install.yaml
if [ $2 == "true" ]; then
kubectl delete -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v$1/webhook-install.yaml
fi
fi
2 changes: 2 additions & 0 deletions conformance/tests/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
v1 "sigs.k8s.io/gateway-api/apis/v1"
"sigs.k8s.io/gateway-api/apis/v1alpha2"
"sigs.k8s.io/gateway-api/apis/v1beta1"
"sigs.k8s.io/gateway-api/conformance/apis/v1alpha1"
Expand All @@ -43,6 +44,7 @@ func TestConformance(t *testing.T) {
g.Expect(err).To(BeNil())

g.Expect(v1alpha2.AddToScheme(client.Scheme())).To(Succeed())
g.Expect(v1.AddToScheme(client.Scheme())).To(Succeed())
g.Expect(v1beta1.AddToScheme(client.Scheme())).To(Succeed())

supportedFeatures := suite.ParseSupportedFeatures(*flags.SupportedFeatures)
Expand Down
Loading

0 comments on commit d939535

Please sign in to comment.