This commit is contained in:
80
资源部署/K8s部署Twikoo实现博客评论功能.md
Normal file
80
资源部署/K8s部署Twikoo实现博客评论功能.md
Normal file
@@ -0,0 +1,80 @@
|
||||
> 本文作者:丁辉
|
||||
|
||||
# K8s部署Twikoo实现博客评论功能
|
||||
|
||||
[官方文档](https://twikoo.js.org/intro.html)
|
||||
|
||||
## 搭建
|
||||
|
||||
```yaml
|
||||
cat <<EOF | kubectl apply -f -
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: twikoo
|
||||
spec:
|
||||
# - OrderedReady: 按顺序创建/删除Pod(默认)
|
||||
podManagementPolicy: OrderedReady
|
||||
# 副本数:只运行1个Pod实例
|
||||
replicas: 1
|
||||
# 历史版本保留数量:3
|
||||
revisionHistoryLimit: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: twikoo
|
||||
# 关联的Service名称,用于网络标识
|
||||
serviceName: twikoo
|
||||
# Pod就绪后等待时间(秒),确保稳定后才视为可用
|
||||
minReadySeconds: 5
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: twikoo
|
||||
spec:
|
||||
# 优雅终止等待时间:Pod停止前等待5秒完成清理
|
||||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: twikoo
|
||||
image: imaegoo/twikoo:latest
|
||||
env:
|
||||
- name: TWIKOO_THROTTLE
|
||||
value: "1000" # 环境变量:限流阈值
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
protocol: TCP
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 128Mi
|
||||
limits:
|
||||
cpu: 200m
|
||||
memory: 256Mi
|
||||
livenessProbe:
|
||||
failureThreshold: 3 # 连续失败3次后重启容器
|
||||
initialDelaySeconds: 5 # 容器启动后5秒开始检查
|
||||
periodSeconds: 3 # 每3秒检查一次
|
||||
successThreshold: 1 # 成功1次即视为健康
|
||||
tcpSocket:
|
||||
port: 8080
|
||||
timeoutSeconds: 20 # 检查超时时间
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /app/data
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce # 单节点读写
|
||||
storageClassName: nfs-client # 指定StorageClass
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi # 请求1GB存储
|
||||
EOF
|
||||
```
|
||||
|
||||
## 头像配置
|
||||
|
||||
- [Cravatar](https://cn.cravatar.com/)
|
||||
- [Weavatar](https://weavatar.com/)
|
||||
|
||||
Reference in New Issue
Block a user