Skip to content

Commit

Permalink
Install webhook in conformance tests on k8s < 1.25
Browse files Browse the repository at this point in the history
  • Loading branch information
kate-osborn committed Nov 16, 2023
1 parent 6665a74 commit d5c70d7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
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
5 changes: 3 additions & 2 deletions conformance/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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,7 +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)
./scripts/install-gateway.sh $(GW_API_VERSION) $(INSTALL_WEBHOOK)
kubectl apply -f $(CRDS)
kubectl apply -f $(NGF_MANIFEST)

Expand Down Expand Up @@ -92,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
1 change: 1 addition & 0 deletions conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ update-ngf-manifest Update the NGF deployment manifest image names an
| 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
13 changes: 13 additions & 0 deletions conformance/scripts/install-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +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 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
6 changes: 6 additions & 0 deletions conformance/scripts/uninstall-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ if [ $1 == "main" ]; then
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 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

0 comments on commit d5c70d7

Please sign in to comment.