Skip to content

Commit

Permalink
update the installation
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiweiyin318 committed May 8, 2021
1 parent 0e326b8 commit 975effd
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 53 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ IMAGE ?= multicloud-manager
IMAGE_REGISTRY ?= quay.io/open-cluster-management
IMAGE_TAG ?= latest
FOUNDATION_IMAGE_NAME ?= $(IMAGE_REGISTRY)/$(IMAGE):$(IMAGE_TAG)
MANAGED_CLUSTER_NAME ?= cluster1

GIT_HOST ?= github.com/open-cluster-management
BASE_DIR := $(shell basename $(PWD))
Expand Down Expand Up @@ -67,9 +68,16 @@ deploy-foundation-hub: ensure-kustomize
deploy-foundation-agent: ensure-kustomize
cp deploy/foundation/klusterlet/kustomization.yaml deploy/foundation/klusterlet/kustomization.yaml.tmp
cd deploy/foundation/klusterlet && ../../../$(KUSTOMIZE) edit set image foundation-agent=$(FOUNDATION_IMAGE_NAME)
cd deploy/foundation/klusterlet && ../../../$(KUSTOMIZE) edit set namespace $(MANAGED_CLUSTER_NAME)
$(KUSTOMIZE) build deploy/foundation/klusterlet | $(KUBECTL) apply -f -
mv deploy/foundation/klusterlet/kustomization.yaml.tmp deploy/foundation/klusterlet/kustomization.yaml

clean-foundation-hub:
$(KUBECTL) delete -k deploy/foundation/hub

clean-foundation-agent:
$(KUBECTL) delete -k deploy/foundation/klusterlet

build-e2e:
go test -c ./test/e2e

Expand Down
48 changes: 13 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,71 +12,49 @@ Check the [CONTRIBUTING Doc](CONTRIBUTING.md) for how to contribute to the repo.

This is a guide on how to build and deploy open-cluster-management Foundation from code.

### Setup

Create a directory `$GOPATH/src/github.com/open-cluster-management`, and clone the code into the directory. Since the build process will use (eventually installing) some `golang` tools, makes sure you have `$GOPATH/bin` added to your `$PATH`.

Populate the vendor directory. If necessary, set environment variable `GO111MODULE=on`.

```sh
go mod vendor
```

### Build
### Build images

Run the following after cloning/pulling/making a change.

```sh
make build
make images
```

make build will build all the binaries in the current directory.
`make images` will build a new image named `quay.io/open-cluster-management/multicloud-manager:latest`.

### Prerequisites

Need to install ManagedCluster before deploy open-cluster-management Foundation.

