apiVersion: apps/v1
kind: Deployment
metadata:
  name: o2server-deployment
  labels:
    app: o2server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: o2server
  template:
    metadata:
      labels:
        app: o2server
    spec:
      containers:
        - name: o2server
          image: o2oa/o2server:latest
          imagePullPolicy: Always #每次拉取Always,永不从外部仓库拉取镜像Never
          ports:
            - containerPort: 80
          resources:
            requests:
              memory: "5Gi" # 请求 6GB 内存
              cpu: "4" # 请求 4 个 CPU 核心
            limits:
              memory: "10Gi" # 限制最大内存为 8GB
              cpu: "4" # 限制最大 CPU 使用为 4 个 CPU 核心
          volumeMounts:
            - name: mysql-lib-volume
              mountPath: /var/lib/mysql
            - name: config-volume
              mountPath: /opt/o2server/config
            - name: custom-volume
              mountPath: /opt/o2server/custom
            - name: dynamic-volume
              mountPath: /opt/o2server/dynamic
            - name: local-volume
              mountPath: /opt/o2server/local
            - name: logs-volume
              mountPath: /opt/o2server/logs
            - name: webroot-volume
              mountPath: /opt/o2server/webroot
      volumes:
        - name: mysql-lib-volume
          hostPath:
            path: /data/o2oa/mysql/lib/mysql
        - name: config-volume
          hostPath:
            path: /data/o2oa/o2server/config
        - name: custom-volume
          hostPath:
            path: /data/o2oa/o2server/custom
        - name: dynamic-volume
          hostPath:
            path: /data/o2oa/o2server/dynamic
        - name: local-volume
          hostPath:
            path: /data/o2oa/o2server/local
        - name: logs-volume
          hostPath:
            path: /data/o2oa/o2server/logs
        - name: webroot-volume
          hostPath:
            path: /data/o2oa/o2server/webroot
---
apiVersion: v1
kind: Service
metadata:
  name: o2server-service
spec:
  selector:
    app: o2server
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      nodePort: 30080 # 可选的 NodePort
  type: NodePort # 使用 NodePort 类型
