free-fs

服务器规划

服务器 域名 备注
172.16.100.225

源码编译

源码链接

代码修改代码地址

https://gitee.com/soyuangit/free-fs/tree/master

k8s

free-fs.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app: free-fs
name: free-fs
spec:
serviceName: free-fs
replicas: 1
selector:
matchLabels:
app: free-fs
template:
metadata:
labels:
app: free-fs
spec:
nodeSelector:
type: free-fs
hostNetwork: true
containers:
# mysql
- name: mysql
image: mysql:5.7
volumeMounts:
- mountPath: /var/lib/mysql
name: mysql-volume
env:
- name: MYSQL_ROOT_PASSWORD
value: "soyuan.123"
# free-fs server
- name: server
image: java:8
volumeMounts:
- mountPath: /svc
name: fs-server-volume
command: ["/bin/sh","-c","cd /svc && java -Djava.security.egd=file:/dev/./urandom -Duser.timezone=GMT+08 -jar app.jar"]
# nginx
- name: nginx
image: nginx
volumeMounts:
- mountPath: /usr/share/nginx/html
name: fs-server-volume
- mountPath: /etc/nginx/conf.d
name: nginx-conf-volume
# 启动命令
command: ["/bin/sh","-c","chown -R nginx /usr/share/nginx/html/file && /usr/sbin/nginx -g 'daemon off;'"]
volumes:
- name: mysql-volume
hostPath:
# directory location on host
path: /free-fs-data/mysql
# this field is optional
type: Directory
- name: fs-server-volume
hostPath:
# directory location on host
path: /free-fs-data/server
# this field is optional
type: Directory
- name: nginx-conf-volume
hostPath:
# directory location on host
path: /free-fs-data/nginx/conf
# this field is optional
type: Directory

nginx 配置文件

default.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
server {
listen 8000;
server_name localhost;

#access_log /var/log/nginx/host.access.log main;

location / {
root /usr/share/nginx/html/file;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

node设置labels

kubectl label nodes 172.16.100.225 type=free-fs

重启statefulsets

kubectl rollout restart statefulsets free-fs

创建目录

1
2
3
4
5
6
7
# mysql 目录
$ mkdir -p /free-fs-data/mysql
$ chmod 777 /free-fs-data/mysql
# server 目录程序,jar包和配置文件,和文件缓存目录
$ mkdir -p /free-fs-data/server
# nginx 反向代理目录,配置文件
$ mkdir -p /free-fs-data/nginx/conf

free-fs
https://zhaops-hub.github.io/2022/03/02/k8s/free-fs/
作者
赵培胜
发布于
2022年3月2日
许可协议