Add clearer documentation for multiple cluster services

Signed-off-by: chen zechun <zechun.chen@daocloud.io>
This commit is contained in:
chen zechun 2022-07-24 23:28:50 +08:00
parent ed9b838056
commit 70d06b164c
1 changed files with 74 additions and 56 deletions

View File

@ -6,7 +6,7 @@ Users are able to **export** and **import** services between clusters with [Mult
### Karmada has been installed
We can install Karmada by referring to [quick-start](https://github.com/karmada-io/karmada#quick-start), or directly run `hack/local-up-karmada.sh` script which is also used to run our E2E cases.
We can install Karmada by referring to [Quick Start](https://github.com/karmada-io/karmada#quick-start), or directly run `hack/local-up-karmada.sh` script which is also used to run our E2E cases.
### Member Cluster Network
@ -19,7 +19,7 @@ Ensure that at least two clusters have been added to Karmada, and the container
We need to install ServiceExport and ServiceImport in the member clusters.
After ServiceExport and ServiceImport have been installed on the **karmada control-plane**, we can create `ClusterPropagationPolicy` to propagate those two CRDs to the member clusters.
After ServiceExport and ServiceImport have been installed on the **Karmada Control Plane**, we can create `ClusterPropagationPolicy` to propagate those two CRDs to the member clusters.
```yaml
# propagate ServiceExport CRD
@ -79,7 +79,7 @@ spec:
- name: serve
image: jeremyot/serve:0a40de8
args:
- "--message='hello from cluster 1 (Node: {{env \"NODE_NAME\"}} Pod: {{env \"POD_NAME\"}} Address: {{addr}})'"
- "--message='hello from cluster member1 (Node: {{env \"NODE_NAME\"}} Pod: {{env \"POD_NAME\"}} Address: {{addr}})'"
env:
- name: NODE_NAME
valueFrom:
@ -121,7 +121,7 @@ spec:
### Step 2: Export service to the `member2` cluster
- Create a `ServiceExport` object on **karmada control-plane**, and then create a `PropagationPolicy` to propagate the `ServiceExport` object to the `member1` cluster.
- Create a `ServiceExport` object on **Karmada Control Plane**, and then create a `PropagationPolicy` to propagate the `ServiceExport` object to the `member1` cluster.
```yaml
apiVersion: multicluster.x-k8s.io/v1alpha1
@ -144,7 +144,7 @@ spec:
- member1
```
- Create a `ServiceImport` object on **karmada control-plane**, and then create a `PropagationPlicy` to propagate the `ServiceImport` object to the `member2` cluster.
- Create a `ServiceImport` object on **Karmada Control Plane**, and then create a `PropagationPolicy` to propagate the `ServiceImport` object to the `member2` cluster.
```yaml
apiVersion: multicluster.x-k8s.io/v1alpha1
@ -172,13 +172,31 @@ spec:
- member2
```
### Step 3: Consume service from `member2` cluster
### Step 3: Access the service from `member2` cluster
After the above steps, we can find the **derived service** which has the prefix `derived-` on the `member2` cluster. Then, we can access the **derived service** to access the service on the `member1` cluster.
Start a Pod `request` on the `member2` cluster to access the ClusterIP of **derived service**:
```
kubectl run -i --rm --restart=Never --image=jeremyot/request:0a40de8 request -- --duration={duration-time} --address={ClusterIP of derived service}
```shell
# get the services in cluster member2, and we can find the service with the name 'derived-serve'
$ kubectl --kubeconfig ~/.kube/members.config --context member2 get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
derived-serve ClusterIP 10.13.205.2 <none> 80/TCP 81s
kubernetes ClusterIP 10.13.0.1 <none> 443/TCP 15m
```
Start a pod `request` on the `member2` cluster to access the ClusterIP of **derived service**:
```shell
$ kubectl --kubeconfig ~/.kube/members.config --context member2 run -i --rm --restart=Never --image=jeremyot/request:0a40de8 request -- --duration={duration-time} --address={ClusterIP of derived service}
```
Eg, if we continue to access service for 3s, ClusterIP is `10.13.205.2`:
```shell
# access the service of derived-serve, and the pod in member1 cluster returns a response
$ kubectl --kubeconfig ~/.kube/members.config --context member2 run -i --rm --restart=Never --image=jeremyot/request:0a40de8 request -- --duration=3s --address=10.13.205.2
If you don't see a command prompt, try pressing enter.
2022/07/24 15:13:08 'hello from cluster member1 (Node: member1-control-plane Pod: serve-9b5b94f65-cp87p Address: 10.10.0.5)'
2022/07/24 15:13:09 'hello from cluster member1 (Node: member1-control-plane Pod: serve-9b5b94f65-cp87p Address: 10.10.0.5)'
pod "request" deleted
```