167 lines
3.9 KiB
YAML
167 lines
3.9 KiB
YAML
|
---
|
||
|
|
||
|
# 创建 Namespace
|
||
|
apiVersion: v1
|
||
|
kind: Namespace
|
||
|
metadata:
|
||
|
name: hty1024-app
|
||
|
|
||
|
---
|
||
|
|
||
|
# 创建 StorageClass
|
||
|
apiVersion: storage.k8s.io/v1
|
||
|
kind: StorageClass
|
||
|
metadata:
|
||
|
name: storage-local-trilium
|
||
|
labels:
|
||
|
app.k8s.hty1024.com/env: prod
|
||
|
app.k8s.hty1024.com/type: app
|
||
|
app.k8s.hty1024.com/name: trilium
|
||
|
app.k8s.hty1024.com/version: 0.63.7
|
||
|
app.k8s.hty1024.com/resources: storageClass
|
||
|
provisioner: kubernetes.io/no-provisioner
|
||
|
reclaimPolicy: Retain
|
||
|
volumeBindingMode: WaitForFirstConsumer
|
||
|
|
||
|
---
|
||
|
|
||
|
# 创建 PersistentVolume
|
||
|
apiVersion: v1
|
||
|
kind: PersistentVolume
|
||
|
metadata:
|
||
|
name: hty1024-app-trilium-pv
|
||
|
labels:
|
||
|
app.k8s.hty1024.com/env: prod
|
||
|
app.k8s.hty1024.com/type: app
|
||
|
app.k8s.hty1024.com/name: trilium
|
||
|
app.k8s.hty1024.com/version: 0.63.7
|
||
|
app.k8s.hty1024.com/resources: persistentVolume
|
||
|
spec:
|
||
|
capacity:
|
||
|
storage: 10Gi
|
||
|
volumeMode: Filesystem
|
||
|
accessModes:
|
||
|
- ReadWriteOnce
|
||
|
persistentVolumeReclaimPolicy: Retain
|
||
|
storageClassName: storage-local-trilium
|
||
|
local:
|
||
|
path: /app/trilium/data
|
||
|
nodeAffinity:
|
||
|
required:
|
||
|
nodeSelectorTerms:
|
||
|
- matchExpressions:
|
||
|
- key: node.k8s.hty1024.com/type
|
||
|
operator: In
|
||
|
values:
|
||
|
- app
|
||
|
|
||
|
---
|
||
|
|
||
|
# 创建 PersistentVolumeClaim
|
||
|
apiVersion: v1
|
||
|
kind: PersistentVolumeClaim
|
||
|
metadata:
|
||
|
name: hty1024-app-trilium-pvc
|
||
|
namespace: hty1024-app
|
||
|
labels:
|
||
|
app.k8s.hty1024.com/env: prod
|
||
|
app.k8s.hty1024.com/type: app
|
||
|
app.k8s.hty1024.com/name: trilium
|
||
|
app.k8s.hty1024.com/version: 0.63.7
|
||
|
app.k8s.hty1024.com/resources: persistentVolumeClaim
|
||
|
spec:
|
||
|
resources:
|
||
|
requests:
|
||
|
storage: 10Gi
|
||
|
volumeMode: Filesystem
|
||
|
accessModes:
|
||
|
- ReadWriteOnce
|
||
|
storageClassName: storage-local-trilium
|
||
|
|
||
|
---
|
||
|
|
||
|
# 创建 Service
|
||
|
apiVersion: v1
|
||
|
kind: Service
|
||
|
metadata:
|
||
|
name: hty1024-app-trilium-service
|
||
|
namespace: hty1024-app
|
||
|
labels:
|
||
|
app.k8s.hty1024.com/env: prod
|
||
|
app.k8s.hty1024.com/type: app
|
||
|
app.k8s.hty1024.com/name: trilium
|
||
|
app.k8s.hty1024.com/version: 0.63.7
|
||
|
app.k8s.hty1024.com/resources: service
|
||
|
spec:
|
||
|
type: NodePort
|
||
|
ports:
|
||
|
- port: 8080
|
||
|
targetPort: 8080
|
||
|
nodePort: 30000
|
||
|
selector:
|
||
|
app.k8s.hty1024.com/env: prod
|
||
|
app.k8s.hty1024.com/type: app
|
||
|
app.k8s.hty1024.com/name: trilium
|
||
|
app.k8s.hty1024.com/version: 0.63.7
|
||
|
app.k8s.hty1024.com/resources: pod
|
||
|
|
||
|
---
|
||
|
|
||
|
# 创建 StatefulSet
|
||
|
apiVersion: apps/v1
|
||
|
kind: StatefulSet
|
||
|
metadata:
|
||
|
name: hty1024-app-trilium-statefulset
|
||
|
namespace: hty1024-app
|
||
|
labels:
|
||
|
app.k8s.hty1024.com/env: prod
|
||
|
app.k8s.hty1024.com/type: app
|
||
|
app.k8s.hty1024.com/name: trilium
|
||
|
app.k8s.hty1024.com/version: 0.63.7
|
||
|
app.k8s.hty1024.com/resources: statefulSet
|
||
|
spec:
|
||
|
replicas: 1
|
||
|
minReadySeconds: 30
|
||
|
selector:
|
||
|
matchLabels:
|
||
|
app.k8s.hty1024.com/env: prod
|
||
|
app.k8s.hty1024.com/type: app
|
||
|
app.k8s.hty1024.com/name: trilium
|
||
|
app.k8s.hty1024.com/version: 0.63.7
|
||
|
app.k8s.hty1024.com/resources: pod
|
||
|
template:
|
||
|
metadata:
|
||
|
labels:
|
||
|
app.k8s.hty1024.com/env: prod
|
||
|
app.k8s.hty1024.com/type: app
|
||
|
app.k8s.hty1024.com/name: trilium
|
||
|
app.k8s.hty1024.com/version: 0.63.7
|
||
|
app.k8s.hty1024.com/resources: pod
|
||
|
spec:
|
||
|
terminationGracePeriodSeconds: 60
|
||
|
volumes:
|
||
|
- name: localtime
|
||
|
hostPath:
|
||
|
path: /etc/localtime
|
||
|
- name: shanghai
|
||
|
hostPath:
|
||
|
path: /usr/share/zoneinfo/Asia/Shanghai
|
||
|
- name: hty1024-app-trilium-data
|
||
|
persistentVolumeClaim:
|
||
|
claimName: hty1024-app-trilium-pvc
|
||
|
containers:
|
||
|
- name: trilium
|
||
|
image: zadam/trilium:0.63.7
|
||
|
ports:
|
||
|
- name: tcp
|
||
|
containerPort: 8080
|
||
|
volumeMounts:
|
||
|
- name: shanghai
|
||
|
mountPath: /etc/localtime
|
||
|
readOnly: true
|
||
|
- name: hty1024-app-trilium-data
|
||
|
mountPath: /home/node/trilium-data
|
||
|
nodeSelector:
|
||
|
node.k8s.hty1024.com/type: app
|
||
|
|