From dca58ee1985daacf1b182f47dc7e30654c120852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=A4=A9=E5=9E=9A?= Date: Tue, 19 Dec 2023 15:45:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=83=A8=E7=BD=B2seafile?= =?UTF-8?q?=E7=9A=84yaml=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/seafile/seafile.yaml | 316 ++++++++++++++++++++++++++++++++++ 1 file changed, 316 insertions(+) create mode 100644 examples/seafile/seafile.yaml diff --git a/examples/seafile/seafile.yaml b/examples/seafile/seafile.yaml new file mode 100644 index 0000000..0983beb --- /dev/null +++ b/examples/seafile/seafile.yaml @@ -0,0 +1,316 @@ +# --- +# +# # 创建 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.3 + 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.3 + 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.3 + 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.3 + 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.3 + 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.3 + 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.3 + 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.3 + 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.3 + 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.3 + 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.3 + 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.3 + 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.6 + 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.22-alpine3.19 + ports: + - name: tcp + containerPort: 11211 + volumeMounts: + - name: localtime + mountPath: /etc/localtime + readOnly: true + - name: seafile + image: seafileltd/seafile-mc:11.0.3 + 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 +