ragflow?k8s部署過程圖文詳解
一、概述
ragflow官方提供的安裝方式是docker-compose方式部署的,單機運行。
k8s部署方式,暫未提供。
不過我們可以通過工具,結合docker-compose.yaml,來推演出對應服務的yaml進行部署。
過程有點曲折,結果很美好。
接下來,本文將使用ragflow-0.18.0,來進行演示詳細部署過程。
二、準備工作
前提條件
硬件
CPU :至少 4 核。
內(nèi)存 :至少 16GB。
磁盤 :至少 50GB。
操作系統(tǒng):推薦 Ubuntu 22.04+
軟件
k8s,自行搭建,或者使用云廠商提供的k8s,都可以。
Harbor,參考文章:http://www.dbjr.com.cn/server/340710vvy.htm
如果有現(xiàn)成的私有倉庫,可以忽略
NFS,參考文章:http://www.dbjr.com.cn/program/3407132ck.htm
如果有現(xiàn)成的NFS,可以忽略
符合以上條件,就可以部署了
鏡像推送
下載鏡像
docker pull elasticsearch:8.11.3 docker pull quay.io/minio/minio:RELEASE.2023-12-20T01-00-02Z docker pull mysql:8.0.39 docker pull valkey/valkey:8 docker pull infiniflow/ragflow:v0.18.0-slim
推送鏡像
這里使用shell腳本完成
#!/bin/bash images="elasticsearch:8.11.3 quay.io/minio/minio:RELEASE.2023-12-20T01-00-02Z mysql:8.0.39 valkey/valkey:8 infiniflow/ragflow:v0.18.0-slim" # 遍歷鏡像列表,并推送到harbor for line in $images; do #echo "$line" docker tag $line harbor.qq.cn:8083/ragflow/$line docker push harbor.qq.cn:8083/ragflow/$line done
注意修改harbor的的地址為實際訪問地址
登錄到harbor,查看鏡像
創(chuàng)建命名空間以及密鑰
創(chuàng)建命名空間ragflow
kubectl create namespace ragflow
創(chuàng)建拉取鏡像需要的密鑰
kubectl create secret docker-registry harbor-key --docker-server=harbor.qq.com:8083 --docker-username=devops --docker-password=1sB5r9UShgK5 --namespace=ragflow
注意:修改harbor地址,用戶名,密碼。
下載部署yaml
yaml已經(jīng)寫好了,推送到我個人的github,地址:https://github.com/987334176/ragflow-k8s
下載項目后,進入文件夾0.18.0
目錄結構
env --> 全局環(huán)境變量 pvc --> 所有組件,統(tǒng)一使用一個pvc來進行持久化存儲 databases --> 數(shù)據(jù)庫相關:mysql,redis middleware --> 中間件相關:elasticsearch,minio services --> 服務相關:ragflow
三、創(chuàng)建全局環(huán)境變量
這里有30個多個變量,直接一鍵運行
kubectl apply -f env/env.yaml
四、創(chuàng)建pv和pvc
創(chuàng)建storageClass,因為pv和pvc必須是同一個storageClass才能綁定成功
kubectl apply -f pvc/storageClass.yaml
注意:修改NFS 服務端的共享路徑,provisioner必須指定為nfs-client
nfs-client是一個外部的動態(tài)存儲供給器(Provisioner),用于在 Kubernetes 集群中動態(tài)創(chuàng)建和管理基于 NFS(Network File System)的 PersistentVolumes(PV)。它是 Kubernetes 社區(qū)提供的一個解決方案,用于支持 NFS 存儲的動態(tài)供給。
創(chuàng)建pv,pvc。注意:這里的pv是自建的NFS,請根據(jù)實際情況修改
kubectl apply -f pvc/pv.yaml kubectl apply -f pvc/pvc.yaml
查看pvc狀態(tài),注意:請確保pvc狀態(tài)為Bound
# kubectl -n ragflow get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE ragflow-pvc Bound ragflow 10Gi RWX nfs-storage <unset> 12m
服務器已經(jīng)掛載好了NFS,進入到NFS根目錄
cd /mnt/nfs_share
創(chuàng)建ragflow相關持久化文件,并設置權限
mkdir -p ragflow/volumes/elasticsearch/data mkdir -p ragflow/volumes/minio/data mkdir -p ragflow/volumes/mysql/data mkdir -p ragflow/volumes/redis/data mkdir -p ragflow/volumes/ragflow/logs chmod 777 -R ragflow
五、數(shù)據(jù)庫相關
MySQL
MySQL 是一個廣泛使用的開源關系型數(shù)據(jù)庫管理系統(tǒng)(RDBMS),它使用 SQL(結構化查詢語言)作為與數(shù)據(jù)庫交互的標準語言。
修改文件mysql-StatefulSet.yaml
vi databases/mysql/mysql-StatefulSet.yaml
修改紅色部分,增加了密鑰,改了鏡像地址
spec: imagePullSecrets: - name: harbor-key ... image: harbor.qq.com:8083/ragflow/mysql:8.0.39
發(fā)布應用,注意執(zhí)行順序,先執(zhí)行configMap,再執(zhí)行下面的。
kubectl apply -f databases/mysql/mysql-cm1-configmap.yaml kubectl apply -f databases/mysql/mysql-StatefulSet.yaml kubectl apply -f databases/mysql/mysql-Service.yaml
等待1分鐘,查看pod,確保是Running狀態(tài)
# kubectl -n ragflow get pods|grep mysql mysql-0 1/1 Running 1 (13m ago) 14m
查看mysql日志
# kubectl -n ragflow logs -f mysql-0 ... 2025-04-28T02:32:18.925930Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.39' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL. ...
出現(xiàn)3306表示mysql啟動正常。
測試mysql登錄
# kubectl -n ragflow exec -it mysql-0 -- /bin/bash bash-5.1# mysql -h localhost -u root -pinfini1#raGflow mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.39 MySQL Community Server - GPL Copyright (c) 2000, 2024, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | rag_flow | | sys | +--------------------+ 5 rows in set (0.00 sec) mysql>
能正常顯示數(shù)據(jù)庫列表,就說明用戶登錄正常。
注意:mysql8默認是啟動了密碼復雜性校驗的,因為官方給的密碼,太簡單了。所以在全局變量中修改了root密碼,否則mysql啟動會失敗。
因為這個問題,搞了半天,一直啟動失敗,要崩潰了。所以后來沒辦法,直接改了root密碼,就正常了。
Valkey
Valkey 是 Redis 的開源替代方案,由 Linux 基金會推出,得到了 AWS、Google Cloud 等公司的支持。
Valkey 是根據(jù) BSD 許可發(fā)布的,是一款高性能鍵 / 值數(shù)據(jù)存儲,支持各種負載,包括緩存、消息隊列,也可用作主數(shù)據(jù)庫。Valkey 可以作為獨立守護進程或在集群內(nèi)運行,有復制和高可用性選項。
修改文件redis-StatefulSet.yaml
vi databases/redis/redis-StatefulSet.yaml
修改紅色部分,增加了密鑰,改了鏡像地址
spec: imagePullSecrets: - name: harbor-key ... image: harbor.qq.com:8083/ragflow/valkey/valkey:8
發(fā)布應用
kubectl apply -f databases/redis/redis-StatefulSet.yaml kubectl apply -f databases/redis/redis-Service.yaml
等待1分鐘,查看pod,確保是Running狀態(tài)
# kubectl -n ragflow get pods|grep redis redis-0 1/1 Running 0 2m53s
查看redis日志
# kubectl -n ragflow logs -f redis-0 1:C 28 Apr 2025 10:43:41.677 * oO0OoO0OoO0Oo Valkey is starting oO0OoO0OoO0Oo 1:C 28 Apr 2025 10:43:41.677 * Valkey version=8.0.2, bits=64, commit=00000000, modified=0, pid=1, just started 1:C 28 Apr 2025 10:43:41.677 * Configuration loaded 1:M 28 Apr 2025 10:43:41.678 * monotonic clock: POSIX clock_gettime 1:M 28 Apr 2025 10:43:41.678 * Running mode=standalone, port=6379. 1:M 28 Apr 2025 10:43:41.765 * Server initialized 1:M 28 Apr 2025 10:43:41.767 * Ready to accept connections tcp
出現(xiàn)6379表示redis啟動正常。
六、中間件相關
Elasticsearch
Elasticsearch 是一個開源的、基于 Lucene 的分布式全文搜索引擎,提供了強大的搜索和數(shù)據(jù)分析能力。它采用倒排索引技術,能夠快速高效地處理大規(guī)模數(shù)據(jù)的搜索和分析,廣泛應用于日志分析、推薦系統(tǒng)、企業(yè)級搜索等場景。
修改文件elasticsearch-StatefulSet.yaml
vi middleware/elasticsearch/elasticsearch-StatefulSet.yaml
修改紅色部分,增加了密鑰,改了鏡像地址
spec: imagePullSecrets: - name: harbor-key ... image: harbor.qq.com:8083/ragflow/elasticsearch:8.11.3
發(fā)布應用
kubectl apply -f middleware/elasticsearch/elasticsearch-StatefulSet.yaml kubectl apply -f middleware/elasticsearch/elasticsearch-Service.yaml
等待2分鐘,查看pod,確保是Running狀態(tài)
# kubectl -n ragflow get pods|grep es es01-0 1/1 Running 0 112s
查看es日志
# kubectl -n ragflow logs -f es01-0 ... {"@timestamp":"2025-04-28T02:49:28.858Z", "log.level": "INFO", "message":"publish_address {172.16.0.220:9200}, bound_addresses {[::]:9200}", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"main","log.logger":"org.elasticsearch.http.AbstractHttpServerTransport","elasticsearch.cluster.uuid":"xBJZ-YKRSTSyRMdPZiwltg","elasticsearch.node.id":"mLrauOXtQdWBGROGXIfd2Q","elasticsearch.node.name":"es01","elasticsearch.cluster.name":"docker-cluster"} ...
出現(xiàn)9200表示Elasticsearch啟動正常。
只要沒有明顯的錯誤就行
MinIO
MinIO 是一個高性能、開源的對象存儲服務,兼容亞馬遜 S3 云存儲服務接口,常用于存儲非結構化數(shù)據(jù),如圖片、視頻、日志文件、備份數(shù)據(jù)等。
修改文件minio-StatefulSet.yaml
vi middleware/minio/minio-StatefulSet.yaml
修改紅色部分,增加了密鑰,改了鏡像地址
spec: imagePullSecrets: - name: harbor-key ... image: harbor.bzmaster.cn:8083/ragflow/quay.io/minio/minio:RELEASE.2023-12-20T01-00-02Z
發(fā)布應用
kubectl apply -f middleware/minio/minio-StatefulSet.yaml kubectl apply -f middleware/minio/minio-Service.yaml
等待1分鐘,查看pod,確保是Running狀態(tài)
# kubectl -n ragflow get pods|grep minio minio-0 1/1 Running 0 106s
查看minio日志
# kubectl -n ragflow logs -f minio-0 Formatting 1st pool, 1 set(s), 1 drives per set. WARNING: Host local has more than 0 drives of set. A host failure will result in data becoming unavailable. You are running an older version of MinIO released 1 year before the latest release Update: Run `mc admin update` MinIO Object Storage Server Copyright: 2015-2023 MinIO, Inc. License: GNU AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html> Version: RELEASE.2023-12-20T01-00-02Z (go1.21.5 linux/amd64) Status: 1 Online, 0 Offline. S3-API: http://172.16.0.221:9000 http://127.0.0.1:9000 Console: http://172.16.0.221:9001 http://127.0.0.1:9001 Documentation: https://min.io/docs/minio/linux/index.html Warning: The standard parity is set to 0. This can lead to data loss.
七、服務相關
Ragflow
Ragflow 是一款基于深度文檔理解構建的開源 RAG(Retrieval-Augmented Generation)引擎。它旨在為各種規(guī)模的企業(yè)及個人提供一套精簡的 RAG 工作流程,結合大語言模型(LLM)針對用戶各類不同的復雜格式數(shù)據(jù)提供可靠的問答以及有理有據(jù)的引用。
修改文件ragflow-Deployment.yaml
vi services/ragflow/ragflow-Deployment.yaml
修改紅色部分,增加了密鑰,改了鏡像地址
spec: imagePullSecrets: - name: harbor-key ... image: harbor.bzmaster.cn:8083/ragflow/infiniflow/ragflow:v0.18.0-slim
發(fā)布應用,注意執(zhí)行順序,先執(zhí)行configMap,再執(zhí)行下面的。
kubectl apply -f services/ragflow/ragflow-cm1-configmap.yaml kubectl apply -f services/ragflow/ragflow-cm2-configmap.yaml kubectl apply -f services/ragflow/ragflow-cm3-configmap.yaml kubectl apply -f services/ragflow/ragflow-cm5-configmap.yaml kubectl apply -f services/ragflow/ragflow-Deployment.yaml kubectl apply -f services/ragflow/ragflow-Service.yaml
等待6分鐘,這個鏡像特別大,請耐心等待!
查看pod,確保是Running狀態(tài)
# kubectl -n ragflow get pods|grep ragflow ragflow-6bddc85f97-6xpkd 1/1 Running 0 6m48s
查看ragflow日志
# kubectl -n ragflow logs -f ragflow-6bddc85f97-6xpkd ... 2025-04-28 15:06:23,972 INFO 15 ____ ___ ______ ______ __ / __ \ / | / ____// ____// /____ _ __ / /_/ // /| | / / __ / /_ / // __ \| | /| / / / _, _// ___ |/ /_/ // __/ / // /_/ /| |/ |/ / /_/ |_|/_/ |_|\____//_/ /_/ \____/ |__/|__/ 2025-04-28 15:06:24,063 INFO 15 RAGFlow version: v0.18.0 slim 2025-04-28 15:06:24,068 INFO 15 project base: /ragflow 2025-04-28 15:06:24,085 INFO 15 Current configs, from /ragflow/conf/service_conf.yaml: ragflow: {'host': '0.0.0.0', 'http_port': 9380} mysql: {'name': 'rag_flow', 'user': 'root', 'password': '********', 'host': 'mysql', 'port': 3306, 'max_connections': 100, 'stale_timeout': 30} minio: {'user': 'rag_flow', 'password': '********', 'host': 'minio:9000'} es: {'hosts': 'http://es01:9200', 'username': 'elastic', 'password': '********'} infinity: {'uri': 'infinity:23817', 'db_name': 'default_db'} redis: {'db': 1, 'password': '********', 'host': 'redis:6379'} 2025-04-28 15:06:24,164 INFO 15 Use Elasticsearch http://es01:9200 as the doc engine. 2025-04-28 15:06:24,364 INFO 15 GET http://es01:9200/ [status:200 duration:0.195s] 2025-04-28 15:06:24,453 INFO 15 HEAD http://es01:9200/ [status:200 duration:0.076s] 2025-04-28 15:06:24,478 INFO 15 Elasticsearch http://es01:9200 is healthy. 2025-04-28 15:06:24,557 WARNING 15 Load term.freq FAIL! 2025-04-28 15:06:24,656 WARNING 15 Realtime synonym is disabled, since no redis connection. 2025-04-28 15:06:24,678 WARNING 15 Load term.freq FAIL! 2025-04-28 15:06:24,757 WARNING 15 Realtime synonym is disabled, since no redis connection. 2025-04-28 15:06:24,769 INFO 15 MAX_CONTENT_LENGTH: 134217728 2025-04-28 15:06:24,853 INFO 15 MAX_FILE_COUNT_PER_USER: 0 2025-04-28 15:07:23,080 INFO 15 init web data success:33.099204301834106 2025-04-28 15:07:23,163 INFO 15 update_progress lock_value: 054d89b4-835e-415a-b2e3-aa6bd0d64e95 2025-04-28 15:07:23,163 INFO 15 RAGFlow HTTP server start... 2025-04-28 15:07:23,265 INFO 15 WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Running on all addresses (0.0.0.0) * Running on http://127.0.0.1:9380 * Running on http://172.16.0.227:9380 ...
沒有明顯報錯就可以了
之后日志會一直出現(xiàn)RedisDB.queue_info相關信息,日志會刷屏,這個不用管,應該是定時任務。
八、訪問ragflow
如果是生產(chǎn)環(huán)境,最好是域名訪問,則需要添加一條ingress規(guī)則,指向到ragflow的svc,端口是80,并做DNS解析,指向到ingress的公網(wǎng)ip。
這里直接使用ragflow的nodeport端口訪問
# kubectl -n ragflow get svc|grep ragflow ragflow NodePort 192.168.34.159 <none> 9380:31078/TCP,80:31930/TCP,443:31213/TCP,5678:31082/TCP,5679:32741/TCP,9382:30421/TCP 23m
可以看到nodeport對應的端口是31930
查看node節(jié)點
# kubectl get node -o wide NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME ubuntu-1 Ready control-plane,master 17h v1.32.3+k3s1 10.0.2.15 <none> Ubuntu 22.04 LTS 5.15.0-136-generic docker://28.0.4
可以看到node節(jié)點ip是,10.0.2.15
訪問頁面:
http://10.0.2.15:31930
點擊注冊
輸入郵箱地址,名稱,密碼
創(chuàng)建賬號成功之后,重新登錄
登錄成功之后,切換到中文,效果如下:
九、測試ragflow
點擊右上角頭像-->模型提供商,設置通義千問
添加成功后,設置系統(tǒng)默認模型
創(chuàng)建知識庫
上傳excel文件,設置切片方法
勾選表格轉HTML
點擊解析
解析成功后,點擊文件
就可以看到數(shù)據(jù)了
文件上傳是保存在minio里面的,登錄minio后臺就可以看到了。
查看nodeport端口
# kubectl -n ragflow get svc|grep minio minio NodePort 192.168.90.129 <none> 9000:31911/TCP,9001:30355/TCP 4h23m
可以看到端口是31911
訪問頁面:
http://10.0.2.15:31911
輸入登錄信息
用戶名:rag_flow
密碼:infini_rag_flow
登錄之后,點擊最大的
這里就可以看到上傳的文件了
ragflow k8s搭建過程,到此結束!
到此這篇關于ragflow k8s部署詳細過程的文章就介紹到這了,更多相關ragflow k8s部署內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
k8s Job 執(zhí)行一次性以及批處理任務使用場景案例
這篇文章主要為大家介紹了k8s Job 執(zhí)行一次性以及批處理任務使用場景案例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-04-04詳解Rainbond內(nèi)置ServiceMesh微服務架構
這篇文章主要為大家介紹了詳解Rainbond內(nèi)置ServiceMesh微服務架構,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-04-04