Skip to content

Commit

Permalink
fix managedcluster deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeey committed Aug 10, 2020
1 parent e148950 commit 4ac8ddf
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
34 changes: 29 additions & 5 deletions deploy/managedcluster/hub/install.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
30 changes: 27 additions & 3 deletions deploy/managedcluster/klusterlet/install.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 4ac8ddf

Please sign in to comment.