Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix storing log file in persistence volume #19

Merged
merged 3 commits into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variables:
VERSION: 0.0.22
VERSION: 0.0.24
REPO: docker.io

stages:
Expand Down
1 change: 0 additions & 1 deletion README.En.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ docsify serve .
- [GORM](https://gorm.io/) - Familiar with GORM apis
- [Casbin](https://casbin.org/) - Familiar with Casbin apis
- [Go-swagger](https://goswagger.io/) - Go-swagger document generation
- [Consul](https://www.consul.io/docs) - Consul

## Install and use

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ docsify serve .
- [GORM](https://gorm.io/) - GORM 数据库ORM组件
- [Casbin](https://casbin.org/) - 权限管理
- [Go-swagger](https://goswagger.io/) - Go-swagger 文档生成调试
- [Consul](https://www.consul.io/docs) - Consul

## 安装使用

Expand Down
2 changes: 1 addition & 1 deletion api/etc/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Auth:
Log:
ServiceName: coreApiLogger
Mode: file
Path: /home/ryan/logs/core/api
Path: /home/data/logs/core/api
Level: info
Compress: false
KeepDays: 7
Expand Down
11 changes: 8 additions & 3 deletions deploy/k8s/core-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
serviceAccountName: endpoints-finder
containers:
- name: core-api
image: ryanpower/core-api:0.0.22
image: ryanpower/core-api:0.0.24
ports:
- containerPort: 9100
readinessProbe:
Expand All @@ -39,12 +39,17 @@ spec:
cpu: 1000m
memory: 1024Mi
volumeMounts:
- name: timezone
mountPath: /etc/localtime
- name: timezone
mountPath: /etc/localtime
- mountPath: /home/data
name: simple-admin-pv
volumes:
- name: timezone
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai
- name: simple-admin-pv
persistentVolumeClaim:
claimName: simple-admin-pv-claim

---

Expand Down
11 changes: 8 additions & 3 deletions deploy/k8s/core-rpc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
serviceAccountName: endpoints-finder
containers:
- name: core-rpc
image: ryanpower/core-rpc:0.0.22
image: ryanpower/core-rpc:0.0.24
ports:
- containerPort: 9101
readinessProbe:
Expand All @@ -39,12 +39,17 @@ spec:
cpu: 1000m
memory: 1024Mi
volumeMounts:
- name: timezone
mountPath: /etc/localtime
- name: timezone
mountPath: /etc/localtime
- mountPath: /home/data
name: simple-admin-pv
volumes:
- name: timezone
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai
- name: simple-admin-pv
persistentVolumeClaim:
claimName: simple-admin-pv-claim

---

Expand Down
29 changes: 29 additions & 0 deletions deploy/k8s/pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: simple-admin-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
hostPath:
path: "/home/data"

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: simple-admin-pv-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteMany
resources:
requests:
storage: 3Gi

5 changes: 3 additions & 2 deletions deploy/k8s/setup-ingress.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
alias kubectl="minikube kubectl --"

# 注册 core-api
# register core-api into ingress tcp config map
kubectl patch configmap tcp-services -n ingress-nginx --patch '{"data":{"9100":"simple-admin/core-api-svc:9100"}}'

# 注册 backend-ui, 8080 端口映射到backend-ui的80端口
# register backend-ui, port 8080 is mapped to port 80 of backend-ui
kubectl patch configmap tcp-services -n ingress-nginx --patch '{"data":{"8080":"simple-admin/backend-ui-svc:80"}}'

# register service into ingress controller
kubectl patch deployment ingress-nginx-controller --patch "$(cat ingress-patch.yaml)" -n ingress-nginx
7 changes: 7 additions & 0 deletions deploy/k8s/setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
alias kubectl="minikube kubectl --"

# create service account
kubectl apply -f auth.yaml

# create persistent volume for log
kubectl apply -f pv.yaml

# create core rpc
kubectl apply -f core-rpc.yaml

# create core api
kubectl apply -f core-api.yaml

# create backend ui
kubectl apply -f backend-ui.yaml
15 changes: 10 additions & 5 deletions docs/simple-admin/en/docs/k8s-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ clean-job:
### coreapi k8s deployment file tutorial

> core api the name of service, you can find in label and metadata:name \
> Namespace is simple-admin by default, you can change your own namespace
> Namespace is default, you can change your own namespace

```yaml
apiVersion: apps/v1
Expand Down Expand Up @@ -221,12 +221,17 @@ spec:
cpu: 1000m # the maximum cpu requirement, 1000m is one cpu, set lower in development env
memory: 1024Mi # the maximum memory usage
volumeMounts:
- name: timezone
mountPath: /etc/localtime
- name: timezone
mountPath: /etc/localtime
- mountPath: /home/data
name: simple-admin-pv
volumes:
- name: timezone
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai # set time zone
path: /usr/share/zoneinfo/Asia/Shanghai
- name: simple-admin-pv # log persistence volume
persistentVolumeClaim:
claimName: simple-admin-pv-claim

---

Expand Down Expand Up @@ -264,7 +269,7 @@ spec:


---
# 服务监控
# Service Monitor
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
Expand Down
15 changes: 10 additions & 5 deletions docs/simple-admin/zh-cn/docs/k8s-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ clean-job:
### coreapi 部署文件详解

> coreapi 是所有服务的label和metadata:name \
> 命名空间默认是 simple-admin, 可自行修改
> 命名空间默认是 default, 可自行修改

```yaml
apiVersion: apps/v1
Expand Down Expand Up @@ -219,13 +219,18 @@ spec:
limits:
cpu: 1000m # 最高占用 cpu
memory: 1024Mi # 最高占用的内存
volumeMounts:
- name: timezone
mountPath: /etc/localtime
volumeMounts:
- name: timezone
mountPath: /etc/localtime
- mountPath: /home/data
name: simple-admin-pv
volumes:
- name: timezone
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai # 设置时区
path: /usr/share/zoneinfo/Asia/Shanghai
- name: simple-admin-pv # log 持久化卷
persistentVolumeClaim:
claimName: simple-admin-pv-claim

---

Expand Down
4 changes: 2 additions & 2 deletions rpc/etc/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ListenOn: 0.0.0.0:9101

DatabaseConf:
Type: mysql
Path: "127.0.0.1"
Path: "192.168.50.216"
Port: 3306
Config: charset=utf8mb4&parseTime=True&loc=Local
DBName: simple_admin
Expand All @@ -17,7 +17,7 @@ DatabaseConf:
Log:
ServiceName: coreRpcLogger
Mode: file
Path: /home/ryan/logs/core/rpc
Path: /home/data/logs/core/rpc
Encoding: json
Level: info
Compress: false
Expand Down