cloudreve网盘迁移K8S

先贴配置文件了

cloudreve.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: cloudreve-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cloudreve
  template:
    metadata:
      labels:
        app: cloudreve
    spec:
      containers:
      - name: cloudreve
        image: cloudreve:latest
        imagePullPolicy: Never
        volumeMounts:
        - name: data
          mountPath: /app/data
        - name: config-volume
          mountPath: /app/conf.ini
          subPath: conf.ini
      volumes:
      - name: config-volume
        configMap:
          name: cloudreve-config
      - name: data
        nfs:
          path: /data
          server: 192.168.57.61
---
apiVersion: v1
kind: Service
metadata:
  name: cloudreve-service
  labels:
    app: cloudreve
spec:
  ports:
  - port: 9000
    name: cloudreve
    protocol: TCP
    targetPort: 5212
    nodePort: 30000
  selector:
    app: cloudreve
  type: NodePort
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: cloudreve-config
data:
  conf.ini: |
     [System]
     Debug = false
     Mode = master
     Listen = :5212
     SessionSecret = NWHeTEjapYr1WTr3utGgy6sZ31EUG10NUtOFZx0ORZDNF8LYaYRRW5wYWNOmenx8
     HashIDSalt = 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:latest
 
COPY cloudreve /app/cloudreve
COPY conf.ini  /app/conf.ini
RUN chmod +x /app/cloudreve
WORKDIR /app

CMD ["./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: [email protected]
[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

你可能感兴趣的:(K8S,kubernetes,容器)