Skip to content

Commit

Permalink
chore: update rating doc
Browse files Browse the repository at this point in the history
  • Loading branch information
0xff-dev committed Jan 10, 2024
1 parent cb33b53 commit adc4cad
Showing 1 changed file with 128 additions and 21 deletions.
149 changes: 128 additions & 21 deletions docs/develop-guid/core/rating/enablerating.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,81 @@ sidebar_position: 1

参考[安装内核](../../../quick-start/quick-install.md)完成内核(未启用Rating)安装。

## 2. 创建命名空间 `kubebb-addons`
## 2. 创建需要的命名空间 `kubebb-addons`, `tekton`

:::info
tekton 会安装在 `tekton` 的命名空间下。
后续安装的组件都会添加到`kubebb-addons`命名空间中,作为kubebb的扩展
:::

```shell
kubectl create namespace kubebb-addons
kubectl create ns kubebb-addons tekton
```

## 3. 安装Tekton流水线

官方组件仓库提供了[Tekton组件安装包](https://github.com/kubebb/components/tree/main/charts/tekton-operator)[Tekton安装示例](https://github.com/kubebb/components/tree/main/examples/tekton-operator)。可以使用内核快速完成tekton的安装。
```yaml
# install-tekton.yaml
apiVersion: core.kubebb.k8s.com.cn/v1alpha1
kind: ComponentPlan
metadata:
name: tekton
namespace: tekton
spec:
approved: true
name: tekton # similar to helm release name
version: 0.64.0
component:
name: kubebb.tekton-operator
namespace: kubebb-system
```
`kubebb core` 内核安装完成后,会自动创建一个系统的 `Repository`, 直接利用这个 `Repository` 来创建 tekton。

> 执行以下命令前需要确保组件kubebb.tekton-operator已经同步完成

命令如下:

```shell
# 默认安装到default命名空间
kubectl apply -f https://raw.githubusercontent.com/kubebb/components/main/examples/tekton-operator/componentplan.yaml
kubectl apply -f install-tekton.yaml
```

查看安装状态:

```shell
kubectl get pods --watch
kubectl -ntekton get pods --watch
```

如果安装完成,输出如下:

```shell
❯ kubectl get pods
NAME READY STATUS RESTARTS AGE
my-tekton-tekton-operator-68bdffc888-8dtfx 2/2 Running 0 25m
my-tekton-tekton-operator-webhook-78bdfcbc77-6k6cx 1/1 Running 0 25m
root@macbookpro:~/workspace/test-arcadia-helm/rating# kubectl get po -ntekton
NAME READY STATUS RESTARTS AGE
tekton-tekton-operator-7754767b9f-hjzjq 2/2 Running 0 2m35s
tekton-tekton-operator-webhook-66c8448c8b-qmzz7 1/1 Running 0 2m35s
```

安装完成后,检查 tekton 安装的 CRD.

```shell
root@macbookpro:~/workspace/test-arcadia-helm/rating# kubectl get crd|grep tekton
clustertasks.tekton.dev 2024-01-10T06:41:24Z
customruns.tekton.dev 2024-01-10T06:41:25Z
pipelineresources.tekton.dev 2024-01-10T06:41:25Z
pipelineruns.tekton.dev 2024-01-10T06:41:25Z
pipelines.tekton.dev 2024-01-10T06:41:25Z
resolutionrequests.resolution.tekton.dev 2024-01-10T06:41:25Z
runs.tekton.dev 2024-01-10T06:41:25Z
taskruns.tekton.dev 2024-01-10T06:41:25Z
tasks.tekton.dev 2024-01-10T06:41:25Z
tektonchains.operator.tekton.dev 2024-01-10T06:41:19Z
tektonconfigs.operator.tekton.dev 2024-01-10T06:41:19Z
tektondashboards.operator.tekton.dev 2024-01-10T06:41:19Z
tektonhubs.operator.tekton.dev 2024-01-10T06:41:19Z
tektoninstallersets.operator.tekton.dev 2024-01-10T06:41:19Z
tektonpipelines.operator.tekton.dev 2024-01-10T06:41:19Z
tektonresults.operator.tekton.dev 2024-01-10T06:41:19Z
tektontriggers.operator.tekton.dev 2024-01-10T06:41:19Z
```

如果长时间安装未完成,可查看对应的Componentplan资源的状态。
Expand Down Expand Up @@ -89,24 +128,40 @@ arcadia.llms 32s

2. 安装Arcadia AI组件

> 此处建议采用组件订阅自动安装的模式,默认安装到default命名空间
```yaml
# arcadia-sub.yaml
apiVersion: core.kubebb.k8s.com.cn/v1alpha1
kind: Subscription
metadata:
name: arcadia
namespace: kubebb-system
spec:
component:
name: arcadia.arcadia
namespace: kubebb-system
componentPlanInstallMethod: auto
name: arcadia
```

```shell
kubectl apply -f https://raw.githubusercontent.com/kubebb/components/main/examples/arcadia/subscription.yaml
kubectl apply -f arcadia-sub.yaml
```

3. 查看安装状态

```shell
❯ kubectl get pods --watch
NAME READY STATUS RESTARTS AGE
my-tekton-tekton-operator-68bdffc888-8dtfx 2/2 Running 0 48m
my-tekton-tekton-operator-webhook-78bdfcbc77-6k6cx 1/1 Running 0 48m
arcadia-5cb86f8787-jvd7j 0/1 Pending 0 0s
arcadia-5cb86f8787-jvd7j 0/1 Pending 0 0s
arcadia-5cb86f8787-jvd7j 0/1 ContainerCreating 0 0s
arcadia-5cb86f8787-jvd7j 0/1 Running 0 20s
arcadia-5cb86f8787-jvd7j 1/1 Running 0 30s
kubectl get po -nkubebb-system
NAME READY STATUS RESTARTS AGE
arcadia-apiserver-559974c74b-r8jrp 0/1 ContainerCreating 0 5m5s
arcadia-chromadb-0 0/1 Pending 0 5m4s
arcadia-controller-85cbddc8fd-bbh4q 1/1 Running 0 5m5s
arcadia-dataprocess-57b99c84bb-sgr9f 0/1 ContainerCreating 0 5m5s
arcadia-fastchat-6b4b454d69-mqjsl 0/2 ContainerCreating 0 5m5s
arcadia-minio-58d6b4885c-vdgzx 0/1 Pending 0 5m5s
arcadia-portal-64c5b7f986-5dc8x 1/1 Running 0 5m5s
arcadia-postgresql-0 0/1 Pending 0 5m4s
kubebb-core-679594d66f-r769g 1/1 Running 0 69m
```

## 5. 更新内核
Expand Down Expand Up @@ -137,3 +192,55 @@ kubebb-core-6d78d7d8fd-vxbc6 0/1 Terminating 0 2m3s
1.6935407235060694e+09 INFO Starting EventSource {"controller": "rating", "controllerGroup": "core.kubebb.k8s.com.cn", "controllerKind": "Rating", "source": "kind source: *v1alpha1.Rating"}
1.6935407235063274e+09 INFO Starting EventSource {"controller": "rating", "controllerGroup": "core.kubebb.k8s.com.cn", "controllerKind": "Rating", "source": "kind source: *v1beta1.PipelineRun"}
```

## 6 创建系统 LLM

因为要进行 AI 评测,为了保证评测结果的公平,需要全局配置一个 `LLM`, 这个资源的 yaml 格式如下

```yaml
apiVersion: arcadia.kubeagi.k8s.com.cn/v1alpha1
kind: LLM
metadata:
name: zhipuai # LLM 的名字
namespace: kubebb-system # LLM的namespace
spec:
provider:
endpoint:
authSecret: # authSecret 是当我们选择了一个模型服务后,例如 openai,zhipuai 等,会给用户一个 token 进行 api调用
kind: secret
name: zhipuai
url: https://open.bigmodel.cn/api/paas/v3/model-api
type: zhipuai
```

这里需要关注的就是 `spec.privider.endpoint`, 其中 `authSecret` 是配置一个 secret 的名字,这个secret中保存了访问 AI 服务的 `Token`, `Token` 在 secret的存储字段是 `apiKey`

```yaml
apiVersion: v1
data:
apiKey: YmFzZTY0Cg==
kind: Secret
metadata:
name: zhipuai
namespace: kubebb-system
type: Opaque
```

`url` 字段,就是模型服务提供的调用接口的地址。

目前平台支持 `openai` 和 `zhipuai`,所以 `spec.type` 字段就是这两个值可选。
因为系统中可能存在多个 `LLM`, 所以我们需要一个配置指明 AI 要使用的 `LLM`。所以我们需要在创建一个 configmap 名字叫 `system-llm`,名字是固定的。
包含两个字段:

- name 使用的LLM的名字
- namespace 使用的LLM所在的namespace

```yaml
kind: ConfigMap
metadata:
name: system-llm
namespace: kubebb-system
data:
name: "zhipuai"
namespace: "kubebb-system"
```

0 comments on commit adc4cad

Please sign in to comment.