apiVersion: apps/v1
kind: Deployment
metadata:
  name: logistics-service
  namespace: erp
  labels:
    app: logistics-service
    version: v1
spec:
  replicas: 2
  selector:
    matchLabels:
      app: logistics-service
  template:
    metadata:
      labels:
        app: logistics-service
        version: v1
    spec:
      containers:
        - name: logistics-service
          image: erp-java-backend/logistics-service:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 8086
              name: http
              protocol: TCP
          env:
            - name: SPRING_PROFILES_ACTIVE
              value: "prod"
            - name: DB_HOST
              value: "111.229.80.149"
            - name: DB_PORT
              value: "3306"
            - name: DB_NAME
              value: "erp_db"
            - name: DB_USER
              value: "root"
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: erp-db-secret
                  key: password
            - name: REDIS_HOST
              value: "111.229.80.149"
            - name: REDIS_PORT
              value: "6379"
            - name: REDIS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: erp-redis-secret
                  key: password
            - name: NACOS_HOST
              value: "111.229.80.149"
            - name: NACOS_PORT
              value: "8848"
          resources:
            requests:
              memory: "256Mi"
              cpu: "100m"
            limits:
              memory: "768Mi"
              cpu: "500m"
          livenessProbe:
            httpGet:
              path: /actuator/health
              port: 8086
            initialDelaySeconds: 60
            periodSeconds: 30
            timeoutSeconds: 10
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /actuator/health
              port: 8086
            initialDelaySeconds: 30
            periodSeconds: 10
            timeoutSeconds: 5
            failureThreshold: 3
---
apiVersion: v1
kind: Service
metadata:
  name: logistics-service
  namespace: erp
spec:
  type: ClusterIP
  ports:
    - port: 8086
      targetPort: 8086
      protocol: TCP
      name: http
  selector:
    app: logistics-service
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: logistics-service
  namespace: erp
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: "10m"
spec:
  rules:
    - host: logistics.erpzbbh.cn
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: logistics-service
                port:
                  number: 8086
