Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit ba7ed75

Browse files
authored
Dependencies from kustomize resources (#200)
* Makefile: remove unused deploy-manifest target * dependencies from kustomize * kuadrant tunning * simple-rl-for-api-owners.md: small fix * fix issues from upgrading authorino to v0.10.0 * fix little issues * fix little issues * fix user guide rate limit syntax
1 parent ab67583 commit ba7ed75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+981
-18227
lines changed

Diff for: .github/workflows/building.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
uses: actions/checkout@v2
3131
- name: build
3232
run: |
33-
make manager
33+
make build
3434
3535
build-image:
3636
name: Build image

Diff for: .github/workflows/testing.yaml

+15-31
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414

1515
# This file is automagically synced here from github.com/knative-sandbox/.github
1616
# repo by knobots: https://github.com/knative-sandbox/knobots and will be overwritten.
17-
17+
---
1818
name: Testing
19-
20-
on: pull_request
21-
19+
on:
20+
push:
21+
branches: ['*']
22+
pull_request:
23+
branches: ['*']
2224
jobs:
2325
unittests:
2426
name: Run unit tests
@@ -34,7 +36,6 @@ jobs:
3436
- name: run tests
3537
run: |
3638
make test-unit
37-
3839
integrationtests:
3940
name: Run integration tests
4041
runs-on: ubuntu-latest
@@ -58,28 +59,12 @@ jobs:
5859
kubectl cluster-info dump
5960
- name: Deploy Kuadrant deps
6061
run: |
61-
make deploy-kuadrant-deps
62+
make local-env-setup
6263
- name: run tests
6364
run: |
6465
make test-integration
65-
66-
verify-istio-manifest:
67-
name: Verify istio manifests
68-
runs-on: ubuntu-latest
69-
steps:
70-
- name: Set up Go 1.17.x
71-
uses: actions/setup-go@v2
72-
with:
73-
go-version: 1.17.x
74-
id: go
75-
- name: Check out code
76-
uses: actions/checkout@v2
77-
- name: run tests
78-
run: |
79-
make istio-manifest-update-test
80-
81-
verify-gateway-api-manifest:
82-
name: Verify Gateway API manifests
66+
verify-manifests:
67+
name: Verify manifests
8368
runs-on: ubuntu-latest
8469
steps:
8570
- name: Set up Go 1.17.x
@@ -89,12 +74,11 @@ jobs:
8974
id: go
9075
- name: Check out code
9176
uses: actions/checkout@v2
92-
- name: run tests
77+
- name: Run make verify-manifests
9378
run: |
94-
make gwapi-manifests-update-test
95-
96-
verify-kuadrant-manifest:
97-
name: Verify kuadrant manifests
79+
make verify-manifests
80+
verify-fmt:
81+
name: Verify fmt
9882
runs-on: ubuntu-latest
9983
steps:
10084
- name: Set up Go 1.17.x
@@ -104,6 +88,6 @@ jobs:
10488
id: go
10589
- name: Check out code
10690
uses: actions/checkout@v2
107-
- name: run tests
91+
- name: Run make verify-fmt
10892
run: |
109-
make manifests-update-test
93+
make verify-fmt

Diff for: Makefile

+48-156
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ SHELL = /usr/bin/env bash -o pipefail
6060
KIND_CLUSTER_NAME = kuadrant-local
6161
GOLANGCI-LINT = $(PROJECT_PATH)/bin/golangci-lint
6262

63+
KUADRANT_NAMESPACE=kuadrant-system
64+
6365
all: build
6466

6567
##@ General
@@ -82,15 +84,6 @@ help: ## Display this help.
8284

8385
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
8486
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
85-
$(MAKE) deploy-manifest
86-
87-
.PHONY: deploy-manifest
88-
deploy-manifest: kustomize ## Generate deployment manifests.
89-
mkdir -p $(PROJECT_DIR)/config/deploy
90-
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
91-
$(KUSTOMIZE) build config/default > $(PROJECT_DIR)/config/deploy/manifests.yaml
92-
# clean up
93-
cd config/manager && $(KUSTOMIZE) edit set image controller=$(DEFAULT_IMG)
9487

9588
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
9689
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
@@ -113,73 +106,40 @@ clean-cov:
113106
rm -rf $(PROJECT_PATH)/cover.out
114107

115108
.PHONY: local-setup
116-
local-setup: local-cleanup local-setup-kind manifests kustomize generate ## Deploy locally kuadrant controller from the current code
117-
export PATH=$(PROJECT_PATH)/bin:$$PATH; ./utils/local-deployment/local-setup.sh
109+
local-setup: export IMG := $(IMAGE_TAG_BASE):dev
110+
local-setup: ## Deploy locally kuadrant controller from the current code
111+
$(MAKE) local-env-setup
112+
$(MAKE) docker-build
113+
$(KIND) load docker-image $(IMG) --name $(KIND_CLUSTER_NAME)
114+
$(MAKE) deploy
115+
kubectl -n kuadrant-system wait --timeout=300s --for=condition=Available deployments --all
116+
@echo
117+
@echo "Now you can export the kuadrant gateway by doing:"
118+
@echo "kubectl port-forward --namespace ${KUADRANT_NAMESPACE} deployment/kuadrant-gateway 8080:8080 8443:8443"
119+
@echo "after that, you can curl -H \"Host: myhost.com\" localhost:8080"
120+
@echo "-- Linux only -- Ingress gateway is exported using nodePort service in port 9080"
121+
@echo "curl -H \"Host: myhost.com\" localhost:9080"
122+
@echo
118123

124+
.PHONY: local-cleanup
125+
local-cleanup: ## Delete local cluster
126+
$(MAKE) kind-delete-cluster
119127

120128
# kuadrant is not deployed
121129
.PHONY: local-env-setup
122-
local-env-setup: local-cleanup local-setup-kind deploy-kuadrant-deps generate install ## Deploys all services and manifests required by kuadrant to run. Used to run kuadrant with "make run"
123-
124-
.PHONY: deploy-kuadrant-deps
125-
deploy-kuadrant-deps:
126-
./utils/local-deployment/deploy-kuadrant-deps.sh
127-
128-
.PHONY: local-setup-kind
129-
local-setup-kind: kind
130-
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config utils/local-deployment/kind-cluster.yaml
131-
132-
.PHONY: local-cleanup
133-
local-cleanup: kind
134-
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
130+
local-env-setup: ## Deploys all services and manifests required by kuadrant to run. Used to run kuadrant with "make run"
131+
$(MAKE) kind-delete-cluster
132+
$(MAKE) kind-create-cluster
133+
$(MAKE) gateway-api-install
134+
$(MAKE) istio-install
135+
$(MAKE) deploy-gateway
136+
$(MAKE) deploy-dependencies
137+
$(MAKE) install
135138

136139
.PHONY: run-lint
137140
run-lint: $(GOLANGCI-LINT) ## Run lint tests
138141
$(GOLANGCI-LINT) run
139142

140-
ISTIO_MANIFEST_PATH = $(PROJECT_DIR)/utils/local-deployment/istio-manifests/autogenerated
141-
.PHONY: generate-istio-manifests
142-
generate-istio-manifests: istioctl ## Generates istio manifests with patches.
143-
-rm -rf $(ISTIO_MANIFEST_PATH)
144-
mkdir -p $(ISTIO_MANIFEST_PATH)
145-
$(ISTIOCTL) manifest generate --set profile=minimal --set values.gateways.istio-ingressgateway.autoscaleEnabled=false --set values.pilot.autoscaleEnabled=false --set values.global.istioNamespace=$(KUADRANT_NAMESPACE) -f utils/local-deployment/patches/istio-externalProvider.yaml -o $(ISTIO_MANIFEST_PATH)
146-
147-
.PHONY: istio-manifest-update-test
148-
istio-manifest-update-test: generate-istio-manifests ## Test istio manifest
149-
git diff --exit-code $(ISTIO_MANIFEST_PATH)
150-
[ -z "$$(git ls-files --other --exclude-standard --directory --no-empty-directory $(ISTIO_MANIFEST_PATH))" ]
151-
152-
GATEWAYAPI_MANIFEST_PATH = $(PROJECT_DIR)/utils/local-deployment/gatewayapi-manifests/autogenerated
153-
.PHONY: generate-gwapi-manifests
154-
generate-gwapi-manifests: ## Generates Gateway API manifests
155-
-rm -rf $(GATEWAYAPI_MANIFEST_PATH)
156-
mkdir -p $(GATEWAYAPI_MANIFEST_PATH)
157-
kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd?ref=v0.4.0" > $(GATEWAYAPI_MANIFEST_PATH)/Base.yaml
158-
159-
.PHONY: gwapi-manifests-update-test
160-
gwapi-manifests-update-test: generate-gwapi-manifests ## Test Gateway API manifests
161-
git diff --exit-code $(GATEWAYAPI_MANIFEST_PATH)
162-
[ -z "$$(git ls-files --other --exclude-standard --directory --no-empty-directory $(GATEWAYAPI_MANIFEST_PATH))" ]
163-
164-
165-
.PHONY: manifests-update-test
166-
manifests-update-test: manifests ## Test autogenerated controller manifests
167-
git diff --exit-code ./config
168-
[ -z "$$(git ls-files --other --exclude-standard --directory --no-empty-directory ./config)" ]
169-
170-
LIMITADOR_OPERATOR_SCM_VERSION=main
171-
LIMITADOR_OPERATOR_IMAGE_TAG=latest
172-
LIMITADOR_OPERATOR_IMAGE=quay.io/kuadrant/limitador-operator:$(LIMITADOR_OPERATOR_IMAGE_TAG)
173-
.PHONY: generate-limitador-manifests
174-
generate-limitador-manifests: ## Generates limitador manifests.
175-
$(eval TMP := $(shell mktemp -d))
176-
cd $(TMP); git clone --depth 1 --branch $(LIMITADOR_OPERATOR_SCM_VERSION) https://github.com/kuadrant/limitador-operator.git
177-
cd $(TMP)/limitador-operator; make kustomize
178-
cd $(TMP)/limitador-operator/config/manager; $(TMP)/limitador-operator/bin/kustomize edit set image controller=$(LIMITADOR_OPERATOR_IMAGE)
179-
cd $(TMP)/limitador-operator/config/default; $(TMP)/limitador-operator/bin/kustomize edit set namespace $(KUADRANT_NAMESPACE)
180-
cd $(TMP)/limitador-operator; bin/kustomize build config/default -o $(PROJECT_PATH)/utils/local-deployment/limitador-operator.yaml
181-
-rm -rf $(TMP)
182-
183143
##@ Build
184144

185145
build: generate fmt vet ## Build manager binary.
@@ -196,9 +156,6 @@ docker-build: ## Build docker image with the manager.
196156
docker-push: ## Push docker image with the manager.
197157
docker push ${IMG}
198158

199-
# old
200-
manager: build
201-
202159
##@ Deployment
203160

204161
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
@@ -209,10 +166,21 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
209166

210167
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
211168
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
212-
$(KUSTOMIZE) build config/default | kubectl apply -f -
169+
$(KUSTOMIZE) build config/deploy | kubectl apply -f -
170+
cd config/manager && $(KUSTOMIZE) edit set image controller=${DEFAULT_IMG}
213171

214172
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
215-
$(KUSTOMIZE) build config/default | kubectl delete -f -
173+
$(KUSTOMIZE) build config/deploy | kubectl delete -f -
174+
175+
deploy-dependencies: kustomize ## Deploy dependencies to the K8s cluster specified in ~/.kube/config.
176+
$(KUSTOMIZE) build config/dependencies | kubectl apply -f -
177+
kubectl -n "$(KUADRANT_NAMESPACE)" wait --timeout=300s --for=condition=Available deployments --all
178+
kubectl apply -n "$(KUADRANT_NAMESPACE)" -f utils/local-deployment/authorino.yaml
179+
kubectl apply -n "$(KUADRANT_NAMESPACE)" -f utils/local-deployment/limitador.yaml
180+
181+
##@ Misc
182+
183+
## Miscellaneous Custom targets
216184

217185
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
218186
controller-gen: ## Download controller-gen locally if necessary.
@@ -226,6 +194,12 @@ ENVTEST = $(shell pwd)/bin/setup-envtest
226194
envtest: ## Download envtest-setup locally if necessary.
227195
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)
228196

