-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Namespace support. #134
Namespace support. #134
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -104,6 +104,10 @@ KUSTOMIZE = $(shell pwd)/bin/kustomize | |||||
kustomize: ## Download kustomize locally if necessary. | ||||||
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected]) | ||||||
|
||||||
KIND = $(shell pwd)/bin/kind | ||||||
kind: | ||||||
$(call go-get-tool,$(KIND),sigs.k8s.io/[email protected]) | ||||||
|
||||||
YQ = $(shell pwd)/bin/yq | ||||||
YQ_VERSION := v4.34.2 | ||||||
$(YQ): | ||||||
|
@@ -182,16 +186,40 @@ docker-push: ## Push docker image with the manager. | |||||
##@ Deployment | ||||||
|
||||||
install: manifests kustomize install-authorino ## Install CRDs into the K8s cluster specified in ~/.kube/config. | ||||||
@if [ $(NAMESPACE) != '' ];then \ | ||||||
echo "Setting Custom Namespace: $(NAMESPACE)"; \ | ||||||
cd $(PROJECT_DIR)/config/install && $(KUSTOMIZE) edit set namespace $(NAMESPACE); \ | ||||||
kubectl create namespace $(NAMESPACE); \ | ||||||
else \ | ||||||
kubectl create namespace $(DEFAULT_REPO); \ | ||||||
fi | ||||||
cd $(PROJECT_DIR) && $(KUSTOMIZE) build config/install > $(OPERATOR_MANIFESTS) | ||||||
kubectl apply -f $(OPERATOR_MANIFESTS) | ||||||
|
||||||
# clean up | ||||||
@if [ $(NAMESPACE) != '' ];then \ | ||||||
echo "Removing Custom Namespace: $(NAMESPACE)"; \ | ||||||
cd $(PROJECT_DIR)/config/install && $(KUSTOMIZE) edit set namespace $(DEFAULT_REPO); \ | ||||||
fi | ||||||
|
||||||
|
||||||
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. | ||||||
kubectl delete -f $(OPERATOR_MANIFESTS) | ||||||
|
||||||
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. | ||||||
cd config/manager && $(KUSTOMIZE) edit set image controller=${OPERATOR_IMAGE} | ||||||
@if [ $(NAMESPACE) != '' ];then \ | ||||||
echo "Setting Custom Namespace: $(NAMESPACE)"; \ | ||||||
cd $(PROJECT_DIR)/config/default && $(KUSTOMIZE) edit set namespace $(NAMESPACE); \ | ||||||
fi | ||||||
|
||||||
$(KUSTOMIZE) build config/default | kubectl apply -f - | ||||||
# rollback kustomize edit | ||||||
cd config/manager && $(KUSTOMIZE) edit set image controller=${DEFAULT_OPERATOR_IMAGE} | ||||||
@if [ $(NAMESPACE) != '' ];then \ | ||||||
echo "Removing Custom Namespace: $(NAMESPACE)"; \ | ||||||
cd $(PROJECT_DIR)/config/default && $(KUSTOMIZE) edit set namespace $(DEFAULT_REPO); \ | ||||||
fi | ||||||
|
||||||
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. | ||||||
$(KUSTOMIZE) build config/default | kubectl delete -f - | ||||||
|
@@ -216,12 +244,22 @@ endef | |||||
DEPLOYMENT_DIR = $(PROJECT_DIR)/config/deploy | ||||||
DEPLOYMENT_FILE = $(DEPLOYMENT_DIR)/manifests.yaml | ||||||
.PHONY: deploy-manifest | ||||||
deploy-manifest: | ||||||
deploy-manifest: kustomize | ||||||
mkdir -p $(DEPLOYMENT_DIR) | ||||||
cd $(PROJECT_DIR)/config/manager && $(KUSTOMIZE) edit set image controller=$(OPERATOR_IMAGE) ;\ | ||||||
cd $(PROJECT_DIR)/config/manager && $(KUSTOMIZE) edit set image controller=$(OPERATOR_IMAGE) | ||||||
|
||||||
@if [ $(NAMESPACE) != '' ];then \ | ||||||
echo "Setting Custom Namespace: $(NAMESPACE)"; \ | ||||||
cd $(PROJECT_DIR)/config/deploy && $(KUSTOMIZE) edit set namespace $(NAMESPACE); \ | ||||||
fi | ||||||
|
||||||
cd $(PROJECT_DIR) && $(KUSTOMIZE) build config/deploy > $(DEPLOYMENT_FILE) | ||||||
# clean up | ||||||
cd $(PROJECT_DIR)/config/manager && $(KUSTOMIZE) edit set image controller=${DEFAULT_OPERATOR_IMAGE} | ||||||
@if [ $(NAMESPACE) != '' ];then \ | ||||||
echo "Removing Custom Namespace: $(NAMESPACE)"; \ | ||||||
cd $(PROJECT_DIR)/config/deploy && $(KUSTOMIZE) edit set namespace $(DEFAULT_REPO); \ | ||||||
fi | ||||||
|
||||||
.PHONY: bundle | ||||||
bundle: export IMAGE_TAG := $(IMAGE_TAG) | ||||||
|
@@ -307,3 +345,72 @@ verify-bundle: bundle ## Verify bundle update. | |||||
.PHONY: verify-fmt | ||||||
verify-fmt: fmt ## Verify fmt update. | ||||||
git diff --exit-code ./api ./controllers | ||||||
|
||||||
## local configurations | ||||||
|
||||||
deploy-develmode: manifests kustomize ## Deploy controller in debug mode to the K8s cluster specified in ~/.kube/config. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The target name says "devel" mode while the descriptions says "debug". But, most importantly:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the I am going to say I had a valid reason for doing it but I can not find it now. I will remove and use the |
||||||
cd config/manager && $(KUSTOMIZE) edit set image controller=${OPERATOR_IMAGE} | ||||||
@if [ $(NAMESPACE) != '' ];then \ | ||||||
echo "Setting Custom Namespace: $(NAMESPACE)"; \ | ||||||
cd $(PROJECT_DIR)/config/default && $(KUSTOMIZE) edit set namespace $(NAMESPACE); \ | ||||||
fi | ||||||
|
||||||
cd $(PROJECT_DIR) && $(KUSTOMIZE) build config/deploy > $(DEPLOYMENT_FILE) | ||||||
|
||||||
$(KUSTOMIZE) build config/default | kubectl apply -f - | ||||||
|
||||||
# clean up | ||||||
cd config/manager && $(KUSTOMIZE) edit set image controller=${DEFAULT_OPERATOR_IMAGE} | ||||||
@if [ $(NAMESPACE) != '' ];then \ | ||||||
echo "Removing Custom Namespace: $(NAMESPACE)"; \ | ||||||
cd $(PROJECT_DIR)/config/default && $(KUSTOMIZE) edit set namespace $(DEFAULT_REPO); \ | ||||||
fi | ||||||
|
||||||
.PHONY: local-cleanup | ||||||
local-cleanup: | ||||||
$(MAKE) kind-delete-cluster | ||||||
|
||||||
.PHONY: local-env-setup | ||||||
local-env-setup: | ||||||
$(MAKE) kind-delete-cluster | ||||||
$(MAKE) kind-create-cluster | ||||||
$(KUSTOMIZE) build config/crd | kubectl apply -f - | ||||||
|
||||||
.PHONY: local-setup | ||||||
local-setup: export OPERATOR_IMAGE := authorino-operator:dev | ||||||
local-setup: | ||||||
$(MAKE) local-env-setup | ||||||
$(MAKE) docker-build | ||||||
echo "Deploying Authorino control plane" | ||||||
$(KIND) load docker-image ${OPERATOR_IMAGE} --name ${KIND_CLUSTER_NAME} | ||||||
$(MAKE) install | ||||||
$(MAKE) deploy | ||||||
|
||||||
.PHONY: local-redeploy | ||||||
local-redeploy: export OPERATOR_IMAGE := authorino-operator:dev | ||||||
local-redeploy: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency with how Authorino calls it:
Suggested change
|
||||||
$(MAKE) docker-build | ||||||
echo "Deploying Authorino control plane" | ||||||
$(KIND) load docker-image ${OPERATOR_IMAGE} --name ${KIND_CLUSTER_NAME} | ||||||
|
||||||
@if [ $(NAMESPACE) != '' ];then \ | ||||||
kubectl rollout restart deployment -n $(NAMESPACE) authorino-operator; \ | ||||||
echo "Wait for all deployments to be up"; \ | ||||||
kubectl -n $(NAMESPACE) wait --timeout=300s --for=condition=Available deployments --all; \ | ||||||
else \ | ||||||
kubectl rollout restart deployment -n $(DEFAULT_REPO) authorino-operator; \ | ||||||
echo "Wait for all deployments to be up"; \ | ||||||
kubectl -n $(DEFAULT_REPO) wait --timeout=300s --for=condition=Available deployments --all; \ | ||||||
fi | ||||||
|
||||||
## kind configuration | ||||||
|
||||||
KIND_CLUSTER_NAME ?= authorino-local | ||||||
|
||||||
.PHONY: kind-create-cluster | ||||||
kind-create-cluster: kind ## Create the "authorino-local" kind cluster. | ||||||
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config utils/kind-cluster.yaml | ||||||
|
||||||
.PHONY: kind-delete-cluster | ||||||
kind-delete-cluster: kind ## Delete the "authorino-local" kind cluster. | ||||||
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing these local cluster-related targets are all to support testing the operator deployed to a custom namespace. Was that the initial motivation? To test local changes in the operator, I often find myself running the following: kind create cluster
make docker-build OPERATOR_IMAGE=authorino-operator:local
kind load docker-image authorino-operator:local
make manifests && sed -e 's/quay.io\/kuadrant\/authorino-operator:latest/authorino-operator:local/' config/deploy/manifests.yaml | kubectl apply -f - Some other times: kind create cluster
kubectl create namespace authorino-operator
make manifests install run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My initial reason for adding the local cluster related targets was for similarity in the dev process. Both authorino and kuadrant-operator uses the same naming. The steps you stated are fine but they are not documented so when starting in the project it is unclear how to start with a dev cluster. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- ../authorino | ||
- ../default | ||
- ../authorino | ||
- ../default | ||
|
||
namespace: authorino-operator |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
# Adds namespace to all resources. | ||
namespace: authorino-operator | ||
|
||
# Value of this field is prepended to the | ||
# names of all resources, e.g. a deployment named | ||
# namePrefix: authorino-operator- | ||
|
||
bases: | ||
resources: | ||
- ../crd | ||
- ../rbac |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
image: kindest/node:v1.27.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have the diff of what this target yields with a custom namespace vs the default one? Likely, this is only because of the role bindings created for the operator, so it sets the right ServiceAccount, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll create a diff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff is in the gist. I comment out then clean up code when creating the diff.
https://gist.github.com/Boomatang/becfda6a1659f7e864ac039a439889bd