diff --git a/.goreleaser.yml b/.goreleaser.yml index a05a5ec53c..a5793d31f6 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -55,3 +55,12 @@ milestones: snapshot: name_template: 'edge' + +before: + hooks: + - make crds-release-file + +release: + extra_files: + - glob: ./build/out/crds.yaml + - glob: ./deploy/manifests/nginx-gateway.yaml diff --git a/Makefile b/Makefile index f1242daa1b..ed7791fcfb 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,19 @@ generate-crds: ## Generate CRDs and Go types using kubebuilder go run sigs.k8s.io/controller-tools/cmd/controller-gen crd paths=./apis/... output:crd:dir=deploy/helm-chart/crds go run sigs.k8s.io/controller-tools/cmd/controller-gen object paths=./apis/... +.PHONY: generate-manifests +generate-manifests: ## Generate manifests using Helm. + cp $(CHART_DIR)/crds/* $(MANIFEST_DIR)/crds/ + 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 + helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) --set metrics.enable=false -n nginx-gateway -s templates/deployment.yaml > conformance/provisioner/static-deployment.yaml + helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) -n nginx-gateway -s templates/service.yaml > $(strip $(MANIFEST_DIR))/service/loadbalancer.yaml + 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 + 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 + +.PHONY: crds-release-file +crds-release-file: ## Generate combined crds file for releases + scripts/combine-crds.sh + .PHONY: clean clean: ## Clean the build -rm -r $(OUT_DIR) @@ -132,14 +145,5 @@ debug-build: build ## Build binary with debug info, symbols, and no optimization .PHONY: build-ngf-debug-image build-ngf-debug-image: debug-build build-ngf-image ## Build NGF image with debug binary -.PHONY: generate-manifests -generate-manifests: ## Generate manifests using Helm. - cp $(CHART_DIR)/crds/* $(MANIFEST_DIR)/crds/ - 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 - helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) --set metrics.enable=false -n nginx-gateway -s templates/deployment.yaml > conformance/provisioner/static-deployment.yaml - helm template nginx-gateway $(CHART_DIR) $(HELM_TEMPLATE_COMMON_ARGS) -n nginx-gateway -s templates/service.yaml > $(strip $(MANIFEST_DIR))/service/loadbalancer.yaml - 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 - 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 - .PHONY: dev-all dev-all: deps fmt njs-fmt vet lint unit-test njs-unit-test ## Run all the development checks diff --git a/scripts/combine-crds.sh b/scripts/combine-crds.sh new file mode 100755 index 0000000000..a05e5cb043 --- /dev/null +++ b/scripts/combine-crds.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +mkdir -p build/out + +CRD_FILE=build/out/crds.yaml +echo "# NGINX Gateway API CustomResourceDefinitions" > ${CRD_FILE} + +for file in `ls deploy/manifests/crds/*.yaml`; do + echo "#" >> ${CRD_FILE} + echo "# $file" >> ${CRD_FILE} + echo "#" >> ${CRD_FILE} + cat $file >> ${CRD_FILE} +done