317 lines
7.8 KiB
YAML
317 lines
7.8 KiB
YAML
# ---
|
||
#
|
||
# # 创建 Namespace
|
||
# apiVersion: v1
|
||
# kind: Namespace
|
||
# metadata:
|
||
# name: hty1024-app
|
||
#
|
||
---
|
||
|
||
# 创建 StorageClass
|
||
apiVersion: storage.k8s.io/v1
|
||
kind: StorageClass
|
||
metadata:
|
||
name: storage-local-seafile
|
||
labels:
|
||
app.k8s.hty1024.com/env: prod
|
||
app.k8s.hty1024.com/type: app
|
||
app.k8s.hty1024.com/name: seafile
|
||
app.k8s.hty1024.com/version: 11.0.9
|
||
app.k8s.hty1024.com/resources: storageClass
|
||
provisioner: kubernetes.io/no-provisioner
|
||
reclaimPolicy: Retain
|
||
volumeBindingMode: WaitForFirstConsumer
|
||
|
||
---
|
||
|
||
# 创建 PersistentVolume
|
||
## mariadb
|
||
apiVersion: v1
|
||
kind: PersistentVolume
|
||
metadata:
|
||
name: hty1024-app-seafile-pv-mariadb
|
||
labels:
|
||
app.k8s.hty1024.com/env: prod
|
||
app.k8s.hty1024.com/type: app
|
||
app.k8s.hty1024.com/name: seafile
|
||
app.k8s.hty1024.com/version: 11.0.9
|
||
app.k8s.hty1024.com/resources: persistentVolume
|
||
spec:
|
||
capacity:
|
||
storage: 10Gi
|
||
volumeMode: Filesystem
|
||
accessModes:
|
||
- ReadWriteOnce
|
||
persistentVolumeReclaimPolicy: Retain
|
||
storageClassName: storage-local-seafile
|
||
local:
|
||
path: /app/seafile/mariadb
|
||
nodeAffinity:
|
||
required:
|
||
nodeSelectorTerms:
|
||
- matchExpressions:
|
||
- key: node.k8s.hty1024.com/type
|
||
operator: In
|
||
values:
|
||
- app
|
||
|
||
---
|
||
|
||
## seafile
|
||
apiVersion: v1
|
||
kind: PersistentVolume
|
||
metadata:
|
||
name: hty1024-app-seafile-pv-data
|
||
labels:
|
||
app.k8s.hty1024.com/env: prod
|
||
app.k8s.hty1024.com/type: app
|
||
app.k8s.hty1024.com/name: seafile
|
||
app.k8s.hty1024.com/version: 11.0.9
|
||
app.k8s.hty1024.com/resources: persistentVolume
|
||
spec:
|
||
capacity:
|
||
storage: 100Gi
|
||
volumeMode: Filesystem
|
||
accessModes:
|
||
- ReadWriteOnce
|
||
persistentVolumeReclaimPolicy: Retain
|
||
storageClassName: storage-local-seafile
|
||
local:
|
||
path: /app/seafile/data
|
||
nodeAffinity:
|
||
required:
|
||
nodeSelectorTerms:
|
||
- matchExpressions:
|
||
- key: node.k8s.hty1024.com/type
|
||
operator: In
|
||
values:
|
||
- app
|
||
|
||
---
|
||
|
||
# 创建 PersistentVolumeClaim
|
||
## mariadb
|
||
apiVersion: v1
|
||
kind: PersistentVolumeClaim
|
||
metadata:
|
||
name: hty1024-app-seafile-pvc-mariadb
|
||
namespace: hty1024-app
|
||
labels:
|
||
app.k8s.hty1024.com/env: prod
|
||
app.k8s.hty1024.com/type: app
|
||
app.k8s.hty1024.com/name: seafile
|
||
app.k8s.hty1024.com/version: 11.0.9
|
||
app.k8s.hty1024.com/resources: persistentVolumeClaim
|
||
spec:
|
||
resources:
|
||
requests:
|
||
storage: 10Gi
|
||
volumeMode: Filesystem
|
||
accessModes:
|
||
- ReadWriteOnce
|
||
storageClassName: storage-local-seafile
|
||
|
||
---
|
||
|
||
## seafile
|
||
apiVersion: v1
|
||
kind: PersistentVolumeClaim
|
||
metadata:
|
||
name: hty1024-app-seafile-pvc-data
|
||
namespace: hty1024-app
|
||
labels:
|
||
app.k8s.hty1024.com/env: prod
|
||
app.k8s.hty1024.com/type: app
|
||
app.k8s.hty1024.com/name: seafile
|
||
app.k8s.hty1024.com/version: 11.0.9
|
||
app.k8s.hty1024.com/resources: persistentVolumeClaim
|
||
spec:
|
||
resources:
|
||
requests:
|
||
storage: 100Gi
|
||
volumeMode: Filesystem
|
||
accessModes:
|
||
- ReadWriteOnce
|
||
storageClassName: storage-local-seafile
|
||
|
||
---
|
||
|
||
# 创建 ConfigMap(自定义 mariadb 的 my.cnf 文件)
|
||
apiVersion: v1
|
||
kind: ConfigMap
|
||
metadata:
|
||
name: hty1024-app-seafile-cm
|
||
namespace: hty1024-app
|
||
labels:
|
||
app.k8s.hty1024.com/env: prod
|
||
app.k8s.hty1024.com/type: app
|
||
app.k8s.hty1024.com/name: seafile
|
||
app.k8s.hty1024.com/version: 11.0.9
|
||
app.k8s.hty1024.com/resources: configMap
|
||
data:
|
||
my.cnf: |
|
||
[mysqld]
|
||
max_connections = 1000
|
||
character-set-server = utf8mb4
|
||
collation-server = utf8mb4_unicode_ci
|
||
|
||
---
|
||
|
||
# 创建 Secret(自定义 MariaDB 用户密码)
|
||
apiVersion: v1
|
||
kind: Secret
|
||
metadata:
|
||
name: hty1024-app-seafile-secret
|
||
namespace: hty1024-app
|
||
labels:
|
||
app.k8s.hty1024.com/env: prod
|
||
app.k8s.hty1024.com/type: app
|
||
app.k8s.hty1024.com/name: seafile
|
||
app.k8s.hty1024.com/version: 11.0.9
|
||
app.k8s.hty1024.com/resources: secret
|
||
type: Opaque
|
||
stringData:
|
||
root.key: |
|
||
123456
|
||
immutable: true
|
||
|
||
---
|
||
|
||
# 创建 Service
|
||
apiVersion: v1
|
||
kind: Service
|
||
metadata:
|
||
name: hty1024-app-seafile-service
|
||
namespace: hty1024-app
|
||
labels:
|
||
app.k8s.hty1024.com/env: prod
|
||
app.k8s.hty1024.com/type: app
|
||
app.k8s.hty1024.com/name: seafile
|
||
app.k8s.hty1024.com/version: 11.0.9
|
||
app.k8s.hty1024.com/resources: service
|
||
spec:
|
||
type: NodePort
|
||
ports:
|
||
- port: 80
|
||
targetPort: 80
|
||
nodePort: 30000
|
||
selector:
|
||
app.k8s.hty1024.com/env: prod
|
||
app.k8s.hty1024.com/type: app
|
||
app.k8s.hty1024.com/name: seafile
|
||
app.k8s.hty1024.com/version: 11.0.9
|
||
app.k8s.hty1024.com/resources: pod
|
||
|
||
---
|
||
|
||
# 创建 StatefulSet
|
||
apiVersion: apps/v1
|
||
kind: StatefulSet
|
||
metadata:
|
||
name: hty1024-app-seafile-statefulset
|
||
namespace: hty1024-app
|
||
labels:
|
||
app.k8s.hty1024.com/env: prod
|
||
app.k8s.hty1024.com/type: app
|
||
app.k8s.hty1024.com/name: seafile
|
||
app.k8s.hty1024.com/version: 11.0.9
|
||
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: seafile
|
||
app.k8s.hty1024.com/version: 11.0.9
|
||
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: seafile
|
||
app.k8s.hty1024.com/version: 11.0.9
|
||
app.k8s.hty1024.com/resources: pod
|
||
spec:
|
||
terminationGracePeriodSeconds: 60
|
||
volumes:
|
||
- name: localtime
|
||
hostPath:
|
||
path: /etc/localtime
|
||
- name: hty1024-app-seafile-mariadb
|
||
persistentVolumeClaim:
|
||
claimName: hty1024-app-seafile-pvc-mariadb
|
||
- name: hty1024-app-seafile-conf
|
||
configMap:
|
||
name: hty1024-app-seafile-cm
|
||
items:
|
||
- key: my.cnf
|
||
path: my.cnf
|
||
- name: hty1024-app-seafile-pwd
|
||
secret:
|
||
secretName: hty1024-app-seafile-secret
|
||
- name: hty1024-app-seafile-data
|
||
persistentVolumeClaim:
|
||
claimName: hty1024-app-seafile-pvc-data
|
||
containers:
|
||
- name: mariadb
|
||
image: mariadb:10.11.9
|
||
ports:
|
||
- name: tcp
|
||
containerPort: 3306
|
||
volumeMounts:
|
||
- name: localtime
|
||
mountPath: /etc/localtime
|
||
readOnly: true
|
||
- name: hty1024-app-seafile-mariadb
|
||
mountPath: /var/lib/mysql
|
||
- name: hty1024-app-seafile-conf
|
||
mountPath: /etc/mysql/conf.d/
|
||
- name: hty1024-app-seafile-pwd
|
||
mountPath: /tmp/secret-volume
|
||
readOnly: true
|
||
env:
|
||
- name: MYSQL_ROOT_PASSWORD_FILE
|
||
value: "/tmp/secret-volume/root.key"
|
||
- name: memcached
|
||
image: memcached:1.6.32-alpine3.20
|
||
ports:
|
||
- name: tcp
|
||
containerPort: 11211
|
||
volumeMounts:
|
||
- name: localtime
|
||
mountPath: /etc/localtime
|
||
readOnly: true
|
||
- name: seafile
|
||
image: seafileltd/seafile-mc:11.0.9
|
||
ports:
|
||
- name: tcp
|
||
containerPort: 80
|
||
volumeMounts:
|
||
- name: localtime
|
||
mountPath: /etc/localtime
|
||
readOnly: true
|
||
- name: hty1024-app-seafile-data
|
||
mountPath: /shared
|
||
env:
|
||
- name: TIME_ZONE
|
||
value: Asia/Shanghai
|
||
- name: DB_HOST
|
||
value: "127.0.0.1"
|
||
- name: DB_ROOT_PASSWD
|
||
value: "123456"
|
||
- name: SEAFILE_ADMIN_EMAIL
|
||
value: "test@hty1024.com"
|
||
- name: SEAFILE_ADMIN_PASSWORD
|
||
value: "123456"
|
||
- name: SEAFILE_SERVER_LETSENCRYPT
|
||
value: "false"
|
||
- name: SEAFILE_SERVER_HOSTNAME
|
||
value: "test.hty1024.com"
|
||
nodeSelector:
|
||
node.k8s.hty1024.com/type: app
|
||
|