This guide will assist you in setting up your development environment for NGINX Gateway Fabric, covering the steps to build, install, and execute tasks necessary for submitting pull requests. By following this guide, you'll have a fully prepared development environment that allows you to contribute to the project effectively.
Follow these steps to set up your development environment.
-
Install:
-
Docker v18.09+
-
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
brew install pre-commit
and then run
pre-commit install
in the project root directory to install the git hooks.
-
Clone your repository, and install the project dependencies:
git clone https://github.com/<YOUR-USERNAME>/nginx-gateway-fabric.git cd nginx-gateway-fabric
make deps
To build the binary, run the make build command from the project's root directory:
make build
This command will build the binary and output it to the /build/.out
directory.
To build the NGINX Gateway Fabric and NGINX container images from source run the following make command:
make TAG=$(whoami) build-images
This will build the docker images nginx-gateway-fabric:<your-user>
and nginx-gateway-fabric/nginx:<your-user>
.
-
Create a
kind
cluster:make create-kind-cluster
-
Load the previously built images onto your
kind
cluster:kind load docker-image nginx-gateway-fabric:$(whoami) nginx-gateway-fabric/nginx:$(whoami)
-
Install Gateway API Resources
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v0.8.1/standard-install.yaml
-
Install NGF using your custom image and expose NGF with a NodePort Service:
-
To install with Helm (where your release name is
my-release
):helm install my-release ./deploy/helm-chart --create-namespace --wait --set service.type=NodePort --set nginxGateway.image.repository=nginx-gateway-fabric --set nginxGateway.image.tag=$(whoami) --set nginxGateway.image.pullPolicy=Never --set nginx.image.repository=nginx-gateway-fabric/nginx --set nginx.image.tag=$(whoami) --set nginx.image.pullPolicy=Never -n nginx-gateway
For more information on helm configuration options see the Helm README.
-
To install with manifests:
make generate-manifests HELM_TEMPLATE_COMMON_ARGS="--set nginxGateway.image.repository=nginx-gateway-fabric --set nginxGateway.image.tag=$(whoami) --set nginxGateway.image.pullPolicy=Never --set nginx.image.repository=nginx-gateway-fabric/nginx --set nginx.image.tag=$(whoami) --set nginx.image.pullPolicy=Never" kubectl apply -f deploy/manifests/crds kubectl apply -f deploy/manifests/nginx-gateway.yaml kubectl apply -f deploy/manifests/service/nodeport.yaml
-
To make sure NGF is running properly, try out the examples.
To run all the unit tests, run the make unit-test command from the project's root directory:
make unit-test
For more details on testing, see the testing documentation.
To run Gateway API conformance tests, please follow the instructions on this page.
To lint the code, run the following make command from the project's root directory:
make lint
Note fieldalignment errors can be fixed by running:
fieldalignment -fix <path-to-package>
Run the following make command from the project's root directory to lint the Helm Chart code:
make lint-helm
To ensure all the generated code is up to date, run the following make command from the project's root directory:
make generate
To update the generated manifests, run the following make command from the project's root directory:
make generate-manifests