diff --git a/Makefile b/Makefile index 3cabafeda..6ee190b6a 100644 --- a/Makefile +++ b/Makefile @@ -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)) @@ -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 diff --git a/README.md b/README.md index 29b236567..9bb5d2a12 100644 --- a/README.md +++ b/README.md @@ -12,46 +12,23 @@ 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}') @@ -59,24 +36,25 @@ Need to install ManagedCluster before deploy open-cluster-management Foundation. 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= make deploy-foundation-agent ``` diff --git a/deploy/foundation/klusterlet/kustomization.yaml b/deploy/foundation/klusterlet/kustomization.yaml index 5a423f56c..5f15e4345 100644 --- a/deploy/foundation/klusterlet/kustomization.yaml +++ b/deploy/foundation/klusterlet/kustomization.yaml @@ -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 diff --git a/deploy/foundation/klusterlet/resources/agent-manifestwork.yaml b/deploy/foundation/klusterlet/resources/agent-manifestwork.yaml index 4a3126cc7..bbd5a8640 100644 --- a/deploy/foundation/klusterlet/resources/agent-manifestwork.yaml +++ b/deploy/foundation/klusterlet/resources/agent-manifestwork.yaml @@ -2,7 +2,6 @@ apiVersion: work.open-cluster-management.io/v1 kind: ManifestWork metadata: name: deploy-foundation-agent - namespace: cluster1 spec: workload: manifests: diff --git a/deploy/foundation/klusterlet/resources/cluster-namespace.yaml b/deploy/foundation/klusterlet/resources/cluster-namespace.yaml deleted file mode 100644 index 2ff6c2f38..000000000 --- a/deploy/foundation/klusterlet/resources/cluster-namespace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: cluster1 diff --git a/deploy/managedcluster/klusterlet/install.sh b/deploy/managedcluster/klusterlet/install.sh index c7ceb909c..9169478de 100755 --- a/deploy/managedcluster/klusterlet/install.sh +++ b/deploy/managedcluster/klusterlet/install.sh @@ -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" diff --git a/examples/action/action_create.yaml b/examples/action/action_create.yaml index c3afa174b..211e809f2 100644 --- a/examples/action/action_create.yaml +++ b/examples/action/action_create.yaml @@ -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: diff --git a/examples/action/action_delete.yaml b/examples/action/action_delete.yaml index 9b03c8dbe..fe019fe3e 100644 --- a/examples/action/action_delete.yaml +++ b/examples/action/action_delete.yaml @@ -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: diff --git a/examples/action/action_update.yaml b/examples/action/action_update.yaml index 9b7ab7c1e..e613f2843 100644 --- a/examples/action/action_update.yaml +++ b/examples/action/action_update.yaml @@ -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: diff --git a/examples/view/getdeployment.yaml b/examples/view/getdeployment.yaml index 404c40bc7..76dcef7d4 100644 --- a/examples/view/getdeployment.yaml +++ b/examples/view/getdeployment.yaml @@ -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 diff --git a/go.mod b/go.mod index 0711fbb20..a4c066a61 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 6a1b2fd1c..e93d097ca 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= @@ -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=