From 4ac8ddf3fcb5aaeacf4cf80a851a0f63daf7ce9f Mon Sep 17 00:00:00 2001 From: liuwei Date: Fri, 7 Aug 2020 15:51:52 +0800 Subject: [PATCH] fix managedcluster deploy --- Makefile | 8 ++--- deploy/managedcluster/hub/install.sh | 34 ++++++++++++++++++--- deploy/managedcluster/klusterlet/install.sh | 30 ++++++++++++++++-- 3 files changed, 60 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index f20ce3de5..88b49f341 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ kustomize_dir:=$(dir $(KUSTOMIZE)) IMAGE ?= multicloud-manager IMAGE_REGISTRY ?= quay.io/open-cluster-management IMAGE_TAG ?= latest -IMAGE_NAME ?= $(IMAGE_REGISTRY)/$(IMAGE):$(IMAGE_TAG) +FOUNDATION_IMAGE_NAME ?= $(IMAGE_REGISTRY)/$(IMAGE):$(IMAGE_TAG) # KUBEBUILDER for unit test export KUBEBUILDER_ASSETS ?=$(shell pwd)/$(PERMANENT_TMP_GOPATH)/kubebuilder/bin @@ -55,14 +55,14 @@ deploy-klusterlet: deploy-acm-foundation-hub: ensure-kustomize cp deploy/prod/hub/kustomization.yaml deploy/prod/hub/kustomization.yaml.tmp - cd deploy/prod/hub && ../../../$(KUSTOMIZE) edit set image ko://github.com/open-cluster-management/multicloud-operators-foundation/cmd/acm-controller=$(IMAGE_NAME) - cd deploy/prod/hub && ../../../$(KUSTOMIZE) edit set image ko://github.com/open-cluster-management/multicloud-operators-foundation/cmd/acm-proxyserver=$(IMAGE_NAME) + cd deploy/prod/hub && ../../../$(KUSTOMIZE) edit set image ko://github.com/open-cluster-management/multicloud-operators-foundation/cmd/acm-controller=$(FOUNDATION_IMAGE_NAME) + cd deploy/prod/hub && ../../../$(KUSTOMIZE) edit set image ko://github.com/open-cluster-management/multicloud-operators-foundation/cmd/acm-proxyserver=$(FOUNDATION_IMAGE_NAME) $(KUSTOMIZE) build deploy/prod/hub | $(KUBECTL) apply -f - mv deploy/prod/hub/kustomization.yaml.tmp deploy/prod/hub/kustomization.yaml deploy-acm-foundation-agent: ensure-kustomize cp deploy/prod/klusterlet/kustomization.yaml deploy/prod/klusterlet/kustomization.yaml.tmp - cd deploy/prod/klusterlet && ../../../$(KUSTOMIZE) edit set image ko://github.com/open-cluster-management/multicloud-operators-foundation/cmd/acm-agent=$(IMAGE_NAME) + cd deploy/prod/klusterlet && ../../../$(KUSTOMIZE) edit set image ko://github.com/open-cluster-management/multicloud-operators-foundation/cmd/acm-agent=$(FOUNDATION_IMAGE_NAME) $(KUSTOMIZE) build deploy/prod/klusterlet | $(KUBECTL) apply -f - mv deploy/prod/klusterlet/kustomization.yaml.tmp deploy/prod/klusterlet/kustomization.yaml diff --git a/deploy/managedcluster/hub/install.sh b/deploy/managedcluster/hub/install.sh index c5f7071b0..0f506acc0 100755 --- a/deploy/managedcluster/hub/install.sh +++ b/deploy/managedcluster/hub/install.sh @@ -1,31 +1,55 @@ #!/bin/bash -set -o errexi set -o nounset set -o pipefail +KUBECTL=${KUBECTL:-kubectl} + +# On openshift, OLM is installed into openshift-operator-lifecycle-manager +$KUBECTL get namespace openshift-operator-lifecycle-manager 1>/dev/null 2>&1 +if [ $? -eq 0 ]; then + export OLM_NAMESPACE=openshift-operator-lifecycle-manager +fi + rm -rf registration-operator echo "############ Cloning registration-operator" git clone https://github.com/open-cluster-management/registration-operator.git + cd registration-operator || { printf "cd failed, registration-operator does not exist" return 1 } +# TODO: Delete this +if [ -n "$IMAGE_NAME" ]; then + IMAGE_NAME_BAK="$IMAGE_NAME" + unset IMAGE_NAME +fi + echo "############ Deploying hub" make deploy-hub +if [ $? -ne 0 ]; then + echo "############ Failed to deploy hub" + exit 1 +fi + +# TODO: Delete this +if [ -n "$IMAGE_NAME_BAK" ]; then + export FOUNDATION_IMAGE_NAME="$IMAGE_NAME_BAK" + unset IMAGE_NAME_BAK +fi for i in {1..7}; do echo "############$i Checking cluster-manager-registration-controller" - RUNNING_POD=$(kubectl -n open-cluster-management-hub get pods | grep cluster-manager-registration-controller | grep -c "Running") + RUNNING_POD=$($KUBECTL -n open-cluster-management-hub get pods | grep cluster-manager-registration-controller | grep -c "Running") if [ "${RUNNING_POD}" -eq 3 ]; then break fi if [ $i -eq 7 ]; then echo "!!!!!!!!!! the cluster-manager-registration-controller is not ready within 3 minutes" - kubectl -n open-cluster-management-hub get pods + $KUBECTL -n open-cluster-management-hub get pods exit 1 fi @@ -34,14 +58,14 @@ done for i in {1..7}; do echo "############$i Checking cluster-manager-registration-webhook" - RUNNING_POD=$(kubectl -n open-cluster-management-hub get pods | grep cluster-manager-registration-webhook | grep -c "Running") + RUNNING_POD=$($KUBECTL -n open-cluster-management-hub get pods | grep cluster-manager-registration-webhook | grep -c "Running") if [ "${RUNNING_POD}" -eq 3 ]; then break fi if [ $i -eq 7 ]; then echo "!!!!!!!!!! the cluster-manager-registration-webhook is not ready within 3 minutes" - kubectl -n open-cluster-management-hub get pods + $KUBECTL -n open-cluster-management-hub get pods exit 1 fi sleep 30 diff --git a/deploy/managedcluster/klusterlet/install.sh b/deploy/managedcluster/klusterlet/install.sh index c8849ba99..6ed3b201a 100755 --- a/deploy/managedcluster/klusterlet/install.sh +++ b/deploy/managedcluster/klusterlet/install.sh @@ -1,31 +1,55 @@ #!/bin/bash -set -o errexi set -o nounset set -o pipefail +KUBECTL=${KUBECTL:-kubectl} + +# On openshift, OLM is installed into openshift-operator-lifecycle-manager +$KUBECTL get namespace openshift-operator-lifecycle-manager 1>/dev/null 2>&1 +if [ $? -eq 0 ]; then + export OLM_NAMESPACE=openshift-operator-lifecycle-manager +fi + rm -rf registration-operator echo "############ Cloning registration-operator" git clone https://github.com/open-cluster-management/registration-operator.git + cd registration-operator || { printf "cd failed, registration-operator does not exist" return 1 } +# TODO: Delete this +if [ -n "$IMAGE_NAME" ]; then + IMAGE_NAME_BAK="$IMAGE_NAME" + unset IMAGE_NAME +fi + echo "############ Deploying klusterlet" make deploy-spoke +if [ $? -ne 0 ]; then + echo "############ Failed to deploy klusterlet" + exit 1 +fi + +# TODO: Delete this +if [ -n "$IMAGE_NAME_BAK" ]; then + export FOUNDATION_IMAGE_NAME="$IMAGE_NAME_BAK" + unset IMAGE_NAME_BAK +fi for i in {1..7}; do echo "############$i Checking klusterlet-registration-agent" - RUNNING_POD=$(kubectl -n open-cluster-management-agent get pods | grep klusterlet-registration-agent | grep -c "Running") + RUNNING_POD=$($KUBECTL -n open-cluster-management-agent get pods | grep klusterlet-registration-agent | grep -c "Running") if [ "${RUNNING_POD}" -eq 3 ]; then break fi if [ $i -eq 7 ]; then echo "!!!!!!!!!! the klusterlet-registration-agent is not ready within 3 minutes" - kubectl -n open-cluster-management-agent get pods + $KUBECTL -n open-cluster-management-agent get pods exit 1 fi sleep 30