Skip to content

Commit f288dbf

Browse files
committed
Use kustomize to generate a single CRDs file (nginx#1886)
Problem: We want to have a single CRDs file to make it easier to install/uninstall our CRDs. Solution: Use kustomize to create a single file
1 parent f16681d commit f288dbf

File tree

12 files changed

+1569
-289
lines changed

12 files changed

+1569
-289
lines changed

.goreleaser.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,8 @@ milestones:
6464
snapshot:
6565
name_template: "edge"
6666

67-
before:
68-
hooks:
69-
- make crds-release-file
70-
7167
release:
7268
extra_files:
73-
- glob: ./build/out/crds.yaml
7469
- glob: ./deploy/manifests/nginx-gateway.yaml
7570
- glob: ./deploy/manifests/nginx-plus-gateway.yaml
7671
- glob: ./deploy/manifests/nginx-gateway-experimental.yaml

.yamllint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ yaml-files:
66
ignore:
77
- charts/nginx-gateway-fabric
88
- config/crd/bases/
9+
- deploy/crds.yaml
910
- .github/workflows/
1011

1112
rules:

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ generate: ## Run go generate
101101
.PHONY: generate-crds
102102
generate-crds: ## Generate CRDs and Go types using kubebuilder
103103
go run sigs.k8s.io/controller-tools/cmd/controller-gen crd object paths=./apis/... output:crd:artifacts:config=config/crd/bases
104+
kubectl kustomize config/crd >deploy/crds.yaml
104105

105106
.PHONY: generate-manifests
106107
generate-manifests: ## Generate manifests using Helm.
@@ -113,10 +114,6 @@ generate-manifests: ## Generate manifests using Helm.
113114
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
114115
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
115116

116-
.PHONY: crds-release-file
117-
crds-release-file: ## Generate combined crds file for releases
118-
scripts/combine-crds.sh
119-
120117
.PHONY: clean
121118
clean: ## Clean the build
122119
-rm -r $(OUT_DIR)

charts/nginx-gateway-fabric/README.md

Lines changed: 52 additions & 52 deletions
Large diffs are not rendered by default.

config/crd/kustomization.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
resources:
2+
- bases/gateway.nginx.org_clientsettingspolicies.yaml
3+
- bases/gateway.nginx.org_nginxgateways.yaml
4+
- bases/gateway.nginx.org_nginxproxies.yaml
5+
- bases/gateway.nginx.org_observabilitypolicies.yaml

conformance/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ KIND_KUBE_CONFIG=$${HOME}/.kube/kind/config
1111
CONFORMANCE_TAG = latest
1212
CONFORMANCE_PREFIX = conformance-test-runner
1313
NGF_MANIFEST=../deploy/manifests/nginx-gateway.yaml
14-
CRDS=../deploy/manifests/crds/
1514
STATIC_MANIFEST=provisioner/static-deployment.yaml
1615
PROVISIONER_MANIFEST=provisioner/provisioner.yaml
1716
ENABLE_EXPERIMENTAL ?= false
@@ -66,13 +65,13 @@ load-images-with-plus: ## Load NGF and NGINX Plus images on configured kind clus
6665
.PHONY: prepare-ngf-dependencies
6766
prepare-ngf-dependencies: update-ngf-manifest ## Install NGF dependencies on configured kind cluster
6867
./scripts/install-gateway.sh $(GW_API_VERSION) $(ENABLE_EXPERIMENTAL)
69-
kubectl apply -f $(CRDS)
68+
kubectl kustomize ../config/crd | kubectl apply -f -
7069
kubectl apply -f $(NGF_MANIFEST)
7170

7271
.PHONY: prepare-ngf-dependencies-with-plus
7372
prepare-ngf-dependencies-with-plus: update-ngf-manifest-with-plus ## Install NGF dependencies with Plus on configured kind cluster
7473
./scripts/install-gateway.sh $(GW_API_VERSION)
75-
kubectl apply -f $(CRDS)
74+
kubectl kustomize ../config/crd | kubectl apply -f -
7675
kubectl apply -f $(NGF_MANIFEST)
7776

7877
.PHONY: deploy-updated-provisioner

deploy/crds.yaml

Lines changed: 1309 additions & 0 deletions
Large diffs are not rendered by default.

deploy/manifests/crds

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/developer/quickstart.md

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,34 @@ fully prepared development environment that allows you to contribute to the proj
99
Follow these steps to set up your development environment.
1010

1111
1. Install:
12-
- [Go](https://golang.org/doc/install) v1.21.0+
13-
- [Docker](https://docs.docker.com/get-docker/) v18.09+
14-
- [Kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl)
15-
- [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/)
16-
- [Helm](https://helm.sh/docs/intro/quickstart/#install-helm)
17-
- [git](https://git-scm.com/)
18-
- [GNU Make](https://www.gnu.org/software/software.html)
19-
- [yq](https://github.com/mikefarah/yq/#install)
20-
- [fieldalignment](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/fieldalignment):
21-
22-
```shell
23-
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
24-
```
25-
26-
- [pre-commit](https://pre-commit.com/#install):
2712

28-
```shell
29-
brew install pre-commit
30-
```
13+
- [Go](https://golang.org/doc/install) v1.21.0+
14+
- [Docker](https://docs.docker.com/get-docker/) v18.09+
15+
- [Kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl)
16+
- [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/)
17+
- [Helm](https://helm.sh/docs/intro/quickstart/#install-helm)
18+
- [git](https://git-scm.com/)
19+
- [GNU Make](https://www.gnu.org/software/software.html)
20+
- [yq](https://github.com/mikefarah/yq/#install)
21+
- [fieldalignment](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/fieldalignment):
3122

32-
and then run
23+
```shell
24+
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
25+
```
3326

34-
```shell
35-
pre-commit install
36-
```
27+
- [pre-commit](https://pre-commit.com/#install):
3728

38-
in the project root directory to install the git hooks.
29+
```shell
30+
brew install pre-commit
31+
```
32+
33+
and then run
34+
35+
```shell
36+
pre-commit install
37+
```
38+
39+
in the project root directory to install the git hooks.
3940

4041
2. [Fork the project repository](https://github.com/nginxinc/nginx-gateway-fabric/fork)
4142
3. Clone your repository, and install the project dependencies:
@@ -138,44 +139,44 @@ This will build the docker images `nginx-gateway-fabric:<your-user>` and `nginx-
138139

139140
- To install with Helm (where your release name is `my-release`):
140141

141-
```shell
142-
helm install my-release ./charts/nginx-gateway-fabric --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
143-
```
142+
```shell
143+
helm install my-release ./charts/nginx-gateway-fabric --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
144+
```
144145

145146
- To install NGINX Plus with Helm (where your release name is `my-release`):
146147

147-
```shell
148-
helm install my-release ./charts/nginx-gateway-fabric --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-plus --set nginx.image.tag=$(whoami) --set nginx.image.pullPolicy=Never --set nginx.plus=true -n nginx-gateway
149-
```
148+
```shell
149+
helm install my-release ./charts/nginx-gateway-fabric --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-plus --set nginx.image.tag=$(whoami) --set nginx.image.pullPolicy=Never --set nginx.plus=true -n nginx-gateway
150+
```
150151

151152
> For more information on Helm configuration options see the Helm [README](../../charts/nginx-gateway-fabric/README.md).
152153

153154
- To install with manifests:
154155

155-
```shell
156-
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"
157-
kubectl apply -f deploy/manifests/crds
158-
kubectl apply -f deploy/manifests/nginx-gateway.yaml
159-
kubectl apply -f deploy/manifests/service/nodeport.yaml
160-
```
156+
```shell
157+
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"
158+
kubectl apply -f deploy/crds.yaml
159+
kubectl apply -f deploy/manifests/nginx-gateway.yaml
160+
kubectl apply -f deploy/manifests/service/nodeport.yaml
161+
```
161162

162163
- To install NGINX Plus with manifests:
163164

164-
```shell
165-
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-plus --set nginx.image.tag=$(whoami) --set nginx.image.pullPolicy=Never --set nginx.plus=true"
166-
kubectl apply -f deploy/manifests/crds
167-
kubectl apply -f deploy/manifests/nginx-gateway.yaml
168-
kubectl apply -f deploy/manifests/service/nodeport.yaml
169-
```
165+
```shell
166+
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-plus --set nginx.image.tag=$(whoami) --set nginx.image.pullPolicy=Never --set nginx.plus=true"
167+
kubectl apply -f deploy/crds.yaml
168+
kubectl apply -f deploy/manifests/nginx-gateway.yaml
169+
kubectl apply -f deploy/manifests/service/nodeport.yaml
170+
```
170171

171172
- To install with experimental manifests:
172173

173-
```shell
174-
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"
175-
kubectl apply -f deploy/manifests/crds
176-
kubectl apply -f deploy/manifests/nginx-gateway-experimental.yaml
177-
kubectl apply -f deploy/manifests/service/nodeport.yaml
178-
```
174+
```shell
175+
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"
176+
kubectl apply -f deploy/crds.yaml
177+
kubectl apply -f deploy/manifests/nginx-gateway-experimental.yaml
178+
kubectl apply -f deploy/manifests/service/nodeport.yaml
179+
```
179180

180181
### Run Examples
181182

scripts/combine-crds.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)