diff --git a/Makefile b/Makefile index 7046e4ce..4cbbd718 100644 --- a/Makefile +++ b/Makefile @@ -21,14 +21,13 @@ GOOS = $(shell go env GOOS) TESTARGS_DEFAULT := -v TESTARGS ?= $(TESTARGS_DEFAULT) CONTROLLER_NAME = $(shell cat COMPONENT_NAME 2> /dev/null) -CONTROLLER_NAMESPACE ?= open-cluster-management-agent-addon # Handle KinD configuration MANAGED_CLUSTER_SUFFIX ?= MANAGED_CLUSTER_NAME ?= managed$(MANAGED_CLUSTER_SUFFIX) WATCH_NAMESPACE ?= $(MANAGED_CLUSTER_NAME) KIND_NAME ?= test-$(MANAGED_CLUSTER_NAME) KIND_CLUSTER_NAME ?= kind-$(KIND_NAME) -KIND_NAMESPACE ?= $(CONTROLLER_NAMESPACE) +KIND_NAMESPACE ?= open-cluster-management-agent-addon # Test coverage threshold export COVERAGE_MIN ?= 75 COVERAGE_E2E_OUT ?= coverage_e2e.out @@ -101,7 +100,7 @@ deploy: generate-operator-yaml create-ns .PHONY: create-ns create-ns: - -@kubectl create namespace $(CONTROLLER_NAMESPACE) + -@kubectl create namespace $(KIND_NAMESPACE) -@kubectl create namespace $(WATCH_NAMESPACE) # Run against the current locally configured Kubernetes cluster @@ -162,8 +161,18 @@ kind-deploy-controller: generate-operator-yaml install-resources deploy .PHONY: deploy-controller deploy-controller: kind-deploy-controller +HOSTED ?= none + .PHONY: kind-deploy-controller-dev -kind-deploy-controller-dev: kind-deploy-controller build-images +kind-deploy-controller-dev: + if [ "$(HOSTED)" = "hosted" ]; then\ + $(MAKE) kind-deploy-controller-dev-addon ;\ + else\ + $(MAKE) kind-deploy-controller-dev-normal ;\ + fi + +.PHONY: kind-deploy-controller-dev-normal +kind-deploy-controller-dev-normal: kind-deploy-controller @echo Pushing image to KinD cluster kind load docker-image $(REGISTRY)/$(IMG):$(TAG) --name $(KIND_NAME) @echo "Patch deployment image" @@ -171,6 +180,12 @@ kind-deploy-controller-dev: kind-deploy-controller build-images kubectl patch deployment $(IMG) -n $(KIND_NAMESPACE) -p "{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"$(IMG)\",\"image\":\"$(REGISTRY)/$(IMG):$(TAG)\"}]}}}}" kubectl rollout status -n $(KIND_NAMESPACE) deployment $(IMG) --timeout=180s +.PHONY: kind-deploy-controller-dev-addon +kind-deploy-controller-dev-addon: + kind load docker-image $(REGISTRY)/$(IMG):$(TAG) --name $(KIND_NAME) + kubectl annotate -n $(subst -hosted,,$(KIND_NAMESPACE)) --overwrite managedclusteraddon config-policy-controller\ + addon.open-cluster-management.io/values='{"global":{"imagePullPolicy": "Never", "imageOverrides":{"config_policy_controller": "$(REGISTRY)/$(IMG):$(TAG)"}}}' + # Specify KIND_VERSION to indicate the version tag of the KinD image .PHONY: kind-create-cluster kind-create-cluster: diff --git a/README.md b/README.md index 4c72fd51..3c4f042d 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ to learn how to get involved. ``` - Deploy controller to a cluster - The controller is deployed to a namespace defined in `CONTROLLER_NAMESPACE` and monitors the namepace defined in `WATCH_NAMESPACE` for `ConfigurationPolicy` resources. + The controller is deployed to a namespace defined in `KIND_NAMESPACE` and monitors the namepace defined in `WATCH_NAMESPACE` for `ConfigurationPolicy` resources. 1. Deploy the controller and related resources ```bash @@ -143,7 +143,7 @@ to learn how to get involved. The deployment namespaces are configurable with: ```bash - export CONTROLLER_NAMESPACE='' # (defaults to 'open-cluster-management-agent-addon') + export KIND_NAMESPACE='' # (defaults to 'open-cluster-management-agent-addon') export WATCH_NAMESPACE='' # (defaults to 'managed') ``` **NOTE:** Please be aware of the community's [deployment images](https://github.com/open-cluster-management-io/community#deployment-images) special note.