From b49b80b80c3bc67973e29923246bbff86b2620f2 Mon Sep 17 00:00:00 2001 From: Paolo Dettori Date: Sun, 21 Mar 2021 20:36:18 -0400 Subject: [PATCH 1/4] updated to use kind v. > v 0.7 Signed-off-by: Paolo Dettori --- Makefile | 23 +++++++++++-------- ...cluster-manager.clusterserviceversion.yaml | 2 +- .../klusterlet.clusterserviceversion.yaml | 2 +- .../klusterlet-registration-deployment.yaml | 2 +- .../klusterlet-work-deployment.yaml | 2 +- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index dd1caed2c..1f39a4c30 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,8 @@ KLUSTERLET_KUBECONFIG_CONTEXT?=$(shell $(KUBECTL) config current-context) KLUSTERLET_KIND_KUBECONFIG?=$(HOME)/cluster1-kubeconfig HUB_KIND_KUBECONFIG?=$(HOME)/hub-kubeconfig KIND_CLUSTER?=kind +MANAGED_CLUSTER?=cluster1 +HUB_CLUSTER?=hub OPERATOR_SDK_ARCHOS:=x86_64-linux-gnu ifeq ($(GOHOSTOS),darwin) @@ -100,8 +102,9 @@ install-olm: ensure-operator-sdk $(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) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) create ns open-cluster-management ; fi + $(KUBECTL) config use-context kind-$(MANAGED_CLUSTER) + $(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 deploy-hub: deploy-hub-operator apply-hub-cr @@ -119,11 +122,11 @@ cluster-ip: CLUSTER_IP?=$(shell $(KUBECTL) get svc kubernetes -n default -o jsonpath="{.spec.clusterIP}") 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:) + CLUSTER_IP_KIND?=$(shell $(KUBECTL) --kubeconfig $(HOME)/hub-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) + $(KUBECTL) config use-context kind-$(MANAGED_CLUSTER) $(KUBECTL) get ns open-cluster-management-agent; if [ $$? -ne 0 ] ; then $(KUBECTL) create ns open-cluster-management-agent; fi $(KUBECTL) config set clusters.kind-$(KIND_CLUSTER).server https://$(CLUSTER_IP) --kubeconfig dev-kubeconfig $(KUBECTL) delete secret bootstrap-hub-kubeconfig -n open-cluster-management-agent --ignore-not-found @@ -131,10 +134,11 @@ bootstrap-secret: cluster-ip 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) - $(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 + $(KUBECTL) config use-context kind-$(MANAGED_CLUSTER) + $(KUBECTL) get ns open-cluster-management-agent; if [ $$? -ne 0 ] ; then $(KUBECTL) create ns open-cluster-management-agent; fi + $(KUBECTL) --kubeconfig dev-kubeconfig config set clusters.kind-$(HUB_CLUSTER).server https://$(CLUSTER_IP_KIND) + $(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 # Registration e2e expects to read bootstrap secret from open-cluster-management/e2e-bootstrap-secret # TODO: think about how to factor this @@ -158,7 +162,8 @@ 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: - $(KUBECTL) --kubeconfig=$(KLUSTERLET_KIND_KUBECONFIG) apply -f deploy/klusterlet/config/samples/operator_open-cluster-management_klusterlets.cr.yaml + $(KUBECTL) config use-context kind-$(MANAGED_CLUSTER) + $(KUBECTL) 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 diff --git a/deploy/cluster-manager/olm-catalog/cluster-manager/manifests/cluster-manager.clusterserviceversion.yaml b/deploy/cluster-manager/olm-catalog/cluster-manager/manifests/cluster-manager.clusterserviceversion.yaml index ff9447829..f33a47f0d 100644 --- a/deploy/cluster-manager/olm-catalog/cluster-manager/manifests/cluster-manager.clusterserviceversion.yaml +++ b/deploy/cluster-manager/olm-catalog/cluster-manager/manifests/cluster-manager.clusterserviceversion.yaml @@ -204,7 +204,7 @@ spec: deployments: - name: cluster-manager spec: - replicas: 3 + replicas: 1 selector: matchLabels: app: cluster-manager diff --git a/deploy/klusterlet/olm-catalog/klusterlet/manifests/klusterlet.clusterserviceversion.yaml b/deploy/klusterlet/olm-catalog/klusterlet/manifests/klusterlet.clusterserviceversion.yaml index c35fb2b4b..436dde4f6 100644 --- a/deploy/klusterlet/olm-catalog/klusterlet/manifests/klusterlet.clusterserviceversion.yaml +++ b/deploy/klusterlet/olm-catalog/klusterlet/manifests/klusterlet.clusterserviceversion.yaml @@ -202,7 +202,7 @@ spec: deployments: - name: klusterlet spec: - replicas: 3 + replicas: 1 selector: matchLabels: app: klusterlet diff --git a/manifests/klusterlet/klusterlet-registration-deployment.yaml b/manifests/klusterlet/klusterlet-registration-deployment.yaml index 83c5b5610..0adf99e48 100644 --- a/manifests/klusterlet/klusterlet-registration-deployment.yaml +++ b/manifests/klusterlet/klusterlet-registration-deployment.yaml @@ -6,7 +6,7 @@ metadata: labels: app: klusterlet-registration-agent spec: - replicas: 3 + replicas: 1 selector: matchLabels: app: klusterlet-registration-agent diff --git a/manifests/klusterlet/klusterlet-work-deployment.yaml b/manifests/klusterlet/klusterlet-work-deployment.yaml index 40f016123..00e54b086 100644 --- a/manifests/klusterlet/klusterlet-work-deployment.yaml +++ b/manifests/klusterlet/klusterlet-work-deployment.yaml @@ -6,7 +6,7 @@ metadata: labels: app: klusterlet-manifestwork-agent spec: - replicas: 3 + replicas: 1 selector: matchLabels: app: klusterlet-manifestwork-agent From cee798f8d6752064276a440a928140d5273a7b8d Mon Sep 17 00:00:00 2001 From: Paolo Dettori Date: Mon, 22 Mar 2021 09:31:03 -0400 Subject: [PATCH 2/4] support kind version >= 0.7 Signed-off-by: Paolo Dettori --- Makefile | 2 +- .../manifests/cluster-manager.clusterserviceversion.yaml | 2 +- .../klusterlet/manifests/klusterlet.clusterserviceversion.yaml | 2 +- manifests/klusterlet/klusterlet-registration-deployment.yaml | 2 +- manifests/klusterlet/klusterlet-work-deployment.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 1f39a4c30..0855794d2 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ cluster-ip: CLUSTER_IP?=$(shell $(KUBECTL) get svc kubernetes -n default -o jsonpath="{.spec.clusterIP}") cluster-hub-ip-kind: - CLUSTER_IP_KIND?=$(shell $(KUBECTL) --kubeconfig $(HOME)/hub-kubeconfig config view | grep server | awk '{ print $2 }' | cut -f3 -d/ | cut -f1 -d:) + CLUSTER_IP_KIND?=$(shell $(KUBECTL) --kubeconfig $(HOME)/hub-kubeconfig config view | grep server | awk '{ print $2 }' | cut -f3 -d/) bootstrap-secret: cluster-ip cp $(KUBECONFIG) dev-kubeconfig diff --git a/deploy/cluster-manager/olm-catalog/cluster-manager/manifests/cluster-manager.clusterserviceversion.yaml b/deploy/cluster-manager/olm-catalog/cluster-manager/manifests/cluster-manager.clusterserviceversion.yaml index f33a47f0d..ff9447829 100644 --- a/deploy/cluster-manager/olm-catalog/cluster-manager/manifests/cluster-manager.clusterserviceversion.yaml +++ b/deploy/cluster-manager/olm-catalog/cluster-manager/manifests/cluster-manager.clusterserviceversion.yaml @@ -204,7 +204,7 @@ spec: deployments: - name: cluster-manager spec: - replicas: 1 + replicas: 3 selector: matchLabels: app: cluster-manager diff --git a/deploy/klusterlet/olm-catalog/klusterlet/manifests/klusterlet.clusterserviceversion.yaml b/deploy/klusterlet/olm-catalog/klusterlet/manifests/klusterlet.clusterserviceversion.yaml index 436dde4f6..c35fb2b4b 100644 --- a/deploy/klusterlet/olm-catalog/klusterlet/manifests/klusterlet.clusterserviceversion.yaml +++ b/deploy/klusterlet/olm-catalog/klusterlet/manifests/klusterlet.clusterserviceversion.yaml @@ -202,7 +202,7 @@ spec: deployments: - name: klusterlet spec: - replicas: 1 + replicas: 3 selector: matchLabels: app: klusterlet diff --git a/manifests/klusterlet/klusterlet-registration-deployment.yaml b/manifests/klusterlet/klusterlet-registration-deployment.yaml index 0adf99e48..83c5b5610 100644 --- a/manifests/klusterlet/klusterlet-registration-deployment.yaml +++ b/manifests/klusterlet/klusterlet-registration-deployment.yaml @@ -6,7 +6,7 @@ metadata: labels: app: klusterlet-registration-agent spec: - replicas: 1 + replicas: 3 selector: matchLabels: app: klusterlet-registration-agent diff --git a/manifests/klusterlet/klusterlet-work-deployment.yaml b/manifests/klusterlet/klusterlet-work-deployment.yaml index 00e54b086..40f016123 100644 --- a/manifests/klusterlet/klusterlet-work-deployment.yaml +++ b/manifests/klusterlet/klusterlet-work-deployment.yaml @@ -6,7 +6,7 @@ metadata: labels: app: klusterlet-manifestwork-agent spec: - replicas: 1 + replicas: 3 selector: matchLabels: app: klusterlet-manifestwork-agent From eaff13d3645302ebd3568b539956c725247c7114 Mon Sep 17 00:00:00 2001 From: Paolo Dettori Date: Wed, 24 Mar 2021 15:05:59 -0400 Subject: [PATCH 3/4] fix makefile for passing e2e test Signed-off-by: Paolo Dettori --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0855794d2..cb477b4bd 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,6 @@ 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 MANAGED_CLUSTER?=cluster1 HUB_CLUSTER?=hub @@ -126,9 +125,9 @@ cluster-hub-ip-kind: bootstrap-secret: cluster-ip cp $(KUBECONFIG) dev-kubeconfig - $(KUBECTL) config use-context kind-$(MANAGED_CLUSTER) + $(KUBECTL) config use-context $(KLUSTERLET_KUBECONFIG_CONTEXT) $(KUBECTL) get ns open-cluster-management-agent; if [ $$? -ne 0 ] ; then $(KUBECTL) create ns open-cluster-management-agent; fi - $(KUBECTL) config set clusters.kind-$(KIND_CLUSTER).server https://$(CLUSTER_IP) --kubeconfig dev-kubeconfig + $(KUBECTL) config set clusters.kind-$(MANAGED_CLUSTER).server https://$(CLUSTER_IP) --kubeconfig dev-kubeconfig $(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 From 81dd5c77460c95c797953eaf2d01290d24361bb1 Mon Sep 17 00:00:00 2001 From: Paolo Dettori Date: Thu, 25 Mar 2021 10:21:19 -0400 Subject: [PATCH 4/4] update README with MANAGED_CLUSTER instead of KIND_CLUSTER Signed-off-by: Paolo Dettori --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b3b3365b7..84ea8f28c 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,13 @@ Check the [CONTRIBUTING Doc](CONTRIBUTING.md) for how to contribute to the repo. ## Deploy all-in-one deployment on kind 1. Create a kind cluster -2. Deploy all compoenent on the kind cluster ``` - export KIND_CLUSTER={kind cluster name} + kind create cluster --name cluster1 + kind get kubeconfig --name cluster1 > ./.kubeconfig + ``` +2. Deploy all components on the kind cluster + ``` + export MANAGED_CLUSTER=cluster1 make deploy ``` 3. To clean the environment, run `make clean-deploy` @@ -35,7 +39,7 @@ Check the [CONTRIBUTING Doc](CONTRIBUTING.md) for how to contribute to the repo. ## What is next -After a successfull deployment, a `certificatesigningrequest` and a `managedcluster` will +After a successful deployment, a `certificatesigningrequest` and a `managedcluster` will be created on the hub. ```