-
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
Closed
Closed
Namespace support. #134
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,53 @@ verify-bundle: bundle ## Verify bundle update. | |
.PHONY: verify-fmt | ||
verify-fmt: fmt ## Verify fmt update. | ||
git diff --exit-code ./api ./controllers | ||
|
||
## local configurations | ||
.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-rollout | ||
local-rollout: export OPERATOR_IMAGE := authorino-operator:dev | ||
local-rollout: | ||
$(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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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