197+
$(GOLANGCI-LINT):
198+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_PATH)/bin v1.46.1
199+
200+
.PHONY: golangci-lint
201+
golangci-lint: $(GOLANGCI-LINT) ## Download golangci-lint locally if necessary.
202+
229203
OPERATOR_SDK = $(shell pwd)/bin/operator-sdk
230204
OPERATOR_SDK_VERSION = v1.22.0
231205
operator-sdk: ## Download operator-sdk locally if necessary.
@@ -245,87 +219,5 @@ rm -rf $$TMP_DIR ;\
245219
}
246220
endef
247221

248-
.PHONY: bundle
249-
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
250-
operator-sdk generate kustomize manifests -q
251-
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
252-
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
253-
operator-sdk bundle validate ./bundle
254-
255-
.PHONY: bundle-build
256-
bundle-build: ## Build the bundle image.
257-
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
258-
259-
.PHONY: bundle-push
260-
bundle-push: ## Push the bundle image.
261-
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
262-
263-
.PHONY: opm
264-
OPM = ./bin/opm
265-
opm: ## Download opm locally if necessary.
266-
ifeq (,$(wildcard $(OPM)))
267-
ifeq (,$(shell which opm 2>/dev/null))
268-
@{ \
269-
set -e ;\
270-
mkdir -p $(dir $(OPM)) ;\
271-
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
272-
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\
273-
chmod +x $(OPM) ;\
274-
}
275-
else
276-
OPM = $(shell which opm)
277-
endif
278-
endif
279-
280-
# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
281-
# These images MUST exist in a registry and be pull-able.
282-
BUNDLE_IMGS ?= $(BUNDLE_IMG)
283-
284-
# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
285-
CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION)
286-
287-
# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
288-
ifneq ($(origin CATALOG_BASE_IMG), undefined)
289-
FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG)
290-
endif
291-
292-
# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
293-
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
294-
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
295-
.PHONY: catalog-build
296-
catalog-build: opm ## Build a catalog image.
297-
$(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
298-
299-
# Push the catalog image.
300-
.PHONY: catalog-push
301-
catalog-push: ## Push a catalog image.
302-
$(MAKE) docker-push IMG=$(CATALOG_IMG)
303-
304-
##@ Misc
305-
306-
## Miscellaneous Custom targets
307-
308-
KUADRANT_NAMESPACE=kuadrant-system
309-
310-
KIND = $(shell pwd)/bin/kind
311-
kind: ## Download kind locally if necessary.
312-
$(call go-get-tool,$(KIND),sigs.k8s.io/[email protected])
313-
314-
$(GOLANGCI-LINT):
315-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_PATH)/bin v1.46.1
316-
317-
.PHONY: golangci-lint
318-
golangci-lint: $(GOLANGCI-LINT) ## Download golangci-lint locally if necessary.
319-
320-
# istioctl tool
321-
ISTIOCTL=$(PROJECT_PATH)/bin/istioctl
322-
ISTIOVERSION = 1.12.1
323-
$(ISTIOCTL):
324-
mkdir -p $(PROJECT_PATH)/bin
325-
$(eval TMP := $(shell mktemp -d))
326-
cd $(TMP); curl -sSL https://istio.io/downloadIstio | ISTIO_VERSION=$(ISTIOVERSION) sh -
327-
cp $(TMP)/istio-$(ISTIOVERSION)/bin/istioctl ${ISTIOCTL}
328-
-rm -rf $(TMP)
329-
330-
.PHONY: istioctl
331-
istioctl: $(ISTIOCTL) ## Download istioctl locally if necessary.
222+
# Include last to avoid changing MAKEFILE_LIST used above
223+
include ./make/*.mk

0 commit comments

Comments
 (0)