From 1d5284e2c681fb5728e9306ffdc557a63f292742 Mon Sep 17 00:00:00 2001 From: Alonexc Date: Tue, 16 Jan 2024 10:25:07 +0800 Subject: [PATCH] improve docs --- docs/instruction/06-operator.md | 128 ++++++++++++----- .../current/instruction/06-operator.md | 132 +++++++++++++----- 2 files changed, 186 insertions(+), 74 deletions(-) diff --git a/docs/instruction/06-operator.md b/docs/instruction/06-operator.md index 2b98a69af5..ffe353e89f 100644 --- a/docs/instruction/06-operator.md +++ b/docs/instruction/06-operator.md @@ -1,6 +1,8 @@ # Integrate EventMesh with K8S -### 1. Dependencies +## 1. Local Deployment + +### 1.1 Dependencies ``` docker @@ -9,51 +11,58 @@ kubernetes (kubectl) There is some compatibility between kubernetes an docker, please check the version compatibility between them and download the corresponding version to ensure that they work properly together. ``` -### 2. Start +### 1.2 Start Operator -Go to the eventmesh-operator directory. +Go to the `eventmesh-operator` directory. ```shell -cd eventmesh-operator +$ cd eventmesh-operator ``` Install CRD into the specified k8s cluster. ```shell -make install +$ make install # Uninstall CRDs from the K8s cluster -make uninstall +$ make uninstall ``` If you get error `eventmesh-operator/bin/controller-gen: No such file or directory`, Run the following command: ```shell # download controller-gen locally if necessary. -make controller-gen +$ make controller-gen # download kustomize locally if necessary. -make kustomize +$ make kustomize ``` -View crds information: +View `crds` information: ```shell # run the following command to view crds information: -kubectl get crds +$ kubectl get crd | grep eventmesh-operator.eventmesh NAME CREATED AT connectors.eventmesh-operator.eventmesh 2023-11-28T01:35:21Z runtimes.eventmesh-operator.eventmesh 2023-11-28T01:35:21Z ``` -Create and delete CRs: +Run EventMesh-Operator. + +```shell +# run controller +$ make run +``` + +### 1.3 Create and delete CRs: -Custom resource objects are located at: /config/samples +Custom resource objects are located at: `/config/samples`, When deleting CR, simply replace `create` with `delete`. -When deleting CR, simply replace create with delete. +You can also use the command `kubectl create -f` for a step-by-step deployment. ```shell # Create CR for eventmesh-runtime、eventmesh-connector-rocketmq,Creating a clusterIP lets eventmesh-runtime communicate with other components. -make create +$ make create #success: configmap/runtime-config created @@ -63,35 +72,82 @@ configmap/connector-rocketmq-config created connectors.eventmesh-operator.eventmesh/connector-rocketmq created # View the created Service. -kubectl get service +$ kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE runtime-cluster-service ClusterIP 10.109.209.72 10000/TCP 17s +# After the pods are successfully started, run the following command to view pods. +$ kubectl get pods +NAME READY STATUS RESTARTS AGE +connector-rocketmq-0 1/1 Running 0 12m +eventmesh-runtime-0-a-0 1/1 Running 0 12m + # Delete CR -make delete +$ make delete ``` -Run eventmesh-operator create pods. +## 2. Deploy EventMesh Runtime in Kubernetes + +### 2.1 Deploy EventMesh-Operator + +Deploy EventMesh-Operator using the following command (to delete a deployment, simply replace `deploy` with `undeploy`): ```shell -# run controller -make run -# log -go fmt ./... -go vet ./... -go run ./main.go -INFO controller-runtime.metrics Metrics server is starting to listen {"addr": ":9020"} -INFO setup starting manager -INFO Starting server {"kind": "health probe", "addr": "[::]:8081"} -INFO Starting server {"path": "/metrics", "kind": "metrics", "addr": "[::]:9020"} -INFO runtime Creating a new eventMeshRuntime StatefulSet. {"StatefulSet.Namespace": "default", "StatefulSet.Name": "eventmesh-runtime-0-a"} -INFO connector Creating a new Connector StatefulSet. {"StatefulSet.Namespace": "default", "StatefulSet.Name": "connector-rocketmq"} -INFO runtime Successful reconciliation! -INFO connector Successful reconciliation! +$ cd eventmesh-operator && make deploy +``` -# After the pods are successfully started, run the following command to view pods. -kubectl get pods -NAME READY STATUS RESTARTS AGE -connector-rocketmq-0 1/1 Running 0 12m -eventmesh-runtime-0-a-0 1/1 Running 0 12m +You can also deploy EventMesh-Operator using the following command: + +```shell +# install CRDs +$ make install + +# ServiceAccount +kubectl create -f config/rbac/service_account.yaml +# ClusterRole +kubectl create -f config/rbac/role.yaml +# ClusterRoleBinding +kubectl create -f config/rbac/role_binding.yaml +# eventmesh_operator Deployment +kubectl create -f config/samples/eventmesh_operator.yaml +``` + +Use the commands `kubectl get pods`, `kubectl get crd | grep eventmesh-operator.eventmesh` to view EventMesh-Operator deployment status and CRD information. + +```shell +$ kubectl get pods +NAME READY STATUS RESTARTS AGE +eventmesh-operator-59c59f4f7b-nmmlm 1/1 Running 0 20s + +$ kubectl get crd | grep eventmesh-operator.eventmesh +connectors.eventmesh-operator.eventmesh 2024-01-10T02:40:27Z +runtimes.eventmesh-operator.eventmesh 2024-01-10T02:40:27Z ``` + +### 2.2 Deploy EventMesh Runtime + +Deploy `runtime`, `connector-rocketmq` with the following command: + +```shell +$ make create +``` + +Custom resource objects are located in: `/config/samples` or can be deployed separately using the `kubectl create -f` command: + +```shell +# runtime +kubectl create -f config/samples/eventmesh_v1_runtime.yaml +# runtime service +kubectl create -f config/samples/eventmesh_v1_runtime_cluster.yaml +# connector-rocketmq +kubectl create -f config/samples/eventmesh_v1_connectors_rocketmq.yaml +``` + +Use the command `kubectl get pods` to see if the deployment is successful. + +```shell +NAME READY STATUS RESTARTS AGE +connector-rocketmq-0 1/1 Running 0 9s +eventmesh-operator-59c59f4f7b-nmmlm 1/1 Running 0 3m12s +eventmesh-runtime-0-a-0 1/1 Running 0 15s +``` \ No newline at end of file diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/instruction/06-operator.md b/i18n/zh/docusaurus-plugin-content-docs/current/instruction/06-operator.md index 8f3ae3593c..92ac8d5901 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/instruction/06-operator.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/instruction/06-operator.md @@ -1,6 +1,8 @@ # EventMesh 与 K8S 集成 -### 1. 依赖 +## 1. 本地部署 + +### 1.1 依赖 ``` docker @@ -9,51 +11,58 @@ kubernetes (kubectl) kubernetes 和 docker 之间有一定的兼容性,请检查它们之间的版本兼容性,并下载相应的版本,以确保它们能一起正常工作。 ``` -### 2. 启动 +### 1.2 启动 -进入 eventmesh-operator 目录。 +进入 `eventmesh-operator` 目录。 ```shell -cd eventmesh-operator +$ cd eventmesh-operator ``` 将 CRD 安装到 k8s 集群。 ```shell -make install +$ make install # Uninstall CRDs from the K8s cluster -make uninstall +$ make uninstall ``` -如果出现错误`eventmesh-operator/bin/controller-gen: No such file or directory`,运行以下命令: +如果出现错误 `eventmesh-operator/bin/controller-gen: No such file or directory`,运行以下命令: ```shell # 如有必要,在本地下载 controller-gen. -make controller-gen +$ make controller-gen # 如有必要,在本地下载 kustomize. -make kustomize +$ make kustomize ``` -查看 crds 信息: +查看 `crds` 信息: ``` shell # 运行以下命令查看 crds 信息: -kubectl get crds +$ kubectl get crd | grep eventmesh-operator.eventmesh NAME CREATED AT connectors.eventmesh-operator.eventmesh 2023-11-28T01:35:21Z runtimes.eventmesh-operator.eventmesh 2023-11-28T01:35:21Z ``` -创建和删除 CRs: +启动 EventMesh-Operator。 + +```shell +# run controller +$ make run +``` + +### 1.3 创建和删除 CRs: -自定义资源对象位于:/config/samples +自定义资源对象位于:`/config/samples`,进行部署,删除 CR,只需将 `create` 替换为 `delete` 即可。 -删除 CR,只需将`create`替换为`delete`即可。 +也可使用命令 `kubectl create -f` 进行分步部署。 ```shell # 为 eventmesh-runtime、eventmesh-connector-rocketmq 创建 CR, 创建 clusterIP 可让 eventmesh-runtime 与其他组件通信。 -make create +$ make create #success: configmap/runtime-config created @@ -63,35 +72,82 @@ configmap/connector-rocketmq-config created connectors.eventmesh-operator.eventmesh/connector-rocketmq created # 查看创建的 service. -kubectl get service +$ kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE runtime-cluster-service ClusterIP 10.109.209.72 10000/TCP 17s +# 运行以下命令查看 pods。 +$ kubectl get pods +NAME READY STATUS RESTARTS AGE +connector-rocketmq-0 1/1 Running 0 12m +eventmesh-runtime-0-a-0 1/1 Running 0 12m + # Delete CR -make delete +$ make delete ``` -运行 eventmesh-operator 创建 pods。 +## 2. 在 Kubernetes 中部署 EventMesh Runtime + +### 2.1 部署 EventMesh-Operator + +使用以下命令部署 EventMesh-Operator(删除部署,只需将 `deploy` 替换为 `undeploy`): ```shell -# run controller -make run -# log -go fmt ./... -go vet ./... -go run ./main.go -INFO controller-runtime.metrics Metrics server is starting to listen {"addr": ":9020"} -INFO setup starting manager -INFO Starting server {"kind": "health probe", "addr": "[::]:8081"} -INFO Starting server {"path": "/metrics", "kind": "metrics", "addr": "[::]:9020"} -INFO runtime Creating a new eventMeshRuntime StatefulSet. {"StatefulSet.Namespace": "default", "StatefulSet.Name": "eventmesh-runtime-0-a"} -INFO connector Creating a new Connector StatefulSet. {"StatefulSet.Namespace": "default", "StatefulSet.Name": "connector-rocketmq"} -INFO runtime Successful reconciliation! -INFO connector Successful reconciliation! - -# 成功启动 pod 后,运行以下命令查看 pod。 -kubectl get pods -NAME READY STATUS RESTARTS AGE -connector-rocketmq-0 1/1 Running 0 12m -eventmesh-runtime-0-a-0 1/1 Running 0 12m +$ cd eventmesh-operator && make deploy +``` + +也可使用以下命令部署 EventMesh-Operator: + +```shell +# install CRDs +$ make install + +# ServiceAccount +kubectl create -f config/rbac/service_account.yaml +# ClusterRole +kubectl create -f config/rbac/role.yaml +# ClusterRoleBinding +kubectl create -f config/rbac/role_binding.yaml +# eventmesh_operator Deployment +kubectl create -f config/samples/eventmesh_operator.yaml +``` + +使用命令 `kubectl get pods`、`kubectl get crd | grep eventmesh-operator.eventmesh` 查看 EventMesh-Operator 部署状态和 CRD 信息 + +```shell +$ kubectl get pods +NAME READY STATUS RESTARTS AGE +eventmesh-operator-59c59f4f7b-nmmlm 1/1 Running 0 20s + +$ kubectl get crd | grep eventmesh-operator.eventmesh +connectors.eventmesh-operator.eventmesh 2024-01-10T02:40:27Z +runtimes.eventmesh-operator.eventmesh 2024-01-10T02:40:27Z +``` + +### 2.2 部署 EventMesh Runtime + +使用以下命令部署 `runtime`、`connector-rocketmq`: + +```shell +$ make create +``` + +自定义资源对象位于:`/config/samples`,也可使用 `kubectl create -f` 命令分别部署: + +```shell +# runtime +kubectl create -f config/samples/eventmesh_v1_runtime.yaml +# runtime service +kubectl create -f config/samples/eventmesh_v1_runtime_cluster.yaml +# connector-rocketmq +kubectl create -f config/samples/eventmesh_v1_connectors_rocketmq.yaml +``` + +使用命令 `kubectl get pods` 查看是否部署成功 + +```shell +NAME READY STATUS RESTARTS AGE +connector-rocketmq-0 1/1 Running 0 9s +eventmesh-operator-59c59f4f7b-nmmlm 1/1 Running 0 3m12s +eventmesh-runtime-0-a-0 1/1 Running 0 15s ``` \ No newline at end of file