---
# 创建 Namespace
apiVersion: v1
kind: Namespace
metadata:
name: hty1024-db
---
# 创建 StorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: storage-local-mysql
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: mysql
app.k8s.hty1024.com/version: 8.0.35
app.k8s.hty1024.com/resources: storageClass
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
---
# 创建 PersistentVolume
apiVersion: v1
kind: PersistentVolume
metadata:
name: hty1024-db-mysql-pv
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: mysql
app.k8s.hty1024.com/version: 8.0.35
app.k8s.hty1024.com/resources: persistentVolume
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: storage-local-mysql
local:
path: /app/mysql/data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: node.k8s.hty1024.com/type
operator: In
values:
- app
---
# 创建 PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hty1024-db-mysql-pvc
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: mysql
app.k8s.hty1024.com/version: 8.0.35
app.k8s.hty1024.com/resources: persistentVolumeClaim
spec:
resources:
requests:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
storageClassName: storage-local-mysql
---
# 创建 ConfigMap(自定义 my.cnf 文件)
apiVersion: v1
kind: ConfigMap
metadata:
name: hty1024-db-mysql-cm
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: mysql
app.k8s.hty1024.com/version: 8.0.35
app.k8s.hty1024.com/resources: configMap
data:
my.cnf: |
[mysqld]
max_connections = 1000
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
---
# 创建 Secret(自定义 MySQL 用户密码)
apiVersion: v1
kind: Secret
metadata:
name: hty1024-db-mysql-secret
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: mysql
app.k8s.hty1024.com/version: 8.0.35
app.k8s.hty1024.com/resources: secret
type: Opaque
stringData:
root.key: |
123456
immutable: true
---
# 创建 Service
apiVersion: v1
kind: Service
metadata:
name: hty1024-db-mysql-service
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: mysql
app.k8s.hty1024.com/version: 8.0.35
app.k8s.hty1024.com/resources: service
spec:
type: ClusterIP
ports:
- port: 3306
targetPort: 3306
selector:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: mysql
app.k8s.hty1024.com/version: 8.0.35
app.k8s.hty1024.com/resources: pod
---
# 创建 StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: hty1024-db-mysql-statefulset
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: mysql
app.k8s.hty1024.com/version: 8.0.35
app.k8s.hty1024.com/resources: statefulSet
spec:
replicas: 1
minReadySeconds: 30
selector:
matchLabels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: mysql
app.k8s.hty1024.com/version: 8.0.35
app.k8s.hty1024.com/resources: pod
template:
metadata:
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: mysql
app.k8s.hty1024.com/version: 8.0.35
app.k8s.hty1024.com/resources: pod
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: localtime
hostPath:
path: /etc/localtime
- name: hty1024-db-mysql-data
persistentVolumeClaim:
claimName: hty1024-db-mysql-pvc
- name: hty1024-db-mysql-conf
configMap:
name: hty1024-db-mysql-cm
items:
- key: my.cnf
path: my.cnf
- name: hty1024-db-mysql-pwd
secret:
secretName: hty1024-db-mysql-secret
containers:
- name: mysql
image: mysql:8.0.35
ports:
- name: tcp
containerPort: 3306
volumeMounts:
- name: localtime
mountPath: /etc/localtime
readOnly: true
- name: hty1024-db-mysql-data
mountPath: /var/lib/mysql
- name: hty1024-db-mysql-conf
mountPath: /etc/mysql/conf.d/
- name: hty1024-db-mysql-pwd
mountPath: /tmp/secret-volume
readOnly: true
env:
- name: MYSQL_ROOT_PASSWORD_FILE
value: "/tmp/secret-volume/root.key"
nodeSelector:
node.k8s.hty1024.com/type: app
---
# 创建 Namespace
apiVersion: v1
kind: Namespace
metadata:
name: hty1024-db
---
# 创建 Service
apiVersion: v1
kind: Service
metadata:
name: hty1024-db-phpmyadmin-service
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: phpmyadmin
app.k8s.hty1024.com/version: 5.2.1
app.k8s.hty1024.com/resources: service
spec:
type: NodePort
ports:
- name: phpmyadmin
port: 80
targetPort: 80
nodePort: 30000
selector:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: phpmyadmin
app.k8s.hty1024.com/version: 5.2.1
app.k8s.hty1024.com/resources: pod
---
# 创建 Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: hty1024-db-phpmyadmin
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: phpmyadmin
app.k8s.hty1024.com/version: 5.2.1
app.k8s.hty1024.com/resources: deployment
spec:
replicas: 1
minReadySeconds: 30
selector:
matchLabels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: phpmyadmin
app.k8s.hty1024.com/version: 5.2.1
app.k8s.hty1024.com/resources: pod
template:
metadata:
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: phpmyadmin
app.k8s.hty1024.com/version: 5.2.1
app.k8s.hty1024.com/resources: pod
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: localtime
hostPath:
path: /etc/localtime
containers:
- name: phpmyadmin
image: phpmyadmin:5.2.1
ports:
- name: http
containerPort: 80
volumeMounts:
- name: localtime
mountPath: /etc/localtime
readOnly: true
env:
- name: PMA_ARBITRARY
value: "1"
nodeSelector:
node.k8s.hty1024.com/type: app
---
# 创建 Namespace
apiVersion: v1
kind: Namespace
metadata:
name: hty1024-db
---
# 创建 StorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: storage-local-postgres
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: postgres
app.k8s.hty1024.com/version: 16.1-alpine3.19
app.k8s.hty1024.com/resources: storageClass
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
---
# 创建 PersistentVolume
apiVersion: v1
kind: PersistentVolume
metadata:
name: hty1024-db-postgres-pv
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: postgres
app.k8s.hty1024.com/version: 16.1-alpine3.19
app.k8s.hty1024.com/resources: persistentVolume
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: storage-local-postgres
local:
path: /app/postgres/data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: node.k8s.hty1024.com/type
operator: In
values:
- app
---
# 创建 PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hty1024-db-postgres-pvc
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: postgres
app.k8s.hty1024.com/version: 16.1-alpine3.19
app.k8s.hty1024.com/resources: persistentVolumeClaim
spec:
resources:
requests:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
storageClassName: storage-local-postgres
---
# 创建 Secret(自定义 PostgreSQL 用户密码)
apiVersion: v1
kind: Secret
metadata:
name: hty1024-db-postgres-secret
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: postgres
app.k8s.hty1024.com/version: 16.1-alpine3.19
app.k8s.hty1024.com/resources: secret
type: Opaque
stringData:
postgres.key: |
123456
immutable: true
---
# 创建 Service
apiVersion: v1
kind: Service
metadata:
name: hty1024-db-postgres-service
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: postgres
app.k8s.hty1024.com/version: 16.1-alpine3.19
app.k8s.hty1024.com/resources: service
spec:
type: ClusterIP
ports:
- port: 5432
targetPort: 5432
selector:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: postgres
app.k8s.hty1024.com/version: 16.1-alpine3.19
app.k8s.hty1024.com/resources: pod
---
# 创建 StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: hty1024-db-postgres-statefulset
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: postgres
app.k8s.hty1024.com/version: 16.1-alpine3.19
app.k8s.hty1024.com/resources: statefulSet
spec:
replicas: 1
minReadySeconds: 30
selector:
matchLabels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: postgres
app.k8s.hty1024.com/version: 16.1-alpine3.19
app.k8s.hty1024.com/resources: pod
template:
metadata:
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: postgres
app.k8s.hty1024.com/version: 16.1-alpine3.19
app.k8s.hty1024.com/resources: pod
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: localtime
hostPath:
path: /etc/localtime
- name: hty1024-db-postgres-data
persistentVolumeClaim:
claimName: hty1024-db-postgres-pvc
- name: hty1024-db-postgres-pwd
secret:
secretName: hty1024-db-postgres-secret
containers:
- name: postgres
image: postgres:16.1-alpine3.19
ports:
- name: tcp
containerPort: 5432
volumeMounts:
- name: localtime
mountPath: /etc/localtime
readOnly: true
- name: hty1024-db-postgres-data
mountPath: /var/lib/postgres
- name: hty1024-db-postgres-pwd
mountPath: /tmp/secret-volume
readOnly: true
env:
- name: POSTGRES_PASSWORD_FILE
value: "/tmp/secret-volume/postgres.key"
nodeSelector:
node.k8s.hty1024.com/type: app
---
# 创建 Namespace
apiVersion: v1
kind: Namespace
metadata:
name: hty1024-db
---
# 创建 Service
apiVersion: v1
kind: Service
metadata:
name: hty1024-db-pgadmin4-service
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: pgadmin4
app.k8s.hty1024.com/version: 8.0.0
app.k8s.hty1024.com/resources: service
spec:
type: NodePort
ports:
- name: pgadmin4
port: 80
targetPort: 80
nodePort: 30001
selector:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: pgadmin4
app.k8s.hty1024.com/version: 8.0.0
app.k8s.hty1024.com/resources: pod
---
# 创建 Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: hty1024-db-pgadmin4
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: pgadmin4
app.k8s.hty1024.com/version: 8.0.0
app.k8s.hty1024.com/resources: deployment
spec:
replicas: 1
minReadySeconds: 30
selector:
matchLabels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: pgadmin4
app.k8s.hty1024.com/version: 8.0.0
app.k8s.hty1024.com/resources: pod
template:
metadata:
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: pgadmin4
app.k8s.hty1024.com/version: 8.0.0
app.k8s.hty1024.com/resources: pod
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: localtime
hostPath:
path: /etc/localtime
containers:
- name: pgadmin4
image: dpage/pgadmin4:8.0
ports:
- name: http
containerPort: 80
volumeMounts:
- name: localtime
mountPath: /etc/localtime
readOnly: true
env:
- name: PGADMIN_DEFAULT_EMAIL
value: "test@hty1024.com"
- name: PGADMIN_DEFAULT_PASSWORD
value: "123456"
nodeSelector:
node.k8s.hty1024.com/type: app
---
# 创建 Namespace
apiVersion: v1
kind: Namespace
metadata:
name: hty1024-db
---
# 创建 StorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: storage-local-redis
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: redis
app.k8s.hty1024.com/version: 6.0.20-alpine3.19
app.k8s.hty1024.com/resources: storageClass
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
---
# 创建 PersistentVolume
apiVersion: v1
kind: PersistentVolume
metadata:
name: hty1024-db-redis-pv
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: redis
app.k8s.hty1024.com/version: 6.0.20-alpine3.19
app.k8s.hty1024.com/resources: persistentVolume
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: storage-local-redis
local:
path: /app/redis/data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: node.k8s.hty1024.com/type
operator: In
values:
- app
---
# 创建 PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hty1024-db-redis-pvc
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: redis
app.k8s.hty1024.com/version: 6.0.20-alpine3.19
app.k8s.hty1024.com/resources: persistentVolumeClaim
spec:
resources:
requests:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
storageClassName: storage-local-redis
---
# 创建 Service
apiVersion: v1
kind: Service
metadata:
name: hty1024-db-redis-service
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: redis
app.k8s.hty1024.com/version: 6.0.20-alpine3.19
app.k8s.hty1024.com/resources: service
spec:
type: ClusterIP
ports:
- port: 6379
targetPort: 6379
selector:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: redis
app.k8s.hty1024.com/version: 6.0.20-alpine3.19
app.k8s.hty1024.com/resources: pod
---
# 创建 StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: hty1024-db-redis-statefulset
namespace: hty1024-db
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: redis
app.k8s.hty1024.com/version: 6.0.20-alpine3.19
app.k8s.hty1024.com/resources: statefulSet
spec:
replicas: 1
minReadySeconds: 30
selector:
matchLabels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: redis
app.k8s.hty1024.com/version: 6.0.20-alpine3.19
app.k8s.hty1024.com/resources: pod
template:
metadata:
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: db
app.k8s.hty1024.com/name: redis
app.k8s.hty1024.com/version: 6.0.20-alpine3.19
app.k8s.hty1024.com/resources: pod
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: localtime
hostPath:
path: /etc/localtime
- name: hty1024-db-redis-data
persistentVolumeClaim:
claimName: hty1024-db-redis-pvc
containers:
- name: redis
image: redis:6.0.20-alpine3.19
ports:
- name: tcp
containerPort: 6379
volumeMounts:
- name: localtime
mountPath: /etc/localtime
readOnly: true
- name: hty1024-db-redis-data
mountPath: /data
nodeSelector:
node.k8s.hty1024.com/type: app
---
# 创建 Namespace
apiVersion: v1
kind: Namespace
metadata:
name: hty1024-app
---
# 创建 StorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: storage-local-halo
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: halo
app.k8s.hty1024.com/version: 1.6.1
app.k8s.hty1024.com/resources: storageClass
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
---
# 创建 PersistentVolume
apiVersion: v1
kind: PersistentVolume
metadata:
name: hty1024-app-halo-pv
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: halo
app.k8s.hty1024.com/version: 1.6.1
app.k8s.hty1024.com/resources: persistentVolume
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: storage-local-halo
local:
path: /app/halo/data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: node.k8s.hty1024.com/type
operator: In
values:
- app
---
# 创建 PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hty1024-app-halo-pvc
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: halo
app.k8s.hty1024.com/version: 1.6.1
app.k8s.hty1024.com/resources: persistentVolumeClaim
spec:
resources:
requests:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
storageClassName: storage-local-halo
---
# 创建 Service
apiVersion: v1
kind: Service
metadata:
name: hty1024-app-halo-service
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: halo
app.k8s.hty1024.com/version: 1.6.1
app.k8s.hty1024.com/resources: service
spec:
type: NodePort
ports:
- port: 8090
targetPort: 8090
nodePort: 30003
selector:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: halo
app.k8s.hty1024.com/version: 1.6.1
app.k8s.hty1024.com/resources: pod
---
# 创建 StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: hty1024-app-halo-statefulset
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: halo
app.k8s.hty1024.com/version: 1.6.1
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: halo
app.k8s.hty1024.com/version: 1.6.1
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: halo
app.k8s.hty1024.com/version: 1.6.1
app.k8s.hty1024.com/resources: pod
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: localtime
hostPath:
path: /etc/localtime
- name: hty1024-app-halo-data
persistentVolumeClaim:
claimName: hty1024-app-halo-pvc
containers:
- name: halo
image: halohub/halo:1.6.1
ports:
- name: tcp
containerPort: 8090
volumeMounts:
- name: localtime
mountPath: /etc/localtime
readOnly: true
- name: hty1024-app-halo-data
mountPath: /root/.halo
env:
- name: SERVER_PORT
value: "8090"
- name: SPRING_DATASOURCE_DRIVER_CLASS_NAME
value: "com.mysql.cj.jdbc.Driver"
- name: SPRING_DATASOURCE_URL
value: "jdbc:mysql://hty1024-db-mysql-service.hty1024-db:3306/halo?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true"
- name: SPRING_DATASOURCE_USERNAME
value: "halo"
- name: SPRING_DATASOURCE_PASSWORD
value: "123456"
- name: HALO_ADMIN_PATH
value: "admin"
- name: HALO_CACHE
value: "memory"
nodeSelector:
node.k8s.hty1024.com/type: app
---
# 创建 Namespace
apiVersion: v1
kind: Namespace
metadata:
name: hty1024-app
---
# 创建 StorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: storage-local-wikijs
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: wikijs
app.k8s.hty1024.com/version: 2.5.300
app.k8s.hty1024.com/resources: storageClass
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
---
# 创建 PersistentVolume
apiVersion: v1
kind: PersistentVolume
metadata:
name: hty1024-app-wikijs-pv
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: wikijs
app.k8s.hty1024.com/version: 2.5.300
app.k8s.hty1024.com/resources: persistentVolume
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: storage-local-wikijs
local:
path: /app/wikijs/data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: node.k8s.hty1024.com/type
operator: In
values:
- app
---
# 创建 PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hty1024-app-wikijs-pvc
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: wikijs
app.k8s.hty1024.com/version: 2.5.300
app.k8s.hty1024.com/resources: persistentVolumeClaim
spec:
resources:
requests:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
storageClassName: storage-local-wikijs
---
# 创建 Service
apiVersion: v1
kind: Service
metadata:
name: hty1024-app-wikijs-service
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: wikijs
app.k8s.hty1024.com/version: 2.5.300
app.k8s.hty1024.com/resources: service
spec:
type: NodePort
ports:
- port: 3000
targetPort: 3000
nodePort: 30004
selector:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: wikijs
app.k8s.hty1024.com/version: 2.5.300
app.k8s.hty1024.com/resources: pod
---
# 创建 StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: hty1024-app-wikijs-statefulset
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: wikijs
app.k8s.hty1024.com/version: 2.5.300
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: wikijs
app.k8s.hty1024.com/version: 2.5.300
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: wikijs
app.k8s.hty1024.com/version: 2.5.300
app.k8s.hty1024.com/resources: pod
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: localtime
hostPath:
path: /etc/localtime
- name: hty1024-app-wikijs-data
persistentVolumeClaim:
claimName: hty1024-app-wikijs-pvc
containers:
- name: wikijs
image: requarks/wiki:2.5.300
ports:
- name: tcp
containerPort: 3000
volumeMounts:
- name: localtime
mountPath: /etc/localtime
readOnly: true
- name: hty1024-app-wikijs-data
mountPath: /wiki/data
env:
- name: DB_TYPE
value: "mysql"
- name: DB_HOST
value: "hty1024-db-mysql-service.hty1024-db"
- name: DB_PORT
value: "3306"
- name: DB_USER
value: "wikijs"
- name: DB_PASS
value: "123456"
- name: DB_NAME
value: "wikijs"
nodeSelector:
node.k8s.hty1024.com/type: app
---
# 创建 Namespace
apiVersion: v1
kind: Namespace
metadata:
name: hty1024-app
---
# 创建 StorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: storage-local-gitea
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: gitea
app.k8s.hty1024.com/version: 1.19.4
app.k8s.hty1024.com/resources: storageClass
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
---
# 创建 PersistentVolume
apiVersion: v1
kind: PersistentVolume
metadata:
name: hty1024-app-gitea-pv
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: gitea
app.k8s.hty1024.com/version: 1.19.4
app.k8s.hty1024.com/resources: persistentVolume
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: storage-local-gitea
local:
path: /app/gitea/data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: node.k8s.hty1024.com/type
operator: In
values:
- app
---
# 创建 PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hty1024-app-gitea-pvc
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: gitea
app.k8s.hty1024.com/version: 1.19.4
app.k8s.hty1024.com/resources: persistentVolumeClaim
spec:
resources:
requests:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
storageClassName: storage-local-gitea
---
# 创建 Service
apiVersion: v1
kind: Service
metadata:
name: hty1024-app-gitea-service
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: gitea
app.k8s.hty1024.com/version: 1.19.4
app.k8s.hty1024.com/resources: service
spec:
type: NodePort
ports:
- port: 3000
targetPort: 3000
nodePort: 30005
selector:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: gitea
app.k8s.hty1024.com/version: 1.19.4
app.k8s.hty1024.com/resources: pod
---
# 创建 StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: hty1024-app-gitea-statefulset
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: gitea
app.k8s.hty1024.com/version: 1.19.4
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: gitea
app.k8s.hty1024.com/version: 1.19.4
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: gitea
app.k8s.hty1024.com/version: 1.19.4
app.k8s.hty1024.com/resources: pod
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: localtime
hostPath:
path: /etc/localtime
- name: hty1024-app-gitea-data
persistentVolumeClaim:
claimName: hty1024-app-gitea-pvc
containers:
- name: gitea
image: gitea/gitea:1.19.4
ports:
- name: tcp
containerPort: 3000
volumeMounts:
- name: localtime
mountPath: /etc/localtime
readOnly: true
- name: hty1024-app-gitea-data
mountPath: /data
nodeSelector:
node.k8s.hty1024.com/type: app
---
# 创建 Namespace
apiVersion: v1
kind: Namespace
metadata:
name: hty1024-app
---
# 创建 StorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: storage-local-drawio
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: drawio
app.k8s.hty1024.com/version: 22.1.8
app.k8s.hty1024.com/resources: storageClass
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
---
# 创建 PersistentVolume
apiVersion: v1
kind: PersistentVolume
metadata:
name: hty1024-app-drawio-pv
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: drawio
app.k8s.hty1024.com/version: 22.1.8
app.k8s.hty1024.com/resources: persistentVolume
spec:
capacity:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: storage-local-drawio
local:
path: /app/drawio/fonts
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: node.k8s.hty1024.com/type
operator: In
values:
- app
---
# 创建 PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hty1024-app-drawio-pvc
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: drawio
app.k8s.hty1024.com/version: 22.1.8
app.k8s.hty1024.com/resources: persistentVolumeClaim
spec:
resources:
requests:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
storageClassName: storage-local-drawio
---
# 创建 Service
apiVersion: v1
kind: Service
metadata:
name: hty1024-app-drawio-service
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: drawio
app.k8s.hty1024.com/version: 22.1.8
app.k8s.hty1024.com/resources: service
spec:
type: NodePort
ports:
- port: 8080
targetPort: 8080
nodePort: 30006
selector:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: drawio
app.k8s.hty1024.com/version: 22.1.8
app.k8s.hty1024.com/resources: pod
---
# 创建 Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: hty1024-app-drawio-deployment
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: drawio
app.k8s.hty1024.com/version: 22.1.8
app.k8s.hty1024.com/resources: deployment
spec:
replicas: 1
minReadySeconds: 30
selector:
matchLabels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: drawio
app.k8s.hty1024.com/version: 22.1.8
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: drawio
app.k8s.hty1024.com/version: 22.1.8
app.k8s.hty1024.com/resources: pod
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: localtime
hostPath:
path: /etc/localtime
- name: hty1024-app-drawio-data
persistentVolumeClaim:
claimName: hty1024-app-drawio-pvc
containers:
# - name: plantuml-server
# image: plantuml/plantuml-server:v1.2023.13
# volumeMounts:
# - name: localtime
# mountPath: /etc/localtime
# readOnly: true
# - name: hty1024-app-drawio-data
# mountPath: /usr/share/fonts/drawio
- name: export-server
image: jgraph/export-server:latest
volumeMounts:
- name: localtime
mountPath: /etc/localtime
readOnly: true
- name: hty1024-app-drawio-data
mountPath: /usr/share/fonts/drawio
ports:
- name: tcp
containerPort: 8000
env:
- name: DRAWIO_SERVER_URL
value: "http://localhost:8080"
- name: drawio
image: jgraph/drawio:22.1.8
volumeMounts:
- name: localtime
mountPath: /etc/localtime
readOnly: true
ports:
- name: tcp
containerPort: 8080
env:
- name: DRAWIO_SELF_CONTAINED
value: "1"
- name: DRAWIO_BASE_URL
value: "http://localhost:8080"
# - name: PLANTUML_URL
# value: "http://plantuml-server:8080"
- name: EXPORT_URL
value: "http://localhost:8000"
nodeSelector:
node.k8s.hty1024.com/type: app