Skip to content

Commit

Permalink
Use kustomize to generate a single CRDs file (nginxinc#1886)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lucacome authored May 1, 2024
1 parent d3a4846 commit 0b0f711
Show file tree
Hide file tree
Showing 12 changed files with 1,569 additions and 289 deletions.
5 changes: 0 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,8 @@ 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
- glob: ./deploy/manifests/nginx-plus-gateway.yaml
- glob: ./deploy/manifests/nginx-gateway-experimental.yaml
Expand Down
1 change: 1 addition & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ yaml-files:
ignore:
- charts/nginx-gateway-fabric
- config/crd/bases/
- deploy/crds.yaml
- .github/workflows/

rules:
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ generate: ## Run go generate
.PHONY: generate-crds
generate-crds: ## Generate CRDs and Go types using kubebuilder
go run sigs.k8s.io/controller-tools/cmd/controller-gen crd object paths=./apis/... output:crd:artifacts:config=config/crd/bases
kubectl kustomize config/crd >deploy/crds.yaml

.PHONY: generate-manifests
generate-manifests: ## Generate manifests using Helm.
Expand All @@ -113,10 +114,6 @@ generate-manifests: ## Generate manifests using Helm.
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)
Expand Down
104 changes: 52 additions & 52 deletions charts/nginx-gateway-fabric/README.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
- bases/gateway.nginx.org_clientsettingspolicies.yaml
- bases/gateway.nginx.org_nginxgateways.yaml
- bases/gateway.nginx.org_nginxproxies.yaml
- bases/gateway.nginx.org_observabilitypolicies.yaml
5 changes: 2 additions & 3 deletions conformance/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ KIND_KUBE_CONFIG=$${HOME}/.kube/kind/config
CONFORMANCE_TAG = latest
CONFORMANCE_PREFIX = conformance-test-runner
NGF_MANIFEST=../deploy/manifests/nginx-gateway.yaml
CRDS=../deploy/manifests/crds/
STATIC_MANIFEST=provisioner/static-deployment.yaml
PROVISIONER_MANIFEST=provisioner/provisioner.yaml
ENABLE_EXPERIMENTAL ?= false
Expand Down Expand Up @@ -66,13 +65,13 @@ load-images-with-plus: ## Load NGF and NGINX Plus images on configured kind clus
.PHONY: prepare-ngf-dependencies
prepare-ngf-dependencies: update-ngf-manifest ## Install NGF dependencies on configured kind cluster
./scripts/install-gateway.sh $(GW_API_VERSION) $(ENABLE_EXPERIMENTAL)
kubectl apply -f $(CRDS)
kubectl kustomize ../config/crd | kubectl apply -f -
kubectl apply -f $(NGF_MANIFEST)

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

.PHONY: deploy-updated-provisioner
Expand Down
1,309 changes: 1,309 additions & 0 deletions deploy/crds.yaml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion deploy/manifests/crds

This file was deleted.

95 changes: 48 additions & 47 deletions docs/developer/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,34 @@ fully prepared development environment that allows you to contribute to the proj
Follow these steps to set up your development environment.

1. Install:
- [Go](https://golang.org/doc/install) v1.21.0+
- [Docker](https://docs.docker.com/get-docker/) v18.09+
- [Kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl)
- [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/)
- [Helm](https://helm.sh/docs/intro/quickstart/#install-helm)
- [git](https://git-scm.com/)
- [GNU Make](https://www.gnu.org/software/software.html)
- [yq](https://github.com/mikefarah/yq/#install)
- [fieldalignment](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/fieldalignment):

```shell
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
```

- [pre-commit](https://pre-commit.com/#install):

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

and then run
```shell
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
```

```shell
pre-commit install
```
- [pre-commit](https://pre-commit.com/#install):

in the project root directory to install the git hooks.
```shell
brew install pre-commit
```

and then run

```shell
pre-commit install
```

in the project root directory to install the git hooks.

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

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

```shell
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
```
```shell
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
```

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

```shell
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
```
```shell
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
```

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

- To install with manifests:

```shell
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
```
```shell
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/crds.yaml
kubectl apply -f deploy/manifests/nginx-gateway.yaml
kubectl apply -f deploy/manifests/service/nodeport.yaml
```

- To install NGINX Plus with manifests:

```shell
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"
kubectl apply -f deploy/manifests/crds
kubectl apply -f deploy/manifests/nginx-gateway.yaml
kubectl apply -f deploy/manifests/service/nodeport.yaml
```
```shell
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"
kubectl apply -f deploy/crds.yaml
kubectl apply -f deploy/manifests/nginx-gateway.yaml
kubectl apply -f deploy/manifests/service/nodeport.yaml
```

- To install with experimental manifests:

```shell
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-experimental.yaml
kubectl apply -f deploy/manifests/service/nodeport.yaml
```
```shell
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/crds.yaml
kubectl apply -f deploy/manifests/nginx-gateway-experimental.yaml
kubectl apply -f deploy/manifests/service/nodeport.yaml
```

### Run Examples

Expand Down
13 changes: 0 additions & 13 deletions scripts/combine-crds.sh

This file was deleted.

Loading

0 comments on commit 0b0f711

Please sign in to comment.