Integrating a Heterogeneous GPU into kpanda¶
This guide describes how to integrate a new heterogeneous GPU (such as NVIDIA, Ascend, Metax, Enflame, or Biren) into kpanda, so that it supports type recognition, resource scheduling, monitoring, and alerting in the kpanda UI.
Prerequisites¶
- A working Kubernetes environment.
- The GPU-related software stack (firmware, driver, Docker runtime, etc.) is already installed.
Overview¶
Integrating a new GPU involves the following four steps, which must be completed in order:
| Step | Task | Output |
|---|---|---|
| 1 | Configure the GPU type | A gpu-type-config entry on the Global cluster |
| 2 | Add metric recording rules | A PrometheusRule on the GPU cluster |
| 3 | Add a monitoring dashboard | A GrafanaDashboard on the GPU cluster |
| 4 | Add alert rules | A VMRule on the GPU cluster |
After completing these steps, verify in the kpanda UI that the GPU's type, resources, monitoring, and alerts are displayed correctly.
All examples below use Ascend NPU. When integrating another GPU, replace the type identifier, resource names, and metrics accordingly.
Step 1: Configure the GPU Type¶
Every GPU type has a unique identifier in kpanda, recorded in the gpu-type-config configuration under the kpanda-system namespace of the Global cluster. To integrate a new GPU, add a type definition to this configuration.
Example for Ascend:
{
"type": "Ascend-NPU",
"alias": "Ascend NPU",
"product_key": "huawei.com/npu.chip.name",
"dashboard_url": {
"zh": "/ui/insight-grafana/d/ascend-950dt-node-overview/ascend-950dt-e88a82-e782b9-e680bb-e8a788",
"en": "/ui/insight-grafana/d/ascend-950dt-node-overview/ascend-950dt-e88a82-e782b9-e680bb-e8a788"
},
"resource": [
{
"key": "huawei.com/npu",
"alias": "NPU Card Num(Core)",
"alias_zh": "物理卡数量(个)",
"is_allocatable": true,
"description": "",
"description_zh": "",
"range": {
"min": 1,
"min_desc": "Min use 1 npu",
"max": 128,
"max_desc": "Max use 128 npu"
}
}
]
}
Field Reference¶
| Field | Level | Description |
|---|---|---|
type | GPU type | Unique identifier of the GPU type. kpanda uses it to distinguish GPUs; there can be only one entry per type in gpu-type-config. It must correspond to the vendor + mode label combination of the recording metrics (NVIDIA full card: vendor="nvidia" / mode="GPU"; Ascend full card: vendor="ascend" / mode="GPU"). |
alias | GPU type | Display name of the type, shown in the UI. |
product_key | GPU type | The node label key that identifies the specific GPU model on a node (e.g. huawei.com/npu.chip.name). kpanda reads the model from node labels via this key, for grouping, filtering, and scheduling. |
dashboard_url | GPU type | Grafana dashboard address for this type, split into zh / en. The format is /ui/insight-grafana/d/<CR name>/<uid>, corresponding to the GrafanaDashboard created in Step 3. |
resource | GPU type | List of schedulable resources exposed by this GPU. A type may contain multiple items (e.g. full card, memory, compute). The fields below describe each item. |
resource[].key | Resource item | The Kubernetes resource name (the key used in resources.limits / requests, e.g. huawei.com/npu), i.e. the resource requested during scheduling. |
resource[].alias / alias_zh | Resource item | English / Chinese display name of the resource. |
resource[].is_allocatable | Resource item | Whether the resource can be requested by workloads. When true, the resource appears in the container resource request UI and a quantity can be entered. |
resource[].description / description_zh | Resource item | English / Chinese description of the resource; may be empty. |
resource[].range | Resource item | The allowed value range per container, including min / max and the corresponding min_desc / max_desc text, used for input validation and hints in the UI. |
Step 2: Add Metric Recording Rules¶
Recording rules normalize each vendor's raw metrics into kpanda's unified kpanda_gpu_* core metrics. They are delivered via a PrometheusRule on the GPU cluster.
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
labels:
operator.insight.io/managed-by: insight
name: insight-agent-kpanda-gpu-ascend.records
namespace: insight-system
spec:
groups:
- name: gpu-records-ascend.rule
rules:
- expr: |-
max by (cluster, namespace, pod, id, UUID, gpu, modelName, node) (
label_replace(
label_replace(
label_join(
npu_chip_info_name
* on(namespace, pod, id) group_left(serial_number)
max by (namespace, pod, id, serial_number) (npu_chip_info_serial_number{serial_number!="NA"})
* on(namespace, pod) group_left(node) max by (namespace, pod, node) (kube_pod_info),
"UUID", "-", "serial_number", "id"
),
"gpu", "$1", "id", "(.*)"
),
"modelName", "$1", "name", "(.+)"
)
)
record: insight_ascend_npu_chip_meta
- expr: (count by (node) (insight_ascend_npu_chip_meta) > 0) * 0 + 1
labels:
vendor: ascend
mode: GPU
record: kpanda_gpu_mode
# ... remaining kpanda_gpu_* metric rules
Any newly integrated GPU must record the standard metrics according to the following baseline.
Metric Baseline¶
Using NVIDIA full-card mode (mode="GPU") as the baseline, there are 13 standard kpanda_gpu_* metrics: 4 node-level, 6 device-level, and 3 Pod-level. These metrics should be recorded when integrating a new card.
Allocation and Pod-related metrics may have no samples when there is no corresponding allocation or no running Pod, so you cannot require all 13 metrics to be returned on every query.
Label Baseline¶
- Common labels (required on all 13 metrics):
cluster: cluster IDcluster_name: cluster display namevendor: vendor (e.g.nvidia,ascend)mode: GPU mode (full cardGPU, virtual cardVGPU, and other special modes such as MIG)node: node nameprometheus: scrape source identifiercluster_nameandprometheusare filled in by the collection pipeline; their sample values should not be hardcoded.- Specific labels: extra dimensions that device-level and Pod-level metrics add on top of the common labels. They are not exclusive to any single metric.
- Device-level:
UUID(GPU unique identifier),gpu(card index),modelName(model name) - Pod-level: adds
exported_namespace,exported_podon top of the device-level labels
Required Metrics¶
| Metric | Level | Unit | Specific labels (beyond common labels) |
|---|---|---|---|
kpanda_gpu_mode | Node | - | None |
kpanda_gpu_count | Node | count | None |
kpanda_gpu_allocated | Node | count | None |
kpanda_gpu_mem_allocated | Node | MiB | None |
kpanda_gpu_device_info | Device | - | UUID, gpu, modelName |
kpanda_gpu_device_core_utilization | Device | % | UUID, gpu, modelName |
kpanda_gpu_device_core_allocated | Device | % | UUID, gpu, modelName |
kpanda_gpu_device_memory_total | Device | MiB | UUID, gpu, modelName |
kpanda_gpu_device_memory_used | Device | MiB | UUID, gpu, modelName |
kpanda_gpu_device_memory_allocated | Device | MiB | UUID, gpu, modelName |
kpanda_gpu_pod_utilization | Pod | % | UUID, gpu, modelName, exported_namespace, exported_pod |
kpanda_gpu_mem_pod_usage | Pod | MiB | UUID, modelName, exported_namespace, exported_pod (no gpu) |
kpanda_gpu_mem_pod_utilization | Pod | % | UUID, modelName, exported_namespace, exported_pod (no gpu) |
In the NVIDIA full-card real samples,
kpanda_gpu_mem_pod_usageandkpanda_gpu_mem_pod_utilizationdo not carry thegpulabel, whereaskpanda_gpu_pod_utilizationdoes. When integrating, provide the dimensions according to each metric's real samples.
Real Samples¶
The following are real samples from NVIDIA full card (Tesla P4), for reference:
kpanda_gpu_mode{cluster="6c52dff3-...", cluster_name="jinye-gpu-cluster-1", vendor="nvidia", mode="GPU", node="controller-node-1", prometheus="insight-system/insight-agent-prometheus"} = 1
kpanda_gpu_device_memory_used{cluster="6c52dff3-...", cluster_name="jinye-gpu-cluster-1", vendor="nvidia", mode="GPU", node="controller-node-1", prometheus="insight-system/insight-agent-prometheus", UUID="GPU-dd924653-2c99-1cb5-4a3e-855a15dfb1b2", gpu="0", modelName="Tesla P4"}
kpanda_gpu_pod_utilization{..., vendor="nvidia", mode="GPU", UUID="GPU-dd924653-...", gpu="0", modelName="Tesla P4", exported_namespace="default", exported_pod="gpu-burn-demo-84dcdfbc4f-cxvfm"}
Step 3: Add a Monitoring Dashboard¶
The GPU monitoring dashboard is delivered via a GrafanaDashboard custom resource. The dashboard content is provided as Grafana JSON in spec.json:
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
labels:
operator.insight.io/managed-by: insight
name: ascend-950dt-node-overview
namespace: insight-system
spec:
allowCrossNamespaceImport: true
instanceSelector:
matchLabels:
operator.insight.io/managed-by: insight
json: |-
{
// put the dashboard JSON here
}
The label
operator.insight.io/managed-by: insightis the insight management identifier and must not be modified.
After the dashboard is created, fill its access URL back into the dashboard_url field of the gpu-type-config from Step 1:
"dashboard_url": {
"zh": "/ui/insight-grafana/d/ascend-950dt-node-overview/ascend-950dt-e88a82-e782b9-e680bb-e8a788",
"en": "/ui/insight-grafana/d/ascend-950dt-node-overview/ascend-950dt-e88a82-e782b9-e680bb-e8a788"
}
URL segments:
/ui/insight-grafana/d/: the Grafana URL prefixascend-950dt-node-overview: the name of theGrafanaDashboardCRascend-950dt-e88a82-e782b9-e680bb-e8a788: the dashboard uid
Step 4: Add Alert Rules¶
Finally, add alert rules for the GPU, delivered via a VMRule:
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMRule
metadata:
labels:
operator.insight.io/builtin-rule: 'true'
name: ascend
namespace: insight-system
spec:
groups:
- name: ascend-npu
rules:
- alert: AscendAIProcessorNetworkPortLinkStatusDown
annotations:
description: 'Network port Link status changed from 1 (UP) to 0 (DOWN), current status: {{ $value }}'
expr: '{{$expr}}'
summary: Ascend AI Processor network port Link status is DOWN (instance {{ $labels.instance }} - NPU {{ $labels.id }})
value: '{{$value}}'
expr: npu_chip_info_link_status == 0
for: 10s
labels:
rule_id: 01m60sx49f249nzzp1sqxj95pb
severity: warning
source: promql
record: ''
# ... remaining alert rules
Verification¶
After completing all four steps, confirm in the kpanda UI that:
- The GPU type and resources are correctly recognized and can be requested for scheduling.
- The monitoring dashboard loads correctly and the
kpanda_gpu_*metrics have data. - The alert rules take effect and appear in the alert list.