Merge pull request #2040 from windsonsea/docsite1

[doc] Improve docs/working-with-anp.md
This commit is contained in:
karmada-bot 2022-07-02 09:27:25 +08:00 committed by GitHub
commit 67996bb5c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 21 deletions

View File

@ -2,21 +2,21 @@
## Purpose
For a member cluster that joins Karmada in pull mode, we need to provide a method to connect the network between the Karmada control plane and the member cluster, so that karmada-aggregated-apiserver can access this member cluster.
For a member cluster that joins Karmada in the pull mode, you need to provide a method to connect the network between the Karmada control plane and the member cluster, so that karmada-aggregated-apiserver can access this member cluster.
Deploying ANP to achieve appeal is one of the methods. This article describes how to deploy ANP in Karmada.
## Environment
## Environment
Karmada deployed using the kind tool.
Karmada can be deployed using the kind tool.
We can directly `hack/local-up-karmada.sh` to deploy Karmada.
You can directly use `hack/local-up-karmada.sh` to deploy Karmada.
## Actions
### Step 1: Download code
To facilitate demonstration, the code is modified based on ANP v0.0.24 to support access to the front server through HTTP. Here is the code base address: https://github.com/mrlihanbo/apiserver-network-proxy/tree/v0.0.24/dev.
To facilitate demonstration, the code is modified based on ANP v0.0.24 to support access to the front server through HTTP. Here is the code repository address: https://github.com/mrlihanbo/apiserver-network-proxy/tree/v0.0.24/dev.
```shell
git clone -b v0.0.24/dev https://github.com/mrlihanbo/apiserver-network-proxy.git
@ -33,7 +33,7 @@ docker build . --build-arg ARCH=amd64 -f artifacts/images/agent-build.Dockerfile
docker build . --build-arg ARCH=amd64 -f artifacts/images/server-build.Dockerfile -t swr.ap-southeast-1.myhuaweicloud.com/karmada/proxy-server:0.0.24
```
### Step 3: Generate certificate
### Step 3: Generate a certificate
Run the command to check the IP address of karmada-host-control-plane:
@ -41,17 +41,17 @@ Run the command to check the IP address of karmada-host-control-plane:
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' karmada-host-control-plane
```
Run the make certs command to generate a certificate and specify PROXY_SERVER_IP as the IP address obtained in the preceding command.
Run the `make certs` command to generate a certificate and specify PROXY_SERVER_IP as the IP address obtained in the preceding command.
```shell
make certs PROXY_SERVER_IP=x.x.x.x
```
The generated certificate is in the `certs` folder.
The certificate is generated in the `certs` folder.
### Step 4: Deploy proxy-server
Save the `proxy-server.yaml` file in the root directory of the ANP code.
Save the `proxy-server.yaml` file in the root directory of the ANP code repository.
<details>
<summary>unfold me to see the yaml</summary>
@ -133,7 +133,7 @@ data:
</details>
Save the `replace-proxy-server.sh` file in the root directory of the ANP code.
Save the `replace-proxy-server.sh` file in the root directory of the ANP code repository.
<details>
<summary>unfold me to see the shell</summary>
@ -165,14 +165,14 @@ sed -i'' -e "s/{{cluster_key}}/${CLUSTER_KEY}/g" ${cert_yaml}
</details>
Run the following command to run the script:
Run the following commands to run the script:
```shell
chmod +x replace-proxy-server.sh
bash replace-proxy-server.sh
```
Deploying the proxy-server on the Karmada control plane:
Deploy the proxy-server on the Karmada control plane:
```shell
kind load docker-image swr.ap-southeast-1.myhuaweicloud.com/karmada/proxy-server:0.0.24 --name karmada-host
@ -182,7 +182,7 @@ kubectl --context=karmada-host apply -f proxy-server.yaml
### Step 5: Deploy proxy-agent
Save the `proxy-agent.yaml` file in the root directory of the ANP code.
Save the `proxy-agent.yaml` file in the root directory of the ANP code repository.
<details>
<summary>unfold me to see the yaml</summary>
@ -252,7 +252,7 @@ data:
</details>
Save the `replace-proxy-agent.sh` file in the root directory of the ANP code.
Save the `replace-proxy-agent.sh` file in the root directory of the ANP code repository.
<details>
<summary>unfold me to see the shell</summary>
@ -279,29 +279,32 @@ sed -i'' -e "s/{{proxy_agent_key}}/${PROXY_AGENT_KEY}/g" ${cert_yaml}
</details>
Run the following command to run the script:
Run the following commands to run the script:
```shell
chmod +x replace-proxy-agent.sh
bash replace-proxy-agent.sh
```
Deploying the proxy-agent in the pull mode member cluster (in this example, cluster member3 cluster is in pull mode.):
Deploy the proxy-agent in the pull mode for a member cluster (in this example, the `member3` cluster is in the pull mode.):
```shell
kind load docker-image swr.ap-southeast-1.myhuaweicloud.com/karmada/proxy-agent:0.0.24 --name member3
kubectl --kubeconfig=/root/.kube/members.config --context=member3 apply -f proxy-agent.yaml
```
**The ANP deployment is complete.**
### Step 6: Add command flags for karmada-agent deployment
**The ANP deployment is complete now.**
After deploying the ANP deployment, we need to add extra command flags `--cluster-api-endpoint` and `--proxy-server-address` for `karmada-agent` deployment in `member3` cluster.
### Step 6: Add command flags for the karmada-agent deployment
After deploying the ANP deployment, you need to add extra command flags `--cluster-api-endpoint` and `--proxy-server-address` for the `karmada-agent` deployment in the `member3` cluster.
Where `--cluster-api-endpoint` is the APIEndpoint of the cluster. You can obtain it from the KubeConfig file of the `member3` cluster.
Where `--proxy-server-address` is the address of the proxy server that is used to proxy the cluster. In current case, we can set `--proxy-server-address` to `http://<karmada_controlplan_addr>:8088`. Get `karmada_controlplan_addr` value through the following command:
Where `--proxy-server-address` is the address of the proxy server that is used to proxy the cluster. In current case, you can set `--proxy-server-address` to `http://<karmada_controlplan_addr>:8088`. Get `karmada_controlplan_addr` value through the following command:
```shell
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' karmada-host-control-plane
```
Port `8088` is set by our code modification in ANP: https://github.com/mrlihanbo/apiserver-network-proxy/blob/v0.0.24/dev/cmd/server/app/server.go#L267. You can also modify it to a different value.
Set port `8088` by modifying the code in ANP: https://github.com/mrlihanbo/apiserver-network-proxy/blob/v0.0.24/dev/cmd/server/app/server.go#L267. You can also modify it to a different value.