# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: apps/v1
kind: Deployment
metadata:
  name: chatqna-gaudi-backend-server-deploy
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: chatqna-gaudi-backend-server-deploy
  template:
    metadata:
      annotations:
        sidecar.istio.io/rewriteAppHTTPProbers: 'true'
      labels:
        app: chatqna-gaudi-backend-server-deploy
    spec:
      containers:
      - envFrom:
        - configMapRef:
            name: qna-config
        image: opea/chatqna:latest
        imagePullPolicy: IfNotPresent
        name: chatqna-gaudi-backend-server-deploy
        ports:
        - containerPort: 8888
      hostIPC: true
      nodeSelector:
        node-type: opea
      serviceAccountName: default
      topologySpreadConstraints:
      - labelSelector:
          matchLabels:
            app: chatqna-gaudi-backend-server-deploy
        maxSkew: 1
        topologyKey: kubernetes.io/hostname
        whenUnsatisfiable: ScheduleAnyway
---
apiVersion: v1
kind: Service
metadata:
  name: chatqna-gaudi-backend-server
  namespace: default
spec:
  ports:
  - name: port1
    nodePort: 30888
    port: 8888
    targetPort: 8888
  selector:
    app: chatqna-gaudi-backend-server-deploy
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dataprep-deploy
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: dataprep-deploy
  template:
    metadata:
      annotations:
        sidecar.istio.io/rewriteAppHTTPProbers: 'true'
      labels:
        app: dataprep-deploy
    spec:
      containers:
      - envFrom:
        - configMapRef:
            name: qna-config
        image: opea/dataprep-redis:latest
        imagePullPolicy: IfNotPresent
        name: dataprep-deploy
        ports:
        - containerPort: 6007
      hostIPC: true
      nodeSelector:
        node-type: opea
      serviceAccountName: default
      topologySpreadConstraints:
      - labelSelector:
          matchLabels:
            app: dataprep-deploy
        maxSkew: 1
        topologyKey: kubernetes.io/hostname
        whenUnsatisfiable: ScheduleAnyway
---
apiVersion: v1
kind: Service
metadata:
  name: dataprep
  namespace: default
spec:
  ports:
  - name: port1
    port: 6007
    targetPort: 6007
  selector:
    app: dataprep-deploy
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: embedding-server-deploy
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: embedding-server-deploy
  template:
    metadata:
      annotations:
        sidecar.istio.io/rewriteAppHTTPProbers: 'true'
      labels:
        app: embedding-server-deploy
    spec:
      containers:
      - args:
        - --model-id
        - BAAI/bge-base-en-v1.5
        - --auto-truncate
        envFrom:
        - configMapRef:
            name: qna-config
        image: ghcr.io/huggingface/text-embeddings-inference:cpu-1.5
        imagePullPolicy: IfNotPresent
        name: embedding-server-deploy
        ports:
        - containerPort: 80
        volumeMounts:
        - mountPath: /data
          name: volume1
        - mountPath: /dev/shm
          name: shm
      hostIPC: true
      nodeSelector:
        node-type: opea
      serviceAccountName: default
      topologySpreadConstraints:
      - labelSelector:
          matchLabels:
            app: embedding-server-deploy
        maxSkew: 1
        topologyKey: kubernetes.io/hostname
        whenUnsatisfiable: ScheduleAnyway
      volumes:
      - hostPath:
          path: /mnt/models
          type: Directory
        name: volume1
      - emptyDir:
          medium: Memory
          sizeLimit: 1Gi
        name: shm
---
apiVersion: v1
kind: Service
metadata:
  name: embedding-server
  namespace: default
spec:
  ports:
  - name: port1
    port: 8090
    targetPort: 80
  selector:
    app: embedding-server-deploy
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: llm-server-deploy
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: llm-server-deploy
  template:
    metadata:
      annotations:
        sidecar.istio.io/rewriteAppHTTPProbers: 'true'
      labels:
        app: llm-server-deploy
    spec:
      containers:
      - args:
        - --model-id
        - Intel/neural-chat-7b-v3-3
        - --max-input-length
        - '2048'
        - --max-total-tokens
        - '4096'
        envFrom:
        - configMapRef:
            name: qna-config
        image: ghcr.io/huggingface/tgi-gaudi:2.0.5
        imagePullPolicy: IfNotPresent
        name: llm-server-deploy
        ports:
        - containerPort: 80
        resources:
          limits:
            habana.ai/gaudi: 1
        volumeMounts:
        - mountPath: /data
          name: volume1
        - mountPath: /dev/shm
          name: shm
      hostIPC: true
      nodeSelector:
        node-type: opea
      serviceAccountName: default
      topologySpreadConstraints:
      - labelSelector:
          matchLabels:
            app: llm-server-deploy
        maxSkew: 1
        topologyKey: kubernetes.io/hostname
        whenUnsatisfiable: ScheduleAnyway
      volumes:
      - hostPath:
          path: /mnt/models
          type: Directory
        name: volume1
      - emptyDir:
          medium: Memory
          sizeLimit: 1Gi
        name: shm
