mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-02-14 18:09:57 +00:00
update README for running klusterlet in detached mode (#180)
Signed-off-by: zhujian <jiazhu@redhat.com>
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -9,6 +9,7 @@ registration-operator
|
||||
dev-kubeconfig
|
||||
e2e-kubeconfig
|
||||
hub-kubeconfig
|
||||
external-managed-kubeconfig
|
||||
munge-csv
|
||||
|
||||
# Test binary, build with `go test -c`
|
||||
@@ -20,4 +21,5 @@ _output/
|
||||
|
||||
.kubeconfig
|
||||
.hub-kubeconfig
|
||||
.external-managed-kubeconfig
|
||||
.idea
|
||||
|
||||
32
Makefile
32
Makefile
@@ -38,7 +38,8 @@ operatorsdk_gen_dir:=$(dir $(OPERATOR_SDK))
|
||||
OLM_NAMESPACE?=olm
|
||||
OLM_VERSION?=0.16.1
|
||||
|
||||
KUSTOMIZE?=$(PERMANENT_TMP_GOPATH)/bin/kustomize
|
||||
PWD=$(shell pwd)
|
||||
KUSTOMIZE?=$(PWD)/$(PERMANENT_TMP_GOPATH)/bin/kustomize
|
||||
KUSTOMIZE_VERSION?=v3.5.4
|
||||
KUSTOMIZE_ARCHIVE_NAME?=kustomize_$(KUSTOMIZE_VERSION)_$(GOHOSTOS)_$(GOHOSTARCH).tar.gz
|
||||
kustomize_dir:=$(dir $(KUSTOMIZE))
|
||||
@@ -46,6 +47,7 @@ kustomize_dir:=$(dir $(KUSTOMIZE))
|
||||
KUBECTL?=kubectl
|
||||
KUBECONFIG?=./.kubeconfig
|
||||
HUB_KUBECONFIG?=./.hub-kubeconfig
|
||||
EXTERNAL_MANAGED_KUBECONFIG?=./.external-managed-kubeconfig
|
||||
|
||||
OPERATOR_SDK_ARCHOS:=x86_64-linux-gnu
|
||||
ifeq ($(GOHOSTOS),darwin)
|
||||
@@ -90,8 +92,13 @@ deploy-hub: deploy-hub-operator apply-hub-cr hub-kubeconfig
|
||||
|
||||
deploy-spoke: deploy-spoke-operator apply-spoke-cr
|
||||
|
||||
deploy-spoke-detached: deploy-spoke-operator apply-spoke-cr-detached
|
||||
|
||||
deploy-hub-operator: ensure-kustomize
|
||||
cp deploy/cluster-manager/config/kustomization.yaml deploy/cluster-manager/config/kustomization.yaml.tmp
|
||||
cd deploy/cluster-manager/config && $(KUSTOMIZE) edit set image quay.io/open-cluster-management/registration-operator:latest=$(IMAGE_NAME)
|
||||
$(KUSTOMIZE) build deploy/cluster-manager/config | $(KUBECTL) apply -f -
|
||||
mv deploy/cluster-manager/config/kustomization.yaml.tmp deploy/cluster-manager/config/kustomization.yaml
|
||||
|
||||
apply-hub-cr:
|
||||
$(SED_CMD) -e "s,quay.io/open-cluster-management/registration,$(REGISTRATION_IMAGE)," -e "s,quay.io/open-cluster-management/work,$(WORK_IMAGE)," -e "s,quay.io/open-cluster-management/placement,$(PLACEMENT_IMAGE)," deploy/cluster-manager/config/samples/operator_open-cluster-management_clustermanagers.cr.yaml | $(KUBECTL) apply -f -
|
||||
@@ -100,6 +107,8 @@ clean-hub: clean-hub-cr clean-hub-operator
|
||||
|
||||
clean-spoke: clean-spoke-cr clean-spoke-operator
|
||||
|
||||
clean-spoke-detached: clean-spoke-cr-detached clean-spoke-operator
|
||||
|
||||
cluster-ip:
|
||||
$(eval HUB_CONTEXT := $(shell $(KUBECTL) config current-context --kubeconfig $(HUB_KUBECONFIG)))
|
||||
$(eval HUB_CLUSTER_IP := $(shell $(KUBECTL) get svc kubernetes -n default -o jsonpath="{.spec.clusterIP}" --kubeconfig $(HUB_KUBECONFIG)))
|
||||
@@ -110,12 +119,28 @@ bootstrap-secret:
|
||||
$(KUBECTL) get ns open-cluster-management-agent; if [ $$? -ne 0 ] ; then $(KUBECTL) create ns open-cluster-management-agent; fi
|
||||
$(KUSTOMIZE) build deploy/klusterlet/config/samples/bootstrap | $(KUBECTL) apply -f -
|
||||
|
||||
bootstrap-secret-detached:
|
||||
cp $(HUB_KUBECONFIG) deploy/klusterlet/config/samples/bootstrap/hub-kubeconfig
|
||||
$(KUBECTL) get ns klusterlet; if [ $$? -ne 0 ] ; then $(KUBECTL) create ns klusterlet; fi
|
||||
$(KUSTOMIZE) build deploy/klusterlet/config/samples/bootstrap | $(SED_CMD) -e "s,namespace: open-cluster-management-agent,namespace: klusterlet," | $(KUBECTL) apply -f -
|
||||
|
||||
external-managed-secret:
|
||||
cp $(EXTERNAL_MANAGED_KUBECONFIG) deploy/klusterlet/config/samples/managedcluster/external-managed-kubeconfig
|
||||
$(KUBECTL) get ns klusterlet; if [ $$? -ne 0 ] ; then $(KUBECTL) create ns klusterlet; fi
|
||||
$(KUSTOMIZE) build deploy/klusterlet/config/samples/managedcluster | $(KUBECTL) apply -f -
|
||||
|
||||
deploy-spoke-operator: ensure-kustomize
|
||||
cp deploy/klusterlet/config/kustomization.yaml deploy/klusterlet/config/kustomization.yaml.tmp
|
||||
cd deploy/klusterlet/config && $(KUSTOMIZE) edit set image quay.io/open-cluster-management/registration-operator:latest=$(IMAGE_NAME)
|
||||
$(KUSTOMIZE) build deploy/klusterlet/config | $(KUBECTL) apply -f -
|
||||
mv deploy/klusterlet/config/kustomization.yaml.tmp deploy/klusterlet/config/kustomization.yaml
|
||||
|
||||
apply-spoke-cr: bootstrap-secret
|
||||
$(KUSTOMIZE) build deploy/klusterlet/config/samples | $(SED_CMD) -e "s,quay.io/open-cluster-management/registration,$(REGISTRATION_IMAGE)," -e "s,quay.io/open-cluster-management/work,$(WORK_IMAGE)," | $(KUBECTL) apply -f -
|
||||
|
||||
apply-spoke-cr-detached: bootstrap-secret-detached external-managed-secret
|
||||
$(KUSTOMIZE) build deploy/klusterlet/config/samples | $(SED_CMD) -e "s,mode: Default,mode: Detached," -e "s,quay.io/open-cluster-management/registration,$(REGISTRATION_IMAGE)," -e "s,quay.io/open-cluster-management/work,$(WORK_IMAGE)," | $(KUBECTL) apply -f -
|
||||
|
||||
clean-hub-cr:
|
||||
$(KUBECTL) delete managedcluster --all --ignore-not-found
|
||||
$(KUSTOMIZE) build deploy/cluster-manager/config/samples | $(KUBECTL) delete --ignore-not-found -f -
|
||||
@@ -127,6 +152,11 @@ clean-spoke-cr:
|
||||
$(KUSTOMIZE) build deploy/klusterlet/config/samples | $(KUBECTL) delete --ignore-not-found -f -
|
||||
$(KUSTOMIZE) build deploy/klusterlet/config/samples/bootstrap | $(KUBECTL) delete --ignore-not-found -f -
|
||||
|
||||
clean-spoke-cr-detached:
|
||||
$(KUSTOMIZE) build deploy/klusterlet/config/samples | $(KUBECTL) delete --ignore-not-found -f -
|
||||
$(KUSTOMIZE) build deploy/klusterlet/config/samples/bootstrap | $(SED_CMD) -e "s,namespace: open-cluster-management-agent,namespace: klusterlet," | $(KUBECTL) delete --ignore-not-found -f -
|
||||
$(KUSTOMIZE) build deploy/klusterlet/config/samples/managedcluster | $(KUBECTL) delete --ignore-not-found -f -
|
||||
|
||||
clean-spoke-operator:
|
||||
$(KUSTOMIZE) build deploy/klusterlet/config | $(KUBECTL) delete --ignore-not-found -f -
|
||||
$(KUBECTL) delete ns open-cluster-management-agent --ignore-not-found
|
||||
|
||||
43
README.md
43
README.md
@@ -86,6 +86,49 @@ We mainly provide deployment in two scenarios:
|
||||
make clean-spoke
|
||||
```
|
||||
|
||||
### Deploy spoke(Klusterlet) with Detached mode
|
||||
|
||||
We support deploy the Klusterlet(registration-agent, work-agent) outside of managed cluster, called `Detached` mode, and we define the cluster where the Klusterlet runs as management-cluster.
|
||||
|
||||
1. Set env variables.
|
||||
```shell
|
||||
export KUBECONFIG=$HOME/.kube/config
|
||||
```
|
||||
2. Switch to hub context and deploy hub components.
|
||||
```
|
||||
kubectl config use-context {hub-context}
|
||||
make deploy-hub
|
||||
```
|
||||
**PLEASE NOTE**: If you're running kubernetes in docker, the `server` address in kubeconfig may not be accessible for other clusters. In this case, you need to set `HUB_KUBECONFIG` explicitly.
|
||||
|
||||
For example, if your clusters are created by kind, you need to use kind's command to export a kubeconfig of hub with an accessible `server` address. ([The related issue](https://github.com/kubernetes-sigs/kind/issues/1305))
|
||||
|
||||
```shell
|
||||
kind get kubeconfig --name {kind-hub-cluster-name} --internal > ./.hub-kubeconfig # ./.hub-kubeconfig is default value of HUB_KUBECONFIG
|
||||
```
|
||||
3. Switch to management context and deploy agent components on management cluster.
|
||||
```
|
||||
kubectl config use-context {management-context}
|
||||
make deploy-spoke-detached
|
||||
```
|
||||
|
||||
**PLEASE NOTE**: If you're running kubernetes in docker, the `server` address in kubeconfig may not be accessible for other clusters. In this case, you need to set `EXTERNAL_MANAGED_KUBECONFIG` explicitly.
|
||||
|
||||
For example, if your clusters are created by kind, you need to use kind's command to export a kubeconfig of managed/spoke cluster with an accessible `server` address. ([The related issue](https://github.com/kubernetes-sigs/kind/issues/1305))
|
||||
|
||||
```shell
|
||||
kind get kubeconfig --name {kind-managed-cluster-name} --internal > ./.external-managed-kubeconfig # ./.external-managed-kubeconfig is default value of EXTERNAL_MANAGED_KUBECONFIG, it is only useful in Detached mode.
|
||||
```
|
||||
4. To clean the hub environment.
|
||||
```shell
|
||||
kubectl config use-context {hub-context}
|
||||
make clean-hub
|
||||
```
|
||||
5. To clean the spoke environment.
|
||||
```shell
|
||||
kubectl config use-context {management-context}
|
||||
make clean-spoke-detached
|
||||
|
||||
## What is next
|
||||
|
||||
After a successful deployment, a `certificatesigningrequest` and a `managedcluster` will
|
||||
|
||||
@@ -17,8 +17,7 @@ spec:
|
||||
apiservicedefinitions: {}
|
||||
customresourcedefinitions:
|
||||
owned:
|
||||
- description: Klusterlet defines the configurations of agents running on the
|
||||
managed cluster
|
||||
- description: Klusterlet defines the configurations of agents running on the managed cluster
|
||||
displayName: Klusterlet
|
||||
kind: Klusterlet
|
||||
name: klusterlets.operator.open-cluster-management.io
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
secretGenerator:
|
||||
- name: external-managed-kubeconfig
|
||||
namespace: klusterlet
|
||||
files:
|
||||
- kubeconfig=external-managed-kubeconfig
|
||||
type: "Opaque"
|
||||
|
||||
generatorOptions:
|
||||
disableNameSuffixHash: true
|
||||
Reference in New Issue
Block a user