在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