1. Install Cluster Manager on Hub cluster.
Need to install **Cluster Manager** and **Klusterlet** before deploy Foundation components. The installation instruction is [here](https://open-cluster-management.io).

```sh
make deploy-hub
```

2. Install Klusterlet On Managed cluster.

1. Copy `kubeconfig` of Hub to `~/.kubconfig`.
2. Install Klusterlet.

```sh
make deploy-klusterlet
```

3. Approve CSR on Hub cluster.
Need to approve and accept the managed clusters registered to the Hub.

* Approve CSR on Hub cluster.

```sh
MANAGED_CLUSTER=$(kubectl get managedclusters | grep cluster | awk '{print $1}')
CSR_NAME=$(kubectl get csr |grep $MANAGED_CLUSTER | grep Pending |awk '{print $1}')
kubectl certificate approve "${CSR_NAME}"
```

4. Accept Managed Cluster on Hub.
* Accept Managed Cluster on Hub.

```sh
MANAGED_CLUSTER=$(kubectl get managedclusters | grep cluster | awk '{print $1}')
kubectl patch managedclusters $MANAGED_CLUSTER --type merge --patch '{"spec":{"hubAcceptsClient":true}}'
```

### Deploy open-cluster-management Foundation from the quay.io
### Deploy Foundation

1. Deploy hub components on hub cluster.
1. Deploy foundation hub components on hub cluster.

```sh
make deploy-foundation-hub
```

2. Deploy klusterlet components on managed cluster.

2. Deploy foundation agent components to the managed cluster from the hub cluster.
```sh
export MANAGED_CLUSTER_NAME=<your managed cluster name, default is cluster1>
make deploy-foundation-agent
```

Expand Down
3 changes: 2 additions & 1 deletion deploy/foundation/klusterlet/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
resources:
- resources/cluster-namespace.yaml
- resources/agent-manifestwork.yaml

namespace: cluster1

images:
- name: foundation-agent
newName: quay.io/open-cluster-management/multicloud-manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: work.open-cluster-management.io/v1
kind: ManifestWork
metadata:
name: deploy-foundation-agent
namespace: cluster1
spec:
workload:
manifests:
Expand Down
4 changes: 0 additions & 4 deletions deploy/foundation/klusterlet/resources/cluster-namespace.yaml

This file was deleted.

36 changes: 36 additions & 0 deletions deploy/managedcluster/klusterlet/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,42 @@ for i in {1..7}; do

done

for i in {1..7}; do
echo "############$i Checking managed cluster "
$KUBECTL get managedclusters cluster1 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
break
fi

if [ $i -eq 7 ]; then
echo "!!!!!!!!!! the managed cluster is not created within 3 minutes"
$KUBECTL get ns
exit 1
fi
sleep 30

done

CSR_NAME=$($KUBECTL get csr |grep cluster1 | grep Pending |awk '{print $1}')
$KUBECTL certificate approve "${CSR_NAME}"
$KUBECTL patch managedclusters cluster1 --type merge --patch '{"spec":{"hubAcceptsClient":true}}'

for i in {1..7}; do
echo "############$i Checking managed cluster namespace is created"
$KUBECTL get ns cluster1 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
break
fi

if [ $i -eq 7 ]; then
echo "!!!!!!!!!! the managed cluster namespace is not created within 3 minutes"
$KUBECTL get ns
exit 1
fi
sleep 30

done

echo "############ ManagedCluster klusterlet is installed successfully!!"

echo "############ Cleanup"
Expand Down
2 changes: 1 addition & 1 deletion examples/action/action_create.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This work is used to create nginx deployment to clusters cluster0
# This action is used to create nginx deployment in cluster1
apiVersion: action.open-cluster-management.io/v1beta1
kind: ManagedClusterAction
metadata:
Expand Down
2 changes: 1 addition & 1 deletion examples/action/action_delete.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This work is used to create nginx deployment to clusters cluster0
# This action is used to delete nginx deployment in cluster1
apiVersion: action.open-cluster-management.io/v1beta1
kind: ManagedClusterAction
metadata:
Expand Down
2 changes: 1 addition & 1 deletion examples/action/action_update.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This work is used to create nginx deployment to clusters cluster0
# This action is used to update nginx deployment in cluster1
apiVersion: action.open-cluster-management.io/v1beta1
kind: ManagedClusterAction
metadata:
Expand Down
8 changes: 3 additions & 5 deletions examples/view/getdeployment.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# This resourceview is to get node with lable role=master from all clusters
# This view is used to get the deployment in cluster1
apiVersion: view.open-cluster-management.io/v1beta1
kind: ManagedClusterView
metadata:
labels:
name: getdeployment
name: getdeployment
namespace: cluster1
spec:
scope:
resource: deployments
name: foundation-proxyserver
namespace: open-cluster-management
name: foundation-agent
namespace: open-cluster-management-agent
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/open-cluster-management/multicloud-operators-foundation

go 1.15
go 1.16

replace k8s.io/client-go => k8s.io/client-go v0.20.0

Expand Down
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,6 @@ go.uber.org/zap v0.0.0-20180814183419-67bc79d13d15/go.mod h1:vwi/ZaCAaUcBkycHslx
go.uber.org/zap v1.8.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.14.1 h1:nYDKopTbvAPq/NrUVZwT15y2lpROBiLLyoRTbXOYWOo=
go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
go.uber.org/zap v1.15.0 h1:ZZCA22JRF2gQE5FoNmhmrf7jeJJ2uhqDUNRYKm8dvmM=
go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
Expand Down Expand Up @@ -2225,7 +2224,6 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gomodules.xyz/jsonpatch/v2 v2.0.1 h1:xyiBuvkD2g5n7cYzx6u2sxQvsAy4QJsZFCzGVdzOXZ0=
gomodules.xyz/jsonpatch/v2 v2.0.1/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU=
gomodules.xyz/jsonpatch/v2 v2.1.0 h1:Phva6wqu+xR//Njw6iorylFFgn/z547tw5Ne3HZPQ+k=
gomodules.xyz/jsonpatch/v2 v2.1.0/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU=
Expand Down Expand Up @@ -2576,7 +2574,6 @@ sigs.k8s.io/controller-runtime v0.2.0-beta.2/go.mod h1:TSH2R0nSz4WAlUUlNnOFcOR/V
sigs.k8s.io/controller-runtime v0.2.0/go.mod h1:ZHqrRDZi3f6BzONcvlUxkqCKgwasGk5FZrnSv9TVZF4=
sigs.k8s.io/controller-runtime v0.5.2/go.mod h1:JZUwSMVbxDupo0lTJSSFP5pimEyxGynROImSsqIOx1A=
sigs.k8s.io/controller-runtime v0.6.0/go.mod h1:CpYf5pdNY/B352A1TFLAS2JVSlnGQ5O2cftPHndTroo=
sigs.k8s.io/controller-runtime v0.6.2 h1:jkAnfdTYBpFwlmBn3pS5HFO06SfxvnTZ1p5PeEF/zAA=
sigs.k8s.io/controller-runtime v0.6.2/go.mod h1:vhcq/rlnENJ09SIRp3EveTaZ0yqH526hjf9iJdbUJ/E=
sigs.k8s.io/controller-runtime v0.7.0 h1:bU20IBBEPccWz5+zXpLnpVsgBYxqclaHu1pVDl/gEt8=
sigs.k8s.io/controller-runtime v0.7.0/go.mod h1:pJ3YBrJiAqMAZKi6UVGuE98ZrroV1p+pIhoHsMm9wdU=
Expand Down

0 comments on commit 975effd

Please sign in to comment.