112 lines
2.4 KiB
YAML
112 lines
2.4 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: blog
|
|
namespace: apps
|
|
labels:
|
|
app: blog
|
|
spec:
|
|
replicas: 1
|
|
revisionHistoryLimit: 3
|
|
selector:
|
|
matchLabels:
|
|
app: blog
|
|
# 博客用 RWO 卷,滚动更新会出现新旧 pod 抢同一个卷而卡住,所以用 Recreate
|
|
strategy:
|
|
type: Recreate
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: blog
|
|
spec:
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 10001
|
|
fsGroup: 10001
|
|
containers:
|
|
- name: blog
|
|
image: harbor.nineleaves.cn/apps/blog:BUILD_TAG
|
|
imagePullPolicy: Always
|
|
ports:
|
|
- containerPort: 5000
|
|
env:
|
|
- name: SITE_TITLE
|
|
value: "我的博客"
|
|
- name: DATA_DIR
|
|
value: /data
|
|
- name: ADMIN_TOKEN
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: blog-secret
|
|
key: admin-token
|
|
resources:
|
|
requests:
|
|
cpu: 20m
|
|
memory: 64Mi
|
|
limits:
|
|
memory: 256Mi
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /healthz
|
|
port: 5000
|
|
initialDelaySeconds: 3
|
|
periodSeconds: 5
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /healthz
|
|
port: 5000
|
|
initialDelaySeconds: 15
|
|
periodSeconds: 20
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: /data
|
|
volumes:
|
|
- name: data
|
|
persistentVolumeClaim:
|
|
claimName: blog-data
|
|
---
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: blog-data
|
|
namespace: apps
|
|
spec:
|
|
accessModes: ["ReadWriteOnce"]
|
|
storageClassName: longhorn
|
|
resources:
|
|
requests:
|
|
storage: 1Gi
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: blog
|
|
namespace: apps
|
|
spec:
|
|
selector:
|
|
app: blog
|
|
ports:
|
|
- port: 80
|
|
targetPort: 5000
|
|
---
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: Ingress
|
|
metadata:
|
|
name: blog
|
|
namespace: apps
|
|
annotations:
|
|
nginx.ingress.kubernetes.io/proxy-body-size: "10m"
|
|
spec:
|
|
ingressClassName: nginx
|
|
rules:
|
|
- host: blog.nineleaves.cn
|
|
http:
|
|
paths:
|
|
- path: /
|
|
pathType: Prefix
|
|
backend:
|
|
service:
|
|
name: blog
|
|
port:
|
|
number: 80
|