apiVersion: v1
kind: ConfigMap
metadata:
  namespace: preview
  name: asktug-api-proxy-preview-config-v2
data:
  ACCOUNTS_URL: https://accounts-preview.pingcap.cn
  ASKTUG_URL: http://10.10.172.228:40080
  ASKTUG_TOKEN: b6fbdfc59167a7a76ff085b0997e963355eeb8494a57c3f2d56bb2816ca10f9d
  ENABLE_CORS: "true"

---

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: preview
  name: asktug-api-proxy-preview
spec:
  replicas: 1
  selector:
    matchLabels:
      app: asktug-api-proxy-preview
  template:
    metadata:
      labels:
        app: asktug-api-proxy-preview
    spec:
      containers:
      - name: nodejs
        image: registry.cn-hangzhou.aliyuncs.com/pingcap-ee/asktug-api-proxy:v1.2.0
        imagePullPolicy: Always
        command: ["npm", "start"]
        envFrom:
        - configMapRef:
            name: asktug-api-proxy-preview-config-v2
        livenessProbe:
          httpGet:
            path: /healthy/live
            port: 3000
          periodSeconds: 10
          initialDelaySeconds: 3
          successThreshold: 1
          timeoutSeconds: 4
        ports:
        - containerPort: 3000
        resources:
          limits:
            cpu: "1"
            memory: 1Gi
          requests:
            cpu: "0.25"
            memory: 256Mi
      imagePullSecrets:
      - name: aliyun-hangzhou-registry

---

apiVersion: v1
kind: Service
metadata:
  namespace: preview
  name: asktug-api-proxy-preview
  labels:
    app: asktug-api-proxy-preview
spec:
  ports:
    - port: 80
      targetPort: 3000
      protocol: TCP
      name: http
  selector:
    app: asktug-api-proxy-preview
