2
2
VERSION = edge
3
3
GIT_COMMIT = $(shell git rev-parse HEAD || echo "unknown")
4
4
DATE = $(shell date -u +"% Y-% m-% dT% H:% M:% SZ")
5
+ SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST ) ) )
5
6
MANIFEST_DIR = $(CURDIR ) /deploy/manifests
6
- CHART_DIR = $(CURDIR ) / charts/nginx-gateway-fabric
7
+ CHART_DIR = $(SELF_DIR ) charts/nginx-gateway-fabric
7
8
NGINX_CONF_DIR = internal/mode/static/nginx/conf
8
9
NJS_DIR = internal/mode/static/nginx/modules/src
9
10
NGINX_DOCKER_BUILD_PLUS_ARGS = --secret id=nginx-repo.crt,src=nginx-repo.crt --secret id=nginx-repo.key,src=nginx-repo.key
10
11
BUILD_AGENT =local
12
+ PLUS_ENABLED ?= false
11
13
12
14
PROD_TELEMETRY_ENDPOINT = oss.edge.df.f5.com:443
13
15
# the telemetry related variables below are also configured in goreleaser.yml
@@ -16,7 +18,7 @@ TELEMETRY_ENDPOINT=# if empty, NGF will report telemetry in its logs at debug le
16
18
TELEMETRY_ENDPOINT_INSECURE = false
17
19
18
20
GW_API_VERSION = 1.1.0
19
- ENABLE_EXPERIMENTAL = false
21
+ ENABLE_EXPERIMENTAL ? = false
20
22
NODE_VERSION = $(shell cat .nvmrc)
21
23
22
24
# go build flags - should not be overridden by the user
@@ -31,18 +33,23 @@ NGINX_PLUS_PREFIX ?= $(PREFIX)/nginx-plus## The name of the nginx plus image. Fo
31
33
TAG ?= $(VERSION:v%=% ) # # The tag of the image. For example, 1.1.0
32
34
TARGET ?= local# # The target of the build. Possible values: local and container
33
35
KIND_KUBE_CONFIG=$${HOME}/.kube/kind/config# # The location of the kind kubeconfig
34
- OUT_DIR ?= $( CURDIR ) / build/out# # The folder where the binary will be stored
36
+ OUT_DIR ?= build/out# # The folder where the binary will be stored
35
37
GOARCH ?= amd64# # The architecture of the image and/or binary. For example: amd64 or arm64
36
38
GOOS ?= linux# # The OS of the image and/or binary. For example: linux or darwin
37
39
override HELM_TEMPLATE_COMMON_ARGS += --set creator=template --set nameOverride=nginx-gateway# # The common options for the Helm template command.
38
40
override HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE += --set service.create=false# # The options to be passed to the full Helm templating command only.
39
41
override NGINX_DOCKER_BUILD_OPTIONS += --build-arg NJS_DIR=$(NJS_DIR ) --build-arg NGINX_CONF_DIR=$(NGINX_CONF_DIR ) --build-arg BUILD_AGENT=$(BUILD_AGENT )
42
+
40
43
.DEFAULT_GOAL := help
41
44
45
+ ifneq (,$(findstring plus,$(MAKECMDGOALS ) ) )
46
+ PLUS_ENABLED = true
47
+ endif
48
+
42
49
.PHONY : help
43
50
help : Makefile # # Display this help
44
- @grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "; printf "Usage:\n\n make \033[36m<target>\033[0m [VARIABLE=value...]\n\nTargets:\n\n"}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
45
- @grep -E ' ^(override )?[a-zA-Z_-]+ \??\+?= .*?## .*$$' $< | sort | awk ' BEGIN {FS = " \\??\\+?= .*?## "; printf "\nVariables:\n\n"}; {gsub(/override /, "", $$1); printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
51
+ @grep -hE ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "; printf "Usage:\n\n make \033[36m<target>\033[0m [VARIABLE=value...]\n\nTargets:\n\n"}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
52
+ @grep -hE ' ^(override )?[a-zA-Z_-]+ \??\+?= .*?## .*$$' $( MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = " \\??\\+?= .*?## "; printf "\nVariables:\n\n"}; {gsub(/override /, "", $$1); printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
46
53
47
54
.PHONY : build-prod-images
48
55
build-prod-images : build-prod-ngf-image build-prod-nginx-image # # Build the NGF and nginx docker images for production
@@ -62,21 +69,21 @@ build-prod-ngf-image: build-ngf-image ## Build the NGF docker image for producti
62
69
63
70
.PHONY : build-ngf-image
64
71
build-ngf-image : check-for-docker build # # Build the NGF docker image
65
- docker build --platform linux/$(GOARCH ) --build-arg BUILD_AGENT=$(BUILD_AGENT ) --target $(strip $(TARGET ) ) -f build/Dockerfile -t $(strip $(PREFIX ) ) :$(strip $(TAG ) ) .
72
+ docker build --platform linux/$(GOARCH ) --build-arg BUILD_AGENT=$(BUILD_AGENT ) --target $(strip $(TARGET ) ) -f $( SELF_DIR ) build/Dockerfile -t $(strip $(PREFIX ) ) :$(strip $(TAG ) ) $( strip $( SELF_DIR ) )
66
73
67
74
.PHONY : build-prod-nginx-image
68
75
build-prod-nginx-image : build-nginx-image # # Build the custom nginx image for production
69
76
70
77
.PHONY : build-nginx-image
71
78
build-nginx-image : check-for-docker # # Build the custom nginx image
72
- docker build --platform linux/$(GOARCH ) $(strip $(NGINX_DOCKER_BUILD_OPTIONS ) ) -f build/Dockerfile.nginx -t $(strip $(NGINX_PREFIX ) ) :$(strip $(TAG ) ) .
79
+ docker build --platform linux/$(GOARCH ) $(strip $(NGINX_DOCKER_BUILD_OPTIONS ) ) -f $( SELF_DIR ) build/Dockerfile.nginx -t $(strip $(NGINX_PREFIX ) ) :$(strip $(TAG ) ) $( strip $( SELF_DIR ) )
73
80
74
81
.PHONY : build-prod-nginx-plus-image
75
82
build-prod-nginx-plus-image : build-nginx-plus-image # # Build the custom nginx plus image for production
76
83
77
84
.PHONY : build-nginx-plus-image
78
85
build-nginx-plus-image : check-for-docker # # Build the custom nginx plus image
79
- docker build --platform linux/$(GOARCH ) $(strip $(NGINX_DOCKER_BUILD_OPTIONS ) ) $(strip $(NGINX_DOCKER_BUILD_PLUS_ARGS ) ) -f build/Dockerfile.nginxplus -t $(strip $(NGINX_PLUS_PREFIX ) ) :$(strip $(TAG ) ) .
86
+ docker build --platform linux/$(GOARCH ) $(strip $(NGINX_DOCKER_BUILD_OPTIONS ) ) $(strip $(NGINX_DOCKER_BUILD_PLUS_ARGS ) ) -f $( SELF_DIR ) build/Dockerfile.nginxplus -t $(strip $(NGINX_PLUS_PREFIX ) ) :$(strip $(TAG ) ) $( strip $( SELF_DIR ) )
80
87
81
88
.PHONY : check-for-docker
82
89
check-for-docker : # # Check if Docker is installed
@@ -86,7 +93,7 @@ check-for-docker: ## Check if Docker is installed
86
93
build : # # Build the binary
87
94
ifeq (${TARGET},local)
88
95
@go version || (code=$$?; printf "\033[0;31mError\033[0m: unable to build locally\n"; exit $$code)
89
- CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -trimpath -a -ldflags "$(GO_LINKER_FLAGS)" $(ADDITIONAL_GO_BUILD_FLAGS) -o $(OUT_DIR)/gateway github.com/nginxinc/nginx-gateway-fabric/cmd/gateway
96
+ CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -C $(SELF_DIR) - trimpath -a -ldflags "$(GO_LINKER_FLAGS)" $(ADDITIONAL_GO_BUILD_FLAGS) -o $(OUT_DIR)/gateway github.com/nginxinc/nginx-gateway-fabric/cmd/gateway
90
97
endif
91
98
92
99
.PHONY : build-goreleaser
@@ -103,13 +110,25 @@ generate-crds: ## Generate CRDs and Go types using kubebuilder
103
110
go run sigs.k8s.io/controller-tools/cmd/controller-gen crd object paths=./apis/... output:crd:artifacts:config=config/crd/bases
104
111
kubectl kustomize config/crd > deploy/crds.yaml
105
112
113
+ .PHONY : install-crds
114
+ install-crds : # # Install CRDs
115
+ kubectl kustomize config/crd | kubectl apply -f -
116
+
117
+ .PHONY : install-gateway-crds
118
+ install-gateway-crds : # # Install Gateway API CRDs
119
+ $(SELF_DIR ) tests/scripts/install-gateway.sh $(GW_API_VERSION ) $(ENABLE_EXPERIMENTAL )
120
+
121
+ .PHONY : uninstall-gateway-crds
122
+ uninstall-gateway-crds : # # Uninstall Gateway API CRDs
123
+ $(SELF_DIR ) tests/scripts/uninstall-gateway.sh $(GW_API_VERSION ) $(ENABLE_EXPERIMENTAL )
124
+
106
125
.PHONY : generate-manifests
107
126
generate-manifests : # # Generate manifests using Helm.
108
127
helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE ) -n nginx-gateway | cat $(strip $(MANIFEST_DIR ) ) /namespace.yaml - > $(strip $(MANIFEST_DIR ) ) /nginx-gateway.yaml
109
128
helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE ) --set nginx.plus=true --set nginx.image.repository=$(NGINX_PLUS_PREFIX ) -n nginx-gateway | cat $(strip $(MANIFEST_DIR ) ) /namespace.yaml - > $(strip $(MANIFEST_DIR ) ) /nginx-plus-gateway.yaml
110
129
helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE ) --set nginxGateway.gwAPIExperimentalFeatures.enable=true -n nginx-gateway | cat $(strip $(MANIFEST_DIR ) ) /namespace.yaml - > $(strip $(MANIFEST_DIR ) ) /nginx-gateway-experimental.yaml
111
130
helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) $(HELM_TEMPLATE_EXTRA_ARGS_FOR_ALL_MANIFESTS_FILE ) --set nginxGateway.gwAPIExperimentalFeatures.enable=true --set nginx.plus=true --set nginx.image.repository=$(NGINX_PLUS_PREFIX ) -n nginx-gateway | cat $(strip $(MANIFEST_DIR ) ) /namespace.yaml - > $(strip $(MANIFEST_DIR ) ) /nginx-plus-gateway-experimental.yaml
112
- helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) --set metrics.enable=false --set nginxGateway.productTelemetry.enable=false -n nginx-gateway -s templates/deployment.yaml > conformance/provisioner /static-deployment.yaml
131
+ helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) --set metrics.enable=false --set nginxGateway.productTelemetry.enable=false -n nginx-gateway -s templates/deployment.yaml > config/tests /static-deployment.yaml
113
132
helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) -n nginx-gateway -s templates/service.yaml > $(strip $(MANIFEST_DIR ) ) /service/loadbalancer.yaml
114
133
helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) --set service.annotations.' service\.beta\.kubernetes\.io\/aws-load-balancer-type' =" nlb" -n nginx-gateway -s templates/service.yaml > $(strip $(MANIFEST_DIR ) ) /service/loadbalancer-aws-nlb.yaml
115
134
helm template nginx-gateway $(CHART_DIR ) $(HELM_TEMPLATE_COMMON_ARGS ) --set service.type=NodePort --set service.externalTrafficPolicy=" " -n nginx-gateway -s templates/service.yaml > $(strip $(MANIFEST_DIR ) ) /service/nodeport.yaml
@@ -128,7 +147,7 @@ deps: ## Add missing and remove unused modules, verify deps and download them to
128
147
129
148
.PHONY : create-kind-cluster
130
149
create-kind-cluster : # # Create a kind cluster
131
- $(eval KIND_IMAGE=$(shell grep -m1 'FROM kindest/node' <conformance/ tests/Dockerfile | awk -F'[ ]' '{print $$2}') )
150
+ $(eval KIND_IMAGE=$(shell grep -m1 'FROM kindest/node' <$( SELF_DIR ) tests/Dockerfile | awk -F'[ ]' '{print $$2}') )
132
151
kind create cluster --image $(KIND_IMAGE )
133
152
kind export kubeconfig --kubeconfig $(KIND_KUBE_CONFIG )
134
153
@@ -189,14 +208,12 @@ install-ngf-local-build: build-images load-images helm-install-local ## Install
189
208
install-ngf-local-build-with-plus : build-images-with-plus load-images-with-plus helm-install-local-with-plus # # Install NGF with NGINX Plus from local build on configured kind cluster.
190
209
191
210
.PHONY : helm-install-local
192
- helm-install-local : # # Helm install NGF on configured kind cluster with local images. To build, load, and install with helm run make install-ngf-local-build.
193
- ./conformance/scripts/install-gateway.sh $(GW_API_VERSION ) $(ENABLE_EXPERIMENTAL )
194
- helm install dev $(CHART_DIR ) --create-namespace --wait --set service.type=NodePort --set nginxGateway.image.repository=$(PREFIX ) --set nginxGateway.image.tag=$(TAG ) --set nginxGateway.image.pullPolicy=Never --set nginx.image.repository=$(NGINX_PREFIX ) --set nginx.image.tag=$(TAG ) --set nginx.image.pullPolicy=Never --set nginxGateway.gwAPIExperimentalFeatures.enable=$(ENABLE_EXPERIMENTAL ) -n nginx-gateway
211
+ helm-install-local : install-gateway-crds # # Helm install NGF on configured kind cluster with local images. To build, load, and install with helm run make install-ngf-local-build.
212
+ helm install nginx-gateway $(CHART_DIR ) --set nginx.image.repository=$(NGINX_PREFIX ) --create-namespace --wait --set nginxGateway.image.pullPolicy=Never --set service.type=NodePort --set nginxGateway.image.repository=$(PREFIX ) --set nginxGateway.image.tag=$(TAG ) --set nginx.image.tag=$(TAG ) --set nginx.image.pullPolicy=Never --set nginxGateway.gwAPIExperimentalFeatures.enable=$(ENABLE_EXPERIMENTAL ) -n nginx-gateway $(HELM_PARAMETERS )
195
213
196
214
.PHONY : helm-install-local-with-plus
197
- helm-install-local-with-plus : # # Helm install NGF with NGINX Plus on configured kind cluster with local images. To build, load, and install with helm run make install-ngf-local-build-with-plus.
198
- ./conformance/scripts/install-gateway.sh $(GW_API_VERSION ) $(ENABLE_EXPERIMENTAL )
199
- helm install dev $(CHART_DIR ) --create-namespace --wait --set service.type=NodePort --set nginxGateway.image.repository=$(PREFIX ) --set nginxGateway.image.tag=$(TAG ) --set nginxGateway.image.pullPolicy=Never --set nginx.image.repository=$(NGINX_PLUS_PREFIX ) --set nginx.image.tag=$(TAG ) --set nginx.image.pullPolicy=Never --set nginx.plus=true --set nginxGateway.gwAPIExperimentalFeatures.enable=$(ENABLE_EXPERIMENTAL ) -n nginx-gateway
215
+ helm-install-local-with-plus : install-gateway-crds # # Helm install NGF with NGINX Plus on configured kind cluster with local images. To build, load, and install with helm run make install-ngf-local-build-with-plus.
216
+ helm install nginx-gateway $(CHART_DIR ) --set nginx.image.repository=$(NGINX_PLUS_PREFIX ) --create-namespace --wait --set nginxGateway.image.pullPolicy=Never --set service.type=NodePort --set nginxGateway.image.repository=$(PREFIX ) --set nginxGateway.image.tag=$(TAG ) --set nginx.image.tag=$(TAG ) --set nginx.image.pullPolicy=Never --set nginxGateway.gwAPIExperimentalFeatures.enable=$(ENABLE_EXPERIMENTAL ) -n nginx-gateway --set nginx.plus=true $(HELM_PARAMETERS )
200
217
201
218
# Debug Targets
202
219
.PHONY : debug-build
0 commit comments