---
apiVersion: v1
kind: Service
metadata:
  name: llm-server
  namespace: default
spec:
  ports:
  - name: port1
    port: 8005
    targetPort: 80
  selector:
    app: llm-server-deploy
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: raranking-server-deploy
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: raranking-server-deploy
  template:
    metadata:
      annotations:
        sidecar.istio.io/rewriteAppHTTPProbers: 'true'
      labels:
        app: raranking-server-deploy
    spec:
      containers:
      - args:
        - --model-id
        - BAAI/bge-reranker-base
        - --auto-truncate
        envFrom:
        - configMapRef:
            name: qna-config
        image: ghcr.io/huggingface/tei-gaudi:latest
        imagePullPolicy: IfNotPresent
        name: raranking-server-deploy
        ports:
        - containerPort: 80
        resources:
          limits:
            habana.ai/gaudi: 1
        volumeMounts:
        - mountPath: /data
          name: volume1
        - mountPath: /dev/shm
          name: shm
      hostIPC: true
      nodeSelector:
        node-type: opea
      serviceAccountName: default
      topologySpreadConstraints:
      - labelSelector:
          matchLabels:
            app: raranking-server-deploy
        maxSkew: 1
        topologyKey: kubernetes.io/hostname
        whenUnsatisfiable: ScheduleAnyway
      volumes:
      - hostPath:
          path: /mnt/models
          type: Directory
        name: volume1
      - emptyDir:
          medium: Memory
          sizeLimit: 1Gi
        name: shm
---
apiVersion: v1
kind: Service
metadata:
  name: raranking-server
  namespace: default
spec:
  ports:
  - name: port1
    port: 8808
    targetPort: 80
  selector:
    app: raranking-server-deploy
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: retriever-server-deploy
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: retriever-server-deploy
  template:
    metadata:
      annotations:
        sidecar.istio.io/rewriteAppHTTPProbers: 'true'
      labels:
        app: retriever-server-deploy
    spec:
      containers:
      - envFrom:
        - configMapRef:
            name: qna-config
        image: opea/retriever-redis:latest
        imagePullPolicy: IfNotPresent
        name: retriever-server-deploy
        ports:
        - containerPort: 7000
      hostIPC: true
      nodeSelector:
        node-type: opea
      serviceAccountName: default
      topologySpreadConstraints:
      - labelSelector:
          matchLabels:
            app: retriever-server-deploy
        maxSkew: 1
        topologyKey: kubernetes.io/hostname
        whenUnsatisfiable: ScheduleAnyway
---
apiVersion: v1
kind: Service
metadata:
  name: retriever-server
  namespace: default
spec:
  ports:
  - name: port1
    port: 7000
    targetPort: 7000
  selector:
    app: retriever-server-deploy
  type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-vector-db-deploy
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis-vector-db-deploy
  template:
    metadata:
      annotations:
        sidecar.istio.io/rewriteAppHTTPProbers: 'true'
      labels:
        app: redis-vector-db-deploy
    spec:
      containers:
      - envFrom:
        - configMapRef:
            name: qna-config
        image: redis/redis-stack:7.2.0-v9
        imagePullPolicy: IfNotPresent
        name: redis-vector-db-deploy
        ports:
        - containerPort: 8001
        - containerPort: 6379
      hostIPC: true
      nodeSelector:
        node-type: opea
      serviceAccountName: default
      topologySpreadConstraints:
      - labelSelector:
          matchLabels:
            app: redis-vector-db-deploy
        maxSkew: 1
        topologyKey: kubernetes.io/hostname
        whenUnsatisfiable: ScheduleAnyway
---
apiVersion: v1
kind: Service
metadata:
  name: redis-vector-db
  namespace: default
spec:
  ports:
  - name: port1
    port: 6379
    targetPort: 6379
  - name: port2
    port: 8001
    targetPort: 8001
  selector:
    app: redis-vector-db-deploy
  type: ClusterIP
---
