apiVersion: apps/v1
kind: Deployment
metadata:
  name: rtc-backend-dev
  labels:
    app: rtc-backend-dev
spec:
  replicas: 1 # 测试环境通常 1 个副本就够了
  selector:
    matchLabels:
      app: rtc-backend-dev
  template:
    metadata:
      labels:
        app: rtc-backend-dev
    spec:
      containers:
      - name: rtc-backend
        image: ${CI_REGISTRY_IMAGE}/backend:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 8000
        env:
        # Database (Test Environment)
        - name: DB_HOST
          value: "test-mysql-host" # <--- 请填入测试环境数据库 IP
        - name: DB_NAME
          value: "rtc_test"        # <--- 测试数据库名
        - name: DB_USER
          value: "test_user"
        - name: DB_PASSWORD
          value: "test_password"
        - name: DB_PORT
          value: "3306"

        # Redis (Test Environment)
        - name: REDIS_URL
          value: "redis://:password@test-redis-host:6379/1" # <--- 测试环境 Redis

        # Aliyun OSS (Test)
        - name: OSS_ACCESS_KEY_ID
          value: "test_key"
        - name: OSS_ACCESS_KEY_SECRET
          value: "test_secret"
        - name: OSS_BUCKET_NAME
          value: "qy-rtc"
        - name: OSS_ENDPOINT
          value: "oss-cn-beijing.aliyuncs.com"
        - name: OSS_CUSTOM_DOMAIN
          value: ""

        # Aliyun Log (If used by app)
        - name: ALIYUN_LOG_PROJECT
          value: "toy"
        - name: ALIYUN_LOG_STORE
          value: "rtc"
        - name: ALIYUN_LOG_ENDPOINT
          value: "cn-guangzhou.log.aliyuncs.com"
        - name: ALIYUN_LOG_ACCESS_KEY_ID
          value: "LTAI5tBGAkR2rra2prTAX9yc"
        - name: ALIYUN_LOG_ACCESS_KEY_SECRET
          value: "U1z3d0p5saPRD5sCxVooJYSjxSAmKB"

        # Log Center
        - name: ENVIRONMENT
          value: "development"
        - name: LOG_CENTER_URL
          value: "https://qiyuan-log-center-api.airlabs.art"
        - name: LOG_CENTER_ENABLED
          value: "true"
        livenessProbe:
          httpGet:
            path: /healthz/
            port: 8000
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 5
          failureThreshold: 3
        readinessProbe:
          httpGet:
            path: /healthz/
            port: 8000
          initialDelaySeconds: 15
          periodSeconds: 5
          timeoutSeconds: 3
          failureThreshold: 3
        resources:
          requests:
            memory: "256Mi"
            cpu: "250m"
          limits:
            memory: "1024Mi"
            cpu: "1000m"
---
apiVersion: v1
kind: Service
metadata:
  name: rtc-backend-dev
spec:
  selector:
    app: rtc-backend-dev
  ports:
    - protocol: TCP
      port: 8000
      targetPort: 8000
