本文主要是介绍cloudreve网盘迁移K8S,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
先贴配置文件了
cloudreve.yaml
apiVersion: apps/v1
kind: Deployment
metadata:name: cloudreve-deployment
spec:replicas: 1selector:matchLabels:app: cloudrevetemplate:metadata:labels:app: cloudrevespec:containers:- name: cloudreveimage: cloudreve:latestimagePullPolicy: NevervolumeMounts:- name: datamountPath: /app/data- name: config-volumemountPath: /app/conf.inisubPath: conf.inivolumes:- name: config-volumeconfigMap:name: cloudreve-config- name: datanfs:path: /dataserver: 192.168.57.61
---
apiVersion: v1
kind: Service
metadata:name: cloudreve-servicelabels:app: cloudreve
spec:ports:- port: 9000name: cloudreveprotocol: TCPtargetPort: 5212nodePort: 30000selector:app: cloudrevetype: NodePort
---
apiVersion: v1
kind: ConfigMap
metadata:name: cloudreve-config
data:conf.ini: |[System]Debug = falseMode = masterListen = :5212SessionSecret = NWHeTEjapYr1WTr3utGgy6sZ31EUG10NUtOFZx0ORZDNF8LYaYRRW5wYWNOmenx8HashIDSalt = fsoe4LGVhQFscdBp8TmRZRyfaE5EPU33I7Xf3rWQexO6nxw29D8k4Bqac21TfDkg
mountPath: /app/data 是将NFS挂到 /app/data 作为数据目录来存储网盘的文件
因为要使用configmap挂conf.ini 但是挂载到 /app目录后会将目录内的所有文件覆盖找不到启动文件导致镜像无法启动
所以用了
- name: config-volume
mountPath: /app/conf.ini
subPath: conf.ini
这样就不会覆盖 /app下的文件了
这里使用本地的镜像,先编译 cloudreve:latest镜像
Dockerfile
FROM ubuntu:latestCOPY cloudreve /app/cloudreve
COPY conf.ini /app/conf.ini
RUN chmod +x /app/cloudreve
WORKDIR /appCMD ["./cloudreve"]
docker build -t cloudreve:latest .
启动容器
[root@master cloudreve]# kubectl apply -f cloudreve.yaml
deployment.apps/cloudreve-deployment created
service/cloudreve-service created
configmap/cloudreve-config created
查看cloudreve默认账号密码
[root@master cloudreve]# kubectl get pod
NAME READY STATUS RESTARTS AGE
cloudreve-deployment-7c7f887cc8-q9g59 1/1 Running 0 10m
[root@master cloudreve]# kubectl logs cloudreve-deployment-7c7f887cc8-q9g59 ___ _ _ / __\ | ___ _ _ __| |_ __ _____ _____ / / | |/ _ \| | | |/ _ | '__/ _ \ \ / / _ \
/ /___| | (_) | |_| | (_| | | | __/\ V / __/
\____/|_|\___/ \__,_|\__,_|_| \___| \_/ \___|V3.8.3 Commit #88409cc Pro=false
================================================[Info] 2023-12-05 12:09:55 Initializing database connection...
[Info] 2023-12-05 12:09:55 Start initializing database schema...
[Info] 2023-12-05 12:09:55 Admin user name: admin@cloudreve.org
[Info] 2023-12-05 12:09:55 Admin password: oizCkg10
[Info] 2023-12-05 12:09:56 Start executing database script "UpgradeTo3.4.0".
[Info] 2023-12-05 12:09:56 Finish initializing database schema.
[Info] 2023-12-05 12:09:56 Initialize task queue with WorkerNum = 10
[Info] 2023-12-05 12:09:56 Initialize crontab jobs...
[Info] 2023-12-05 12:09:56 Current running mode: Master.
[Info] 2023-12-05 12:09:56 Listening to ":5212"
[GIN] 2023/12/05 - 12:09:56 | 200 | 701.824µs | 192.168.57.76 | GET "/login?redirect=%2Flogin"
[GIN] 2023/12/05 - 12:09:56 | 200 | 350.788µs | 192.168.57.76 | GET "/static/css/6.57254ef2.chunk.css"
[GIN] 2023/12/05 - 12:09:56 | 200 | 18.047561ms | 192.168.57.76 | GET "/static/js/main.b93ef58f.chunk.js"
[GIN] 2023/12/05 - 12:09:56 | 200 | 237.995µs | 192.168.57.76 | GET "/login?redirect=%2Flogin"
[GIN] 2023/12/05 - 12:09:56 | 200 | 34.672902ms | 192.168.57.76 | GET "/static/js/6.df035d4b.chunk.js"
[GIN] 2023/12/05 - 12:09:56 | 200 | 213.24µs | 192.168.57.76 | GET "/static/css/6.57254ef2.chunk.css"
[GIN] 2023/12/05 - 12:09:56 | 200 | 12.010573ms | 192.168.57.76 | GET "/static/js/main.b93ef58f.chunk.js"
[GIN] 2023/12/05 - 12:09:56 | 200 | 44.951791ms | 192.168.57.76 | GET "/static/js/6.df035d4b.chunk.js"
[GIN] 2023/12/05 - 12:09:57 | 200 | 1.320966ms | 192.168.57.76 | GET "/api/v3/site/config"
[GIN] 2023/12/05 - 12:09:57 | 200 | 1.030957ms | 192.168.57.76 | GET "/static/img/favicon.ico"
[Warning] 2023-12-05 12:10:02 更新检查失败, Get "https://api.github.com/repos/cloudreve/cloudreve/releases": tls: failed to verify certificate: x509: certificate signed by unknown authority
这篇关于cloudreve网盘迁移K8S的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!