From ae479bdead983f5e0338cb09a4a98825508cb544 Mon Sep 17 00:00:00 2001 From: Mike Ng Date: Fri, 30 Oct 2020 11:32:35 -0400 Subject: [PATCH 1/2] create a new Makefile target for spoke deploy on kind Signed-off-by: Mike Ng --- Makefile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Makefile b/Makefile index f120ad85f..0751d73ab 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,8 @@ OLM_VERSION?=0.16.1 KUBECTL?=kubectl KUBECONFIG?=./.kubeconfig KLUSTERLET_KUBECONFIG_CONTEXT?=$(shell $(KUBECTL) config current-context) +KLUSTERLET_KIND_KUBECONFIG?=$(HOME)/cluster1-kubeconfig +HUB_KIND_KUBECONFIG?=$(HOME)/hub-kubeconfig KIND_CLUSTER?=kind OPERATOR_SDK_ARCHOS:=x86_64-linux-gnu @@ -101,6 +103,10 @@ install-olm: ensure-operator-sdk $(KUBECTL) get crds | grep clusterserviceversion ; if [ $$? -ne 0 ] ; then $(OPERATOR_SDK) olm install --version $(OLM_VERSION); fi $(KUBECTL) get ns open-cluster-management ; if [ $$? -ne 0 ] ; then $(KUBECTL) create ns open-cluster-management ; fi +install-olm-kind: ensure-operator-sdk + $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) get crds | grep clusterserviceversion ; if [ $$? -ne 0 ] ; then $(OPERATOR_SDK) olm install --version $(OLM_VERSION); fi + $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) get ns open-cluster-management ; if [ $$? -ne 0 ] ; then $(KUBECTL) create ns open-cluster-management ; fi + deploy-hub: deploy-hub-operator apply-hub-cr deploy-hub-operator: install-olm munge-hub-csv @@ -116,6 +122,9 @@ clean-hub: ensure-operator-sdk cluster-ip: CLUSTER_IP?=$(shell $(KUBECTL) get svc kubernetes -n default -o jsonpath="{.spec.clusterIP}") +cluster-ip-kind: + CLUSTER_IP_KIND?=$(shell $(KUBECTL) --kubeconfig=$(HUB_KIND_KUBECONFIG) config view | grep server | awk '{ print $2 }' | cut -f3 -d/ | cut -f1 -d:) + bootstrap-secret: cluster-ip cp $(KUBECONFIG) dev-kubeconfig $(KUBECTL) config use-context $(KLUSTERLET_KUBECONFIG_CONTEXT) @@ -124,6 +133,13 @@ bootstrap-secret: cluster-ip $(KUBECTL) delete secret bootstrap-hub-kubeconfig -n open-cluster-management-agent --ignore-not-found $(KUBECTL) create secret generic bootstrap-hub-kubeconfig --from-file=kubeconfig=dev-kubeconfig -n open-cluster-management-agent +bootstrap-secret-kind: cluster-ip-kind + cp $(HUB_KIND_KUBECONFIG) dev-kubeconfig + $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) get ns open-cluster-management-agent; if [ $$? -ne 0 ] ; then $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) create ns open-cluster-management-agent; fi + $(KUBECTL) --kubeconfig dev-kubeconfig config set clusters.kind-$(KIND_CLUSTER).server https://$(CLUSTER_IP_KIND) + $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) delete secret bootstrap-hub-kubeconfig -n open-cluster-management-agent --ignore-not-found + $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) create secret generic bootstrap-hub-kubeconfig --from-file=kubeconfig=dev-kubeconfig -n open-cluster-management-agent + # Registration e2e expects to read bootstrap secret from open-cluster-management/e2e-bootstrap-secret # TODO: think about how to factor this e2e-bootstrap-secret: cluster-ip @@ -137,9 +153,17 @@ deploy-spoke: deploy-spoke-operator apply-spoke-cr deploy-spoke-operator: install-olm munge-spoke-csv bootstrap-secret $(OPERATOR_SDK) run packagemanifests deploy/klusterlet/olm-catalog/klusterlet/ --namespace open-cluster-management --version $(CSV_VERSION) --install-mode SingleNamespace=open-cluster-management --timeout=10m +deploy-spoke-kind: deploy-spoke-operator-kind apply-spoke-cr-kind + +deploy-spoke-operator-kind: install-olm-kind munge-spoke-csv bootstrap-secret-kind + $(OPERATOR_SDK) run packagemanifests deploy/klusterlet/olm-catalog/klusterlet/ --namespace open-cluster-management --version $(CSV_VERSION) --install-mode SingleNamespace=open-cluster-management --timeout=10m + apply-spoke-cr: $(SED_CMD) -e "s,quay.io/open-cluster-management/registration,$(REGISTRATION_IMAGE)," -e "s,quay.io/open-cluster-management/work,$(WORK_IMAGE)," deploy/klusterlet/config/samples/operator_open-cluster-management_klusterlets.cr.yaml | $(KUBECTL) apply -f - +apply-spoke-cr-kind: + $(SED_CMD) -e "s,quay.io/open-cluster-management/registration,$(REGISTRATION_IMAGE)," -e "s,quay.io/open-cluster-management/work,$(WORK_IMAGE)," deploy/klusterlet/config/samples/operator_open-cluster-management_klusterlets.cr.yaml | $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) apply -f - + clean-spoke: ensure-operator-sdk $(KUBECTL) delete -f deploy/klusterlet/config/samples/operator_open-cluster-management_klusterlets.cr.yaml --ignore-not-found $(OPERATOR_SDK) cleanup klusterlet --namespace open-cluster-management --timeout 10m From 2324c6cd47391b1c893bfeb368eb19b8088fe432 Mon Sep 17 00:00:00 2001 From: Mike Ng Date: Mon, 2 Nov 2020 09:17:31 -0500 Subject: [PATCH 2/2] removed redundant sed for apply-spoke-cr-kind, renamed cluster-ip-kind to cluster-hub-ip-kind, pass in the kubeconfig for one of the kubectl commands that was missing the kubeconfig param Signed-off-by: Mike Ng --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 0751d73ab..6b2056343 100644 --- a/Makefile +++ b/Makefile @@ -105,7 +105,7 @@ install-olm: ensure-operator-sdk install-olm-kind: ensure-operator-sdk $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) get crds | grep clusterserviceversion ; if [ $$? -ne 0 ] ; then $(OPERATOR_SDK) olm install --version $(OLM_VERSION); fi - $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) get ns open-cluster-management ; if [ $$? -ne 0 ] ; then $(KUBECTL) create ns open-cluster-management ; fi + $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) get ns open-cluster-management ; if [ $$? -ne 0 ] ; then $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) create ns open-cluster-management ; fi deploy-hub: deploy-hub-operator apply-hub-cr @@ -122,7 +122,7 @@ clean-hub: ensure-operator-sdk cluster-ip: CLUSTER_IP?=$(shell $(KUBECTL) get svc kubernetes -n default -o jsonpath="{.spec.clusterIP}") -cluster-ip-kind: +cluster-hub-ip-kind: CLUSTER_IP_KIND?=$(shell $(KUBECTL) --kubeconfig=$(HUB_KIND_KUBECONFIG) config view | grep server | awk '{ print $2 }' | cut -f3 -d/ | cut -f1 -d:) bootstrap-secret: cluster-ip @@ -133,7 +133,7 @@ bootstrap-secret: cluster-ip $(KUBECTL) delete secret bootstrap-hub-kubeconfig -n open-cluster-management-agent --ignore-not-found $(KUBECTL) create secret generic bootstrap-hub-kubeconfig --from-file=kubeconfig=dev-kubeconfig -n open-cluster-management-agent -bootstrap-secret-kind: cluster-ip-kind +bootstrap-secret-kind: cluster-hub-ip-kind cp $(HUB_KIND_KUBECONFIG) dev-kubeconfig $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) get ns open-cluster-management-agent; if [ $$? -ne 0 ] ; then $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) create ns open-cluster-management-agent; fi $(KUBECTL) --kubeconfig dev-kubeconfig config set clusters.kind-$(KIND_CLUSTER).server https://$(CLUSTER_IP_KIND) @@ -162,7 +162,7 @@ apply-spoke-cr: $(SED_CMD) -e "s,quay.io/open-cluster-management/registration,$(REGISTRATION_IMAGE)," -e "s,quay.io/open-cluster-management/work,$(WORK_IMAGE)," deploy/klusterlet/config/samples/operator_open-cluster-management_klusterlets.cr.yaml | $(KUBECTL) apply -f - apply-spoke-cr-kind: - $(SED_CMD) -e "s,quay.io/open-cluster-management/registration,$(REGISTRATION_IMAGE)," -e "s,quay.io/open-cluster-management/work,$(WORK_IMAGE)," deploy/klusterlet/config/samples/operator_open-cluster-management_klusterlets.cr.yaml | $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) apply -f - + $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) apply -f deploy/klusterlet/config/samples/operator_open-cluster-management_klusterlets.cr.yaml clean-spoke: ensure-operator-sdk $(KUBECTL) delete -f deploy/klusterlet/config/samples/operator_open-cluster-management_klusterlets.cr.yaml --ignore-not-found