# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: Update the namespace field below to match your deployment namespace
apiVersion: apps/v1
kind: Deployment
metadata:
  name: llama3-70b-agg-epp
  labels:
    app: llama3-70b-agg-epp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: llama3-70b-agg-epp
  template:
    metadata:
      labels:
        app: llama3-70b-agg-epp
    spec:
      serviceAccountName: epp-sa
      terminationGracePeriodSeconds: 130

      imagePullSecrets:
        - name: docker-imagepullsecret

      containers:
        - name: epp
          image: nvcr.io/nvstaging/ai-dynamo/epp-inference-extension-dynamo:v0.6.0-1
          imagePullPolicy: IfNotPresent
          resources:
            requests:
              memory: "1Gi"
              cpu: "1"
            limits:
              memory: "2Gi"
              cpu: "2"
          command: ["/bin/sh", "-c"]
          args:
            - >
              exec /epp
              -poolName "llama3-70b-agg-pool"
              -poolNamespace "$POD_NAMESPACE"
              -v 4 --zap-encoder json
              -grpcPort 9002 -grpcHealthPort 9003
              -configFile /etc/epp/epp-config-dynamo.yaml

          volumeMounts:
            - name: epp-config
              mountPath: /etc/epp
              readOnly: true

          env:
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: PLATFORM_NAMESPACE
              value: "$(POD_NAMESPACE)" # set to your dynamo platform namespace if different
            - name: ETCD_ENDPOINTS
              value: "dynamo-platform-etcd.$(PLATFORM_NAMESPACE):2379" #  update dynamo-platform to appropriate namespace
            - name: NATS_SERVER
              value: "nats://dynamo-platform-nats.$(PLATFORM_NAMESPACE):4222" #  update dynamo-platform to appropriate namespace
            - name: DYN_NAMESPACE
              value: "llama3-70b-agg"
            - name: DYNAMO_KV_BLOCK_SIZE
              value: "128" # UPDATE to match the --block-size in your deploy.yaml engine command
            - name: USE_STREAMING
              value: "true"

          ports:
            - containerPort: 9002
            - containerPort: 9003
            - name: metrics
              containerPort: 9090
          livenessProbe:
            grpc:
              port: 9003
              service: inference-extension
            initialDelaySeconds: 5
            periodSeconds: 10
          readinessProbe:
            grpc:
              port: 9003
              service: inference-extension
            initialDelaySeconds: 5
            periodSeconds: 10

      volumes:
        - name: epp-config
          configMap:
            name: epp-config
            items:
              - key: epp-config-dynamo.yaml
                path: epp-config-dynamo.yaml
