This guide will assist you in setting up your development environment for NGINX Kubernetes Gateway, 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:
-
Clone your repository, and install the project dependencies:
git clone https://github.com/<YOUR-USERNAME>/nginx-kubernetes-gateway.git cd nginx-kubernetes-gateway 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 an NGINX Kubernetes Gateway container image from source run the following make command:
make TAG=$(whoami) container
This will build the docker image nginx-kubernetes-gateway:<your-user>
.
-
Create a
kind
cluster:make create-kind-cluster
-
Load the previously built image onto your
kind
cluster:kind load docker-image nginx-kubernetes-gateway:$(whoami)
-
Modify the image name and image pull policy for the
nginx-gateway
container in the NKG deployment manifest. Set the image name to the image you built in the previous step and the image pull policy toIfNotPresent
, so that Kubernetes will not try to pull it from the DockerHub. Once the changes are made, follow the installation instructions to install NKG on yourkind
cluster.Alternatively, you can update the image name and pull policy by using the following command when applying
deployment.yaml
:cat deploy/manifests/deployment.yaml | sed "s|image: ghcr.io/nginxinc/nginx-kubernetes-gateway.*|image: nginx-kubernetes-gateway:$(whoami)|" | sed "s|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|" | kubectl apply -f -
To make sure NKG 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>