|
| 1 | +# DCGM Health Check |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +This tool runs as a Kubernetes DaemonSet to perform passive health checks on NVIDIA GPUs within a GKE cluster using DCGM (Data Center GPU Manager) and NVML. |
| 6 | + |
| 7 | +It continuously monitors GPU nodes for hardware errors, XID errors, and InfiniBand/network issues. When an issue is detected, the agent patches the Kubernetes Node object to report the failure, applying the appropriate severity label (`Warning`, `Failure` or `Fatal`). |
| 8 | + |
| 9 | +-------------------------------------------------------------------------------- |
| 10 | + |
| 11 | +## ✨ Key Features |
| 12 | + |
| 13 | +- **Passive Health Checking**: Connects to the local DCGM daemon to watch for hardware errors without disrupting running workloads. |
| 14 | +- **Failure Reporting**: Automatically adds conditions to the Kubernetes Node (e.g., `GPUUnhealthy`) and sets the `cloud.google.com/health-check-status` label to the severity of the issue (e.g., `Fatal`, `Warning`) when issues occur. The label is cleared when the node is healthy. |
| 15 | +- **Configurable XID Severities**: Any detected XID error marks the node as unhealthy with a `Warning` severity. You can define specific XID errors to escalate to `Fatal` severity via an optional ConfigMap. |
| 16 | + |
| 17 | +## 🚀 Quick Start |
| 18 | + |
| 19 | +The health check agent is deployed as a DaemonSet to ensure it runs on every node with an NVIDIA GPU. |
| 20 | + |
| 21 | +### Deploying to a GKE cluster |
| 22 | + |
| 23 | +1. **Build and push the image**: |
| 24 | + Use the provided script to build a multi-architecture Docker image and push it to your Artifact Registry: |
| 25 | + |
| 26 | + ```bash |
| 27 | + ./build-and-push-cluster-health-check.sh -p <YOUR_PROJECT> -r <YOUR_REPO> -i cluster-health-check |
| 28 | + ``` |
| 29 | + |
| 30 | +2. **Update the image reference**: |
| 31 | + Edit `deployment/dcgm-healthcheck.yaml` to replace the `<YOUR_REGISTRY>/<YOUR_REPO>/cluster-health-check:latest` image string with your remote destination image created in the previous step. |
| 32 | + |
| 33 | +3. **Deploy the DaemonSet**: |
| 34 | + Apply the Kubernetes manifest in the `deployment/` directory: |
| 35 | + |
| 36 | + ```bash |
| 37 | + kubectl apply -f deployment/dcgm-healthcheck.yaml |
| 38 | + ``` |
| 39 | + |
| 40 | +### 📝 Example Output |
| 41 | + |
| 42 | +Once deployed, the agent will continuously monitor the node's health. When a failure is detected, the agent patches the node's status conditions and metadata labels. You can view the health check results directly on the nodes: |
| 43 | + |
| 44 | +```bash |
| 45 | +$ kubectl get nodes -o custom-columns=NAME:.metadata.name,HEALTH:.metadata.labels.cloud\.google\.com/health-check-status |
| 46 | +NAME HEALTH |
| 47 | +gke-sa-gke-a4x-a4x-highgpu-4g-a4x-poo-a482f777-078q <none> |
| 48 | +gke-sa-gke-a4x-a4x-highgpu-4g-a4x-poo-a482f777-1rk7 warning |
| 49 | +``` |
| 50 | + |
| 51 | +You can view the specific failure message in the node conditions using `kubectl describe`: |
| 52 | + |
| 53 | +```bash |
| 54 | +$ kubectl get node <node-name> -o json | jq -r '["Type", "Status", "LastTransitionTime", "Reason", "Message"], (.status.conditions[] | select(.type == "GPUUnhealthy") | [.type, .status, .lastTransitionTime, .reason, .message]) | @tsv' | column -t |
| 55 | + |
| 56 | +Type Status LastTransitionTime Reason Message |
| 57 | +GPUUnhealthy True 2026-07-08T20:57:02Z HealthCheckFailed <detailed health check message> |
| 58 | +``` |
| 59 | + |
| 60 | +## ⚙️ Configuration (Optional) |
| 61 | + |
| 62 | +The `fatal-xids-config` ConfigMap is **optional**. It controls which NVIDIA XID errors escalate the node's issue severity from `Warning` to `Fatal`. |
| 63 | + |
| 64 | +By default, any XID error will cause the node to be marked as unhealthy (`GPUUnhealthy=True`) with a `Warning` severity. If you apply this ConfigMap and an error matches the `fatal-xids` list, the `cloud.google.com/health-check-status` label will instead be set to `Fatal`. |
| 65 | + |
| 66 | +```yaml |
| 67 | +apiVersion: v1 |
| 68 | +kind: ConfigMap |
| 69 | +metadata: |
| 70 | + name: fatal-xids-config |
| 71 | + namespace: default |
| 72 | +data: |
| 73 | + fatal-xids: "79, 119" # Comma-separated list of fatal XIDs |
| 74 | +``` |
| 75 | +
|
| 76 | +If you wish to configure fatal XIDs, apply the ConfigMap: |
| 77 | +
|
| 78 | +```bash |
| 79 | +kubectl apply -f deployment/configmap.yaml |
| 80 | +``` |
| 81 | + |
| 82 | +You can update this ConfigMap at any time and the agent will automatically reload the configuration. |
| 83 | + |
| 84 | +## 🛠️ Developer Guide: Modifying and Releasing Your Own Image |
| 85 | + |
| 86 | +This section is for developers who wish to customize the script's behavior or release their own version of the container image to a private Google Artifact Registry. |
| 87 | + |
| 88 | +### 1. Modifying the Code |
| 89 | + |
| 90 | +- The core logic for generating the health check is located in the `cmd/` directory, with the main entry point being `cmd/dcgm-healthcheck/main.go`. |
| 91 | +- The image and all relevant dependencies are defined in the `Dockerfile`. |
| 92 | + |
| 93 | +### 2. Building and Pushing to Artifact Registry |
| 94 | + |
| 95 | +We provide a convenient shell script to build and push your customized image to your own Artifact Registry. |
| 96 | + |
| 97 | +You can do so by invoking the `build-and-push-cluster-health-check.sh` script with the following parameters: |
| 98 | + |
| 99 | +| Flag | Description | Required | |
| 100 | +| :--- | :-------------------------------------------------------------- | :------- | |
| 101 | +| `-p` | Your Google Cloud Project ID. | **Yes** | |
| 102 | +| `-r` | The name of your Artifact Registry repository. | **Yes** | |
| 103 | +| `-i` | The name for your image. | **Yes** | |
| 104 | +| `-l` | The region of your Artifact Registry. Defaults to `us-central1` | No | |
| 105 | +| `-v` | Version tag for the image. Defaults to `YYYY-MM-DD`. | No | |
| 106 | +| `-h` | Display the help message. | No | |
| 107 | + |
| 108 | +Sample command to build and push a new image: |
| 109 | + |
| 110 | +```bash |
| 111 | +bash build-and-push-cluster-health-check.sh \ |
| 112 | + -p ${PROJECT?} \ |
| 113 | + -r ${ARTIFACT_REPO?} \ |
| 114 | + -i "cluster-health-check" \ |
| 115 | + -l "us-east1" \ |
| 116 | + -v "0.0.3" |
| 117 | +``` |
0 commit comments