用K8s部署Seafile社区版无法正常启动……

在K8s中部署,显示Pod正常Running。但只有nginx启动了。
K8S版本:1.27.4

kubectl exec -it seafile-0 -c seafile – bash
ll
显示如下:

total 28
drwxr-xr-x 1 root root 4096 Aug  8 12:39 ./
drwxr-xr-x 1 root root 4096 Jun 19 11:48 ../
drwxr-xr-x 2 root root 4096 Aug  8 12:39 conf/
lrwxrwxrwx 1 root root   20 Aug  8 12:39 logs -> /shared/seafile/logs/
drwxr-xr-x 1 root root 4096 Aug  8 12:39 seafile-server-10.0.1/

没有创建软链,貌似启动脚本没有正常执行?

ps -ef 显示如下:

UID          PID    PPID  C STIME TTY          TIME CMD
root           1       0  0 12:39 ?        00:00:00 /usr/bin/python3 -u /sbin/my_init -- /scripts/enterpoint.sh
root          16       1  0 12:39 ?        00:00:00 /usr/bin/runsvdir -P /etc/service
root          17       1  0 12:39 ?        00:00:00 /bin/bash /scripts/enterpoint.sh
root          18      16  0 12:39 ?        00:00:00 runsv cron
root          19      16  0 12:39 ?        00:00:00 runsv sshd
root          20      16  0 12:39 ?        00:00:00 runsv nginx
root          21      18  0 12:39 ?        00:00:00 /usr/sbin/cron -f
root          22      20  0 12:39 ?        00:00:00 nginx: master process /usr/sbin/nginx
www-data      43      22  0 12:39 ?        00:00:00 nginx: worker process
www-data      44      22  0 12:39 ?        00:00:00 nginx: worker process
www-data      45      22  0 12:39 ?        00:00:00 nginx: worker process
root          57      17  0 12:41 ?        00:00:00 sleep 60
root          58       0  0 12:41 pts/0    00:00:00 bash
root          71      58  0 12:41 pts/0    00:00:00 ps -ef

K8s的配置如下:

apiVersion: v1
kind: Service
metadata:
  name: seafile
spec:
  selector:
    app: seafile
  type: NodePort  #该方式会在所有节点上生效
  ports:
    - port: 80 #本Service端口
      targetPort: 80 #容器端口
      nodePort: 30004   # 节点端口,范围固定 30000 ~ 32767
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: seafile
spec:
  selector:
    matchLabels:
      app: seafile
  template:
    metadata:
      labels:
        app: seafile
    spec:
      nodeSelector:
        kubernetes.io/hostname: uk2
      containers:
      - image: mariadb:10.5
        name: seafile-mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: db_dev
        - name: MYSQL_LOG_CONSOLE
          value: "true"
        ports:
        - containerPort: 3306
        volumeMounts:
        - name: seafile-mysql-storage
          mountPath: /var/lib/mysql
      - image: memcached:1.5.6
        name: seafile-memcached
        command: ["memcached"]
        args: ["-m", "256"]
        ports:
        - containerPort: 11211
      - image: seafileltd/seafile-mc:10.0.1
        name: seafile
        env:
        - name: DB_HOST
          value: localhost
        - name: DB_ROOT_PASSWD
          value: db_dev
        - name: TIME_ZONE
          value: Asia/Shanghai
        - name: SEAFILE_ADMIN_EMAIL
          value: xxx@xxx.com
        - name: SEAFILE_ADMIN_PASSWORD
          value: xxx
        - name: SEAFILE_SERVER_LETSENCRYPT
          value: "false"
        - name: SEAFILE_SERVER_HOSTNAME
          value: xxx.com
        ports:
        - containerPort: 80
          name: seafile
        #- containerPort: 443
        #  name: ssl
        volumeMounts:
        - name: seafile-files-storage
          mountPath: /shared
      volumes:
      - name: seafile-files-storage
        hostPath:
          path: /root/data/seafile/files
      - name: seafile-mysql-storage
        hostPath:
          path: /root/data/seafile/db

打印一下是哪一步报错了

替换启动命令为

command: ["sh", "-c", "while true; do sleep 1; done"]

进入容器:

kubectl exec -it seafile-0 -c seafile -- bash

手动执行:

/sbin/my_init -- /scripts/enterpoint.sh

报错如下:

 /sbin/my_init -- /scripts/enterpoint.sh
*** Running /etc/my_init.d/01_create_data_links.sh...
*** Booting runit daemon...
*** Runit started as PID 186
*** Running /scripts/enterpoint.sh...
2023-08-10 16:02:56 Waiting Nginx
2023-08-10 16:02:56 Nginx ready
2023-08-10 16:02:56 This is an idle script (infinite loop) to keep container running.
[2023-08-10 16:02:56] Now running setup-seafile-mysql.py in auto mode.
Checking python on this machine ...


verifying password of user root ...  done

---------------------------------
This is your configuration
---------------------------------

    server name:            seafile
    server ip/domain:       xxx.com

    seafile data dir:       /opt/seafile/seafile-data
    fileserver port:        8082

    database:               create new
    ccnet database:         ccnet_db
    seafile database:       seafile_db
    seahub database:        seahub_db
    database user:          seafile


Generating ccnet configuration ...

Generating seafile configuration ...

done
Generating seahub configuration ...

----------------------------------------
Now creating ccnet database tables ...

----------------------------------------

Error: Failed to connect to mysql database ccnet_db: Access denied for user 'seafile'@'::1' (using password: YES)
Traceback (most recent call last):
  File "/scripts/start.py", line 95, in <module>
    main()
  File "/scripts/start.py", line 59, in main
    init_seafile_server()
  File "/scripts/bootstrap.py", line 167, in init_seafile_server
    call('{} auto -n seafile'.format(setup_script), env=env)
  File "/scripts/utils.py", line 70, in call
    return subprocess.check_call(*a, **kw)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '/opt/seafile/seafile-server-10.0.1/setup-seafile-mysql.sh auto -n seafile' returned non-zero exit status 1.


这里连接数据库报错

我也看到了,但是为什么是seafile用户,Mysql只配置了root用户啊。
K8s的配置是参考https://docs.seafile.com/d/cb1d3f97106847abbf31/files/?p=/docker/docker-compose.yml这个文件配置的,这个文件也没有配置seafile用户啊。

容器会自动建seafile账号

那为什么会密码不对呢?配置项都是参照docker-compose.yaml文件的,而这个文件在Docker环境是能跑起来的。
我看了K8s中的mysql,也创建了ccnet_db、seafile_db、seahub_db这几个库了,说明至少root的密码是对的,且连接上了吧。seafile这个用户确实也在mysql中创建了,只是主机是%.%.%.%,而root用户的主机是%。
seafile这个用户的密码是固定的还是动态变化的?可以自定义密码么?

看起来是连接失败不是密码错误

请问解决了吗?我这里也有同样的问题