apiVersion: v1
kind: Namespace
metadata:
  name: cube-cube
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cube
  namespace: cube-cube
  labels:
    app: cube
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cube
  template:
    metadata:
      labels:
        app: cube
    spec:
      imagePullSecrets:
        - name: registry-creds
      containers:
        - name: cube
          # tag 由 CI 通过 `kubectl set image` 替换；初次 apply 由 README 部署 runbook 指定
          image: registry.famzheng.me/mochi/cube:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 8080
              name: http
          envFrom:
            # secret `chat-credentials` (LLM_API_TOKEN + GITEA_TOKEN) 由 kubectl 手工创建，
            # 不在 git manifest 里。kubectl apply -f all.yaml 不会动它。
            - secretRef:
                name: chat-credentials
          env:
            - name: LLM_GATEWAY
              value: "http://3.135.65.204:8848/v1"
            - name: LLM_MODEL
              value: "gemma-4-31b-it"
            - name: GITEA_URL
              value: "https://famzheng.me/gitea"
            - name: ISSUE_REPO
              value: "fam/cube"
          readinessProbe:
            httpGet:
              path: /healthz
              port: http
            initialDelaySeconds: 1
            periodSeconds: 5
          livenessProbe:
            httpGet:
              path: /healthz
              port: http
            initialDelaySeconds: 5
            periodSeconds: 15
          resources:
            requests:
              cpu: 10m
              memory: 16Mi
            limits:
              cpu: 200m
              memory: 128Mi
---
apiVersion: v1
kind: Service
metadata:
  name: cube
  namespace: cube-cube
spec:
  selector:
    app: cube
  ports:
    - name: http
      port: 80
      targetPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: cube
  namespace: cube-cube
spec:
  ingressClassName: traefik
  rules:
    - host: cube.famzheng.me
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: cube
                port:
                  number: 80
