# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

apiVersion: nvidia.com/v1alpha1
kind: DynamoGraphDeployment
metadata:
  name: sglang-disagg-planner
spec:
  pvcs:
    - name: dynamo-pvc
      create: false # Must be pre-created before deployment and SLA profiler must have been run
  services:
    Frontend:
      dynamoNamespace: dynamo
      componentType: frontend
      replicas: 1
      extraPodSpec:
        mainContainer:
          image: my-registry/sglang-runtime:my-tag
    Planner:
      dynamoNamespace: dynamo
      envFromSecret: hf-token-secret
      componentType: planner
      replicas: 1
      volumeMounts:
        - name: dynamo-pvc
          mountPoint: /data
      extraPodSpec:
        mainContainer:
          image: my-registry/sglang-runtime:my-tag
          workingDir: /workspace/components/src/dynamo/planner
          command:
          - python3
          - -m
          - planner_sla
          args:
            - --environment=kubernetes
            - --backend=sglang
            - --adjustment-interval=60
            - --profile-results-dir=/data
    decode:
      dynamoNamespace: dynamo
      envFromSecret: hf-token-secret
      componentType: worker
      subComponentType: decode
      replicas: 2
      resources:
        limits:
          gpu: "1"
      extraPodSpec:
        mainContainer:
          image: my-registry/sglang-runtime:my-tag
          workingDir: /workspace/examples/backends/sglang
          command:
            - python3
          args:
            - -m
            - dynamo.sglang
            - --model-path
            - Qwen/Qwen3-0.6B
            - --served-model-name
            - Qwen/Qwen3-0.6B
            - --page-size
            - "16"
            - --tp
            - "1"
            - --trust-remote-code
            - --skip-tokenizer-init
            - --disaggregation-mode
            - decode
            - --disaggregation-transfer-backend
            - nixl
            - --disaggregation-bootstrap-port
            - "12345"
            - --host
            - "0.0.0.0"
    prefill:
      dynamoNamespace: dynamo
      envFromSecret: hf-token-secret
      componentType: worker
      subComponentType: prefill
      replicas: 2
      resources:
        limits:
          gpu: "1"
      extraPodSpec:
        mainContainer:
          image: my-registry/sglang-runtime:my-tag
          workingDir: /workspace/examples/backends/sglang
          command:
            - python3
          args:
            - -m
            - dynamo.sglang
            - --model-path
            - Qwen/Qwen3-0.6B
            - --served-model-name
            - Qwen/Qwen3-0.6B
            - --page-size
            - "16"
            - --tp
            - "1"
            - --trust-remote-code
            - --skip-tokenizer-init
            - --disaggregation-mode
            - prefill
            - --disaggregation-transfer-backend
            - nixl
            - --disaggregation-bootstrap-port
            - "12345"
            - --host
            - "0.0.0.0"
