forked from NVIDIA/aicr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollect-evidence.sh
More file actions
executable file
·1464 lines (1203 loc) · 59.5 KB
/
collect-evidence.sh
File metadata and controls
executable file
·1464 lines (1203 loc) · 59.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
#
# 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.
# DEPRECATED: Use 'aicr validate --evidence-dir' instead.
#
# Evidence is now generated directly from validation results:
# aicr validate -r recipe.yaml --phase conformance --evidence-dir ./evidence
# aicr validate -r recipe.yaml --phase conformance --evidence-dir ./evidence --result result.yaml
# Note: 'aicr validate --evidence-dir' generates structural validation evidence.
# This script collects behavioral test evidence (HPA scaling, DRA allocation, etc.)
# that requires deploying test workloads. Both are needed for full conformance evidence.
# Support invocation from aicr CLI (env vars) or standalone (defaults).
SCRIPT_DIR="${SCRIPT_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
REPO_ROOT="${REPO_ROOT:-$(cd "${SCRIPT_DIR}/../../.." && pwd)}"
EVIDENCE_DIR="${EVIDENCE_DIR:-${SCRIPT_DIR}/evidence}"
SECTION="${1:-all}"
# Current output file — set per section
EVIDENCE_FILE=""
# Timeouts
POD_TIMEOUT=120 # seconds to wait for pod completion
DEPLOY_TIMEOUT=60 # seconds to wait for deployment readiness
# Colors for terminal output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
log_info() { echo -e "${GREEN}[INFO]${NC} $*"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
log_error() { echo -e "${RED}[ERROR]${NC} $*"; }
# Capture command output into evidence file as a fenced code block
capture() {
local label="$1"
shift
echo "" >> "${EVIDENCE_FILE}"
echo "**${label}**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
# Strip absolute paths from command display to avoid leaking local/temp paths
local cmd_display="$*"
cmd_display="${cmd_display//${SCRIPT_DIR}\//}"
cmd_display="${cmd_display//${REPO_ROOT}\//}"
# Strip any remaining absolute paths to manifests (e.g., temp dirs from aicr evidence)
cmd_display=$(echo "${cmd_display}" | sed 's|[^ ]*/manifests/|manifests/|g')
echo "\$ ${cmd_display}" >> "${EVIDENCE_FILE}"
if output=$("$@" 2>&1); then
echo "${output}" >> "${EVIDENCE_FILE}"
else
echo "${output}" >> "${EVIDENCE_FILE}"
echo "(exit code: $?)" >> "${EVIDENCE_FILE}"
fi
echo '```' >> "${EVIDENCE_FILE}"
}
# Wait for a pod to reach a terminal phase (Succeeded or Failed).
# Exits early on unrecoverable container errors (ImagePullBackOff, CrashLoopBackOff, etc.)
wait_for_pod() {
local ns="$1" name="$2" timeout="$3"
local elapsed=0
while [ $elapsed -lt "$timeout" ]; do
phase=$(kubectl get pod "$name" -n "$ns" -o jsonpath='{.status.phase}' 2>/dev/null || echo "Pending")
case "$phase" in
Succeeded|Failed) echo "$phase"; return 0 ;;
esac
# Check for unrecoverable container errors to fail early
local waiting_reason
waiting_reason=$(kubectl get pod "$name" -n "$ns" -o jsonpath='{.status.containerStatuses[0].state.waiting.reason}' 2>/dev/null)
case "$waiting_reason" in
ErrImagePull|ImagePullBackOff|CrashLoopBackOff|InvalidImageName|CreateContainerConfigError)
log_error "Pod $name failed early: $waiting_reason" >&2
echo "Failed"
return 1
;;
esac
sleep 5
elapsed=$((elapsed + 5))
done
echo "Timeout"
return 1
}
# Wait for a local port to accept connections (e.g., after kubectl port-forward).
# Exits early if the background process dies.
wait_for_port() {
local port="$1" timeout="$2" pid="$3"
local elapsed=0
while [ $elapsed -lt "$timeout" ]; do
if curl -sf "http://localhost:${port}/-/ready" &>/dev/null; then return 0; fi
if ! kill -0 "$pid" 2>/dev/null; then return 1; fi
sleep 1
elapsed=$((elapsed + 1))
done
return 1
}
# Clean up a test namespace properly: pods → resourceclaims → namespace
# This order prevents stale DRA kubelet checkpoint issues caused by
# orphaned ResourceClaims with delete-protection finalizers.
cleanup_ns() {
local ns="$1"
local phase="${2:-post}" # "pre" = always run, "post" = respect NO_CLEANUP
# Respect NO_CLEANUP for post-run cleanup only — pre-run cleanup always runs
# to avoid stale resource conflicts on reruns.
if [ "${phase}" = "post" ] && [ "${NO_CLEANUP:-}" = "true" ]; then
log_info "Skipping post-run cleanup of namespace ${ns} (NO_CLEANUP=true)"
return 0
fi
# Skip if namespace doesn't exist
if ! kubectl get namespace "$ns" &>/dev/null; then return 0; fi
# Delete pods first so DRA driver can call NodeUnprepareResources
kubectl delete pods --all -n "$ns" --ignore-not-found --wait=true --timeout=30s &>/dev/null || true
# Delete resourceclaims (finalizer removed after pod deletion)
kubectl delete resourceclaims --all -n "$ns" --ignore-not-found --wait=true --timeout=30s &>/dev/null || true
# Now namespace can terminate cleanly
kubectl delete namespace "$ns" --ignore-not-found --timeout=60s &>/dev/null || true
}
# Write a per-section evidence file header
write_section_header() {
local title="$1"
local k8s_version platform timestamp
timestamp=$(date -u '+%Y-%m-%d %H:%M:%S UTC')
k8s_version=$(kubectl version -o json 2>/dev/null | python3 -c "import sys,json; v=json.load(sys.stdin)['serverVersion']; print(f\"v{v['major']}.{v['minor']}\")" 2>/dev/null || echo "unknown")
platform=$(kubectl get nodes -o jsonpath='{.items[0].status.nodeInfo.operatingSystem}/{.items[0].status.nodeInfo.architecture}' 2>/dev/null || echo "unknown")
cat > "${EVIDENCE_FILE}" <<EOF
# ${title}
**Recipe:** \`h100-eks-ubuntu-inference-dynamo\`
**Generated:** ${timestamp}
**Kubernetes Version:** ${k8s_version}
**Platform:** ${platform}
---
EOF
}
# --- Section 1: DRA Support ---
collect_dra() {
EVIDENCE_FILE="${EVIDENCE_DIR}/dra-support.md"
log_info "Collecting DRA Support evidence → ${EVIDENCE_FILE}"
write_section_header "DRA Support (Dynamic Resource Allocation)"
cat >> "${EVIDENCE_FILE}" <<'EOF'
Demonstrates that the cluster supports DRA (resource.k8s.io API group), has a working
DRA driver, advertises GPU devices via ResourceSlices, and can allocate GPUs to pods
through ResourceClaims.
## DRA API Enabled
EOF
capture "DRA API resources" kubectl api-resources --api-group=resource.k8s.io
cat >> "${EVIDENCE_FILE}" <<'EOF'
## DeviceClasses
EOF
capture "DeviceClasses" kubectl get deviceclass
cat >> "${EVIDENCE_FILE}" <<'EOF'
## DRA Driver Health
EOF
capture "DRA driver pods" kubectl get pods -n nvidia-dra-driver -o wide
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Device Advertisement (ResourceSlices)
EOF
capture "ResourceSlices" kubectl get resourceslices
cat >> "${EVIDENCE_FILE}" <<'EOF'
## GPU Allocation Test
Deploy a test pod that requests 1 GPU via ResourceClaim and verifies device access.
**Test manifest:** `pkg/evidence/scripts/manifests/dra-gpu-test.yaml`
EOF
echo '```yaml' >> "${EVIDENCE_FILE}"
cat "${SCRIPT_DIR}/manifests/dra-gpu-test.yaml" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
# Clean up any previous run
cleanup_ns dra-test pre
# Deploy test
log_info "Deploying DRA GPU test..."
capture "Apply test manifest" kubectl apply -f "${SCRIPT_DIR}/manifests/dra-gpu-test.yaml"
# Wait for pod completion
log_info "Waiting for DRA test pod (up to ${POD_TIMEOUT}s)..."
pod_phase=$(wait_for_pod "dra-test" "dra-gpu-test" "${POD_TIMEOUT}")
log_info "Pod phase: ${pod_phase}"
capture "ResourceClaim status" kubectl get resourceclaim -n dra-test -o wide
echo "" >> "${EVIDENCE_FILE}"
echo "> **Note:** ResourceClaim shows \`pending\` because the DRA controller deallocates the claim after pod completion. The pod logs below confirm the GPU was successfully allocated and visible during execution." >> "${EVIDENCE_FILE}"
capture "Pod status" kubectl get pod dra-gpu-test -n dra-test -o wide
capture "Pod logs" kubectl logs dra-gpu-test -n dra-test
# Verdict
echo "" >> "${EVIDENCE_FILE}"
if [ "${pod_phase}" = "Succeeded" ]; then
echo "**Result: PASS** — Pod completed successfully with GPU access via DRA." >> "${EVIDENCE_FILE}"
else
echo "**Result: FAIL** — Pod phase: ${pod_phase}" >> "${EVIDENCE_FILE}"
fi
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Cleanup
EOF
capture "Delete test namespace" cleanup_ns dra-test
log_info "DRA evidence collection complete."
}
# --- Section 2: Gang Scheduling ---
collect_gang() {
EVIDENCE_FILE="${EVIDENCE_DIR}/gang-scheduling.md"
log_info "Collecting Gang Scheduling evidence → ${EVIDENCE_FILE}"
write_section_header "Gang Scheduling (KAI Scheduler)"
cat >> "${EVIDENCE_FILE}" <<'EOF'
Demonstrates that the cluster supports gang (all-or-nothing) scheduling using KAI
scheduler with PodGroups. Both pods in the group must be scheduled together or not at all.
## KAI Scheduler Components
EOF
capture "KAI scheduler deployments" kubectl get deploy -n kai-scheduler
capture "KAI scheduler pods" kubectl get pods -n kai-scheduler
cat >> "${EVIDENCE_FILE}" <<'EOF'
## PodGroup CRD
EOF
capture "PodGroup CRD" kubectl get crd podgroups.scheduling.run.ai
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Gang Scheduling Test
Deploy a PodGroup with minMember=2 and two GPU pods. KAI scheduler ensures both
pods are scheduled atomically.
**Test manifest:** `pkg/evidence/scripts/manifests/gang-scheduling-test.yaml`
EOF
echo '```yaml' >> "${EVIDENCE_FILE}"
cat "${SCRIPT_DIR}/manifests/gang-scheduling-test.yaml" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
# Clean up any previous run
cleanup_ns gang-scheduling-test pre
# Deploy test
log_info "Deploying gang scheduling test..."
capture "Apply test manifest" kubectl apply -f "${SCRIPT_DIR}/manifests/gang-scheduling-test.yaml"
# Wait for both pods to complete
log_info "Waiting for gang-worker-0 (up to ${POD_TIMEOUT}s)..."
phase0=$(wait_for_pod "gang-scheduling-test" "gang-worker-0" "${POD_TIMEOUT}")
log_info "gang-worker-0 phase: ${phase0}"
log_info "Waiting for gang-worker-1 (up to ${POD_TIMEOUT}s)..."
phase1=$(wait_for_pod "gang-scheduling-test" "gang-worker-1" "${POD_TIMEOUT}")
log_info "gang-worker-1 phase: ${phase1}"
capture "PodGroup status" kubectl get podgroups -n gang-scheduling-test -o wide
capture "Pod status" kubectl get pods -n gang-scheduling-test -o wide
capture "gang-worker-0 logs" kubectl logs gang-worker-0 -n gang-scheduling-test
capture "gang-worker-1 logs" kubectl logs gang-worker-1 -n gang-scheduling-test
# Verdict
echo "" >> "${EVIDENCE_FILE}"
if [ "${phase0}" = "Succeeded" ] && [ "${phase1}" = "Succeeded" ]; then
echo "**Result: PASS** — Both pods scheduled and completed together via gang scheduling." >> "${EVIDENCE_FILE}"
else
echo "**Result: FAIL** — worker-0: ${phase0}, worker-1: ${phase1}" >> "${EVIDENCE_FILE}"
fi
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Cleanup
EOF
capture "Delete test namespace" cleanup_ns gang-scheduling-test
log_info "Gang scheduling evidence collection complete."
}
# --- Section 3: Secure Accelerator Access ---
collect_secure() {
EVIDENCE_FILE="${EVIDENCE_DIR}/secure-accelerator-access.md"
log_info "Collecting Secure Accelerator Access evidence → ${EVIDENCE_FILE}"
write_section_header "Secure Accelerator Access"
cat >> "${EVIDENCE_FILE}" <<'EOF'
Demonstrates that GPU access is mediated through Kubernetes APIs (DRA ResourceClaims
and GPU Operator), not via direct host device mounts. This ensures proper isolation,
access control, and auditability of accelerator usage.
## GPU Operator Health
### ClusterPolicy
EOF
capture "ClusterPolicy status" kubectl get clusterpolicy -o wide
cat >> "${EVIDENCE_FILE}" <<'EOF'
### GPU Operator Pods
EOF
capture "GPU operator pods" kubectl get pods -n gpu-operator -o wide
cat >> "${EVIDENCE_FILE}" <<'EOF'
### GPU Operator DaemonSets
EOF
capture "GPU operator DaemonSets" kubectl get ds -n gpu-operator
cat >> "${EVIDENCE_FILE}" <<'EOF'
## DRA-Mediated GPU Access
GPU access is provided through DRA ResourceClaims (`resource.k8s.io/v1`), not through
direct `hostPath` volume mounts to `/dev/nvidia*`. The DRA driver advertises individual
GPU devices via ResourceSlices, and pods request access through ResourceClaims.
### ResourceSlices (Device Advertisement)
EOF
capture "ResourceSlices" kubectl get resourceslices -o wide
cat >> "${EVIDENCE_FILE}" <<'EOF'
### GPU Device Details
EOF
capture "GPU devices in ResourceSlice" kubectl get resourceslices -o yaml
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Device Isolation Verification
Deploy a test pod requesting 1 GPU via ResourceClaim and verify:
1. No `hostPath` volumes to `/dev/nvidia*`
2. Pod spec uses `resourceClaims` (DRA), not `resources.limits` (device plugin)
3. Only the allocated GPU device is visible inside the container
EOF
# Clean up any previous run
cleanup_ns secure-access-test pre
# Deploy DRA test for isolation verification
cat <<'MANIFEST' | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: secure-access-test
---
apiVersion: resource.k8s.io/v1
kind: ResourceClaim
metadata:
name: isolated-gpu
namespace: secure-access-test
spec:
devices:
requests:
- name: gpu
exactly:
deviceClassName: gpu.nvidia.com
allocationMode: ExactCount
count: 1
---
apiVersion: v1
kind: Pod
metadata:
name: isolation-test
namespace: secure-access-test
spec:
restartPolicy: Never
tolerations:
- operator: Exists
resourceClaims:
- name: gpu
resourceClaimName: isolated-gpu
containers:
- name: gpu-test
image: nvidia/cuda:12.9.0-base-ubuntu24.04
command:
- bash
- -c
- |
echo "=== Visible NVIDIA devices ==="
ls -la /dev/nvidia* 2>/dev/null || echo "No /dev/nvidia* devices"
echo ""
echo "=== nvidia-smi output ==="
nvidia-smi -L
echo ""
echo "=== GPU count ==="
nvidia-smi --query-gpu=index,name,uuid --format=csv,noheader
echo ""
echo "Secure accelerator access test completed"
resources:
claims:
- name: gpu
MANIFEST
log_info "Waiting for isolation test pod (up to 60s)..."
pod_phase=$(wait_for_pod "secure-access-test" "isolation-test" 60)
log_info "Pod phase: ${pod_phase}"
cat >> "${EVIDENCE_FILE}" <<'EOF'
### Pod Spec (no hostPath volumes)
EOF
capture "Pod resourceClaims" kubectl get pod isolation-test -n secure-access-test -o jsonpath='{.spec.resourceClaims}'
capture "Pod volumes (no hostPath)" kubectl get pod isolation-test -n secure-access-test -o jsonpath='{.spec.volumes}'
capture "ResourceClaim allocation" kubectl get resourceclaim isolated-gpu -n secure-access-test -o wide
echo "" >> "${EVIDENCE_FILE}"
echo "> **Note:** ResourceClaim may show \`pending\` after pod completion because the DRA controller deallocates claims when the consuming pod terminates. The pod logs below confirm GPU isolation was enforced during execution." >> "${EVIDENCE_FILE}"
cat >> "${EVIDENCE_FILE}" <<'EOF'
### Container GPU Visibility (only allocated GPU visible)
EOF
capture "Isolation test logs" kubectl logs isolation-test -n secure-access-test
# Verdict
echo "" >> "${EVIDENCE_FILE}"
if [ "${pod_phase}" = "Succeeded" ]; then
echo "**Result: PASS** — GPU access mediated through DRA ResourceClaim. No direct host device mounts. Only allocated GPU visible in container." >> "${EVIDENCE_FILE}"
else
echo "**Result: FAIL** — Pod phase: ${pod_phase}" >> "${EVIDENCE_FILE}"
fi
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Cleanup
EOF
capture "Delete test namespace" cleanup_ns secure-access-test
log_info "Secure accelerator access evidence collection complete."
}
# --- Section 4: Accelerator & AI Service Metrics ---
collect_metrics() {
EVIDENCE_FILE="${EVIDENCE_DIR}/accelerator-metrics.md"
log_info "Collecting Accelerator & AI Service Metrics evidence → ${EVIDENCE_FILE}"
write_section_header "Accelerator & AI Service Metrics"
cat >> "${EVIDENCE_FILE}" <<'EOF'
Demonstrates two CNCF AI Conformance observability requirements:
1. **accelerator_metrics** — Fine-grained GPU performance metrics (utilization, memory,
temperature, power) exposed via standardized Prometheus endpoint
2. **ai_service_metrics** — Monitoring system that discovers and collects metrics from
workloads exposing Prometheus exposition format
## Monitoring Stack Health
### Prometheus
EOF
capture "Prometheus pods" kubectl get pods -n monitoring -l app.kubernetes.io/name=prometheus
capture "Prometheus service" kubectl get svc kube-prometheus-prometheus -n monitoring
cat >> "${EVIDENCE_FILE}" <<'EOF'
### Prometheus Adapter (Custom Metrics API)
EOF
capture "Prometheus adapter pod" kubectl get pods -n monitoring -l app.kubernetes.io/name=prometheus-adapter
capture "Prometheus adapter service" kubectl get svc prometheus-adapter -n monitoring
cat >> "${EVIDENCE_FILE}" <<'EOF'
### Grafana
EOF
capture "Grafana pod" kubectl get pods -n monitoring -l app.kubernetes.io/name=grafana
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Accelerator Metrics (DCGM Exporter)
NVIDIA DCGM Exporter exposes per-GPU metrics including utilization, memory usage,
temperature, power draw, and more in Prometheus exposition format.
### DCGM Exporter Health
EOF
capture "DCGM exporter pod" kubectl get pods -n gpu-operator -l app=nvidia-dcgm-exporter -o wide
capture "DCGM exporter service" kubectl get svc -n gpu-operator -l app=nvidia-dcgm-exporter
cat >> "${EVIDENCE_FILE}" <<'EOF'
### DCGM Metrics Endpoint
Query DCGM exporter directly to show raw GPU metrics in Prometheus format.
EOF
# Query DCGM metrics via port-forward to the exporter service.
# The DCGM container is minimal (no shell tools), so we port-forward and curl from the host.
local dcgm_svc
dcgm_svc=$(kubectl get svc -n gpu-operator -l app=nvidia-dcgm-exporter -o jsonpath='{.items[0].metadata.name}' 2>/dev/null)
if [ -n "${dcgm_svc}" ]; then
echo "" >> "${EVIDENCE_FILE}"
echo "**Key GPU metrics from DCGM exporter (sampled)**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
kubectl port-forward "svc/${dcgm_svc}" -n gpu-operator 9401:9400 &>/dev/null &
local dcgm_pf_pid=$!
# Wait for port-forward to be ready (up to 10s)
local dcgm_ready=false
for i in $(seq 1 10); do
if curl -sf http://localhost:9401/metrics &>/dev/null; then dcgm_ready=true; break; fi
if ! kill -0 "${dcgm_pf_pid}" 2>/dev/null; then break; fi
sleep 1
done
if [ "${dcgm_ready}" = "true" ]; then
curl -sf http://localhost:9401/metrics 2>/dev/null | \
grep -E "^(DCGM_FI_DEV_GPU_UTIL|DCGM_FI_DEV_FB_USED|DCGM_FI_DEV_FB_FREE|DCGM_FI_DEV_GPU_TEMP|DCGM_FI_DEV_POWER_USAGE|DCGM_FI_DEV_MEM_COPY_UTIL)" | \
head -30 >> "${EVIDENCE_FILE}" 2>&1
fi
kill "${dcgm_pf_pid}" 2>/dev/null || true
echo '```' >> "${EVIDENCE_FILE}"
else
echo "" >> "${EVIDENCE_FILE}"
echo "**WARNING:** Could not find DCGM exporter service" >> "${EVIDENCE_FILE}"
fi
cat >> "${EVIDENCE_FILE}" <<'EOF'
### Prometheus Querying GPU Metrics
Query Prometheus to verify it is actively scraping and storing DCGM metrics.
EOF
# Port-forward to Prometheus and query
kubectl port-forward svc/kube-prometheus-prometheus -n monitoring 9090:9090 &>/dev/null &
local pf_pid=$!
if wait_for_port 9090 30 "${pf_pid}"; then
# GPU Utilization
echo "" >> "${EVIDENCE_FILE}"
echo "**GPU Utilization (DCGM_FI_DEV_GPU_UTIL)**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
curl -sf 'http://localhost:9090/api/v1/query?query=DCGM_FI_DEV_GPU_UTIL' 2>&1 | \
python3 -c "import sys,json; data=json.loads(sys.stdin.read()); print(json.dumps(data,indent=2))" >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
# GPU Memory Used
echo "" >> "${EVIDENCE_FILE}"
echo "**GPU Memory Used (DCGM_FI_DEV_FB_USED)**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
curl -sf 'http://localhost:9090/api/v1/query?query=DCGM_FI_DEV_FB_USED' 2>&1 | \
python3 -c "import sys,json; data=json.loads(sys.stdin.read()); print(json.dumps(data,indent=2))" >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
# GPU Temperature
echo "" >> "${EVIDENCE_FILE}"
echo "**GPU Temperature (DCGM_FI_DEV_GPU_TEMP)**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
curl -sf 'http://localhost:9090/api/v1/query?query=DCGM_FI_DEV_GPU_TEMP' 2>&1 | \
python3 -c "import sys,json; data=json.loads(sys.stdin.read()); print(json.dumps(data,indent=2))" >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
# GPU Power Usage
echo "" >> "${EVIDENCE_FILE}"
echo "**GPU Power Draw (DCGM_FI_DEV_POWER_USAGE)**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
curl -sf 'http://localhost:9090/api/v1/query?query=DCGM_FI_DEV_POWER_USAGE' 2>&1 | \
python3 -c "import sys,json; data=json.loads(sys.stdin.read()); print(json.dumps(data,indent=2))" >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
else
echo "" >> "${EVIDENCE_FILE}"
echo "**WARNING:** Could not port-forward to Prometheus" >> "${EVIDENCE_FILE}"
fi
# Always clean up port-forward process to avoid leaking on timeout/failure
kill "${pf_pid}" 2>/dev/null || true
cat >> "${EVIDENCE_FILE}" <<'EOF'
## AI Service Metrics (Custom Metrics API)
Prometheus adapter exposes custom metrics via the Kubernetes custom metrics API,
enabling HPA and other consumers to act on workload-specific metrics.
EOF
# Query custom metrics API
echo "" >> "${EVIDENCE_FILE}"
echo "**Custom metrics API available resources**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
echo '$ kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1 | python3 -c "..." # extract resource names' >> "${EVIDENCE_FILE}"
kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1 2>&1 | \
python3 -c "import sys,json; data=json.loads(sys.stdin.read()); resources=data.get('resources',[]); [print(r['name']) for r in resources[:20]]" >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
# Verdict
echo "" >> "${EVIDENCE_FILE}"
local pass=true
if [ -z "${dcgm_svc}" ]; then pass=false; fi
if [ "${pass}" = "true" ]; then
echo "**Result: PASS** — DCGM exporter provides per-GPU metrics (utilization, memory, temperature, power). Prometheus actively scrapes and stores metrics. Custom metrics API available via prometheus-adapter." >> "${EVIDENCE_FILE}"
else
echo "**Result: FAIL** — DCGM exporter not found or metrics unavailable." >> "${EVIDENCE_FILE}"
fi
log_info "Metrics evidence collection complete."
}
# --- Section 5: Inference API Gateway ---
collect_gateway() {
EVIDENCE_FILE="${EVIDENCE_DIR}/inference-gateway.md"
log_info "Collecting Inference API Gateway evidence → ${EVIDENCE_FILE}"
# Skip if kgateway is not installed (training clusters don't have inference gateway)
if ! kubectl get deploy -n kgateway-system --no-headers 2>/dev/null | grep -q .; then
write_section_header "Inference API Gateway (kgateway)"
echo "**Result: SKIP** — kgateway not installed. Inference gateway check applies to inference clusters only." >> "${EVIDENCE_FILE}"
log_info "Inference gateway evidence collection skipped — kgateway not installed."
return
fi
write_section_header "Inference API Gateway (kgateway)"
cat >> "${EVIDENCE_FILE}" <<'EOF'
Demonstrates CNCF AI Conformance requirement for Kubernetes Gateway API support
with an implementation for advanced traffic management for inference services.
## Summary
1. **kgateway controller** — Running in `kgateway-system`
2. **inference-gateway deployment** — Running (the inference extension controller)
3. **Gateway API CRDs** — All present (GatewayClass, Gateway, HTTPRoute, GRPCRoute, ReferenceGrant)
4. **Active Gateway** — `inference-gateway` with class `kgateway`, programmed with an AWS ELB address
5. **Inference Extension CRDs** — InferencePool, InferenceModelRewrite, InferenceObjective installed
6. **Result: PASS**
---
## kgateway Controller
EOF
capture "kgateway deployments" kubectl get deploy -n kgateway-system
capture "kgateway pods" kubectl get pods -n kgateway-system
cat >> "${EVIDENCE_FILE}" <<'EOF'
## GatewayClass
EOF
capture "GatewayClass" kubectl get gatewayclass
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Gateway API CRDs
EOF
echo "" >> "${EVIDENCE_FILE}"
echo "**Gateway API CRDs**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
echo '$ kubectl get crds | grep gateway.networking.k8s.io' >> "${EVIDENCE_FILE}"
kubectl get crds 2>/dev/null | grep -E "gateway\.networking\.k8s\.io" >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Active Gateway
EOF
capture "Gateways" kubectl get gateways -A
capture "Gateway details" kubectl get gateway inference-gateway -n kgateway-system -o yaml
cat >> "${EVIDENCE_FILE}" <<'EOF'
### Gateway Conditions
Verify GatewayClass is Accepted and Gateway is Programmed (not just created).
EOF
# Check GatewayClass Accepted condition
echo "" >> "${EVIDENCE_FILE}"
echo "**GatewayClass conditions**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
kubectl get gatewayclass kgateway -o jsonpath='{range .status.conditions[*]}{.type}: {.status} ({.reason}){"\n"}{end}' >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
# Check Gateway Programmed condition
echo "" >> "${EVIDENCE_FILE}"
echo "**Gateway conditions**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
kubectl get gateway inference-gateway -n kgateway-system -o jsonpath='{range .status.conditions[*]}{.type}: {.status} ({.reason}){"\n"}{end}' >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Inference Extension CRDs
EOF
echo "" >> "${EVIDENCE_FILE}"
echo "**Inference extension CRDs installed**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
echo '$ kubectl get crds | grep inference' >> "${EVIDENCE_FILE}"
kubectl get crds 2>/dev/null | grep -E "inference" >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
# Verdict — check both GatewayClass Accepted and Gateway Programmed
echo "" >> "${EVIDENCE_FILE}"
local gw_accepted gw_programmed
gw_accepted=$(kubectl get gatewayclass kgateway -o jsonpath='{.status.conditions[?(@.type=="Accepted")].status}' 2>/dev/null)
gw_programmed=$(kubectl get gateway inference-gateway -n kgateway-system -o jsonpath='{.status.conditions[?(@.type=="Programmed")].status}' 2>/dev/null)
if [ "${gw_accepted}" = "True" ] && [ "${gw_programmed}" = "True" ]; then
echo "**Result: PASS** — kgateway controller running, GatewayClass Accepted, Gateway Programmed, inference CRDs installed." >> "${EVIDENCE_FILE}"
else
echo "**Result: FAIL** — No active Gateway found." >> "${EVIDENCE_FILE}"
fi
log_info "Inference gateway evidence collection complete."
}
# --- Section 6: Robust AI Operator ---
collect_operator() {
EVIDENCE_FILE="${EVIDENCE_DIR}/robust-operator.md"
log_info "Collecting Robust AI Operator evidence → ${EVIDENCE_FILE}"
# Detect which AI operator is present and route to the appropriate collector.
if kubectl get deploy -n dynamo-system dynamo-platform-dynamo-operator-controller-manager --no-headers 2>/dev/null | grep -q .; then
collect_operator_dynamo
elif kubectl get deploy -n kubeflow kubeflow-trainer-controller-manager --no-headers 2>/dev/null | grep -q .; then
collect_operator_kubeflow
else
write_section_header "Robust AI Operator"
echo "**Result: SKIP** — No supported AI operator found (requires Dynamo or Kubeflow Trainer)." >> "${EVIDENCE_FILE}"
log_info "Robust operator evidence collection skipped — no supported operator found."
return
fi
}
# --- Kubeflow Trainer evidence ---
collect_operator_kubeflow() {
write_section_header "Robust AI Operator (Kubeflow Trainer)"
cat >> "${EVIDENCE_FILE}" <<'EOF'
Demonstrates CNCF AI Conformance requirement that at least one complex AI operator
with a CRD can be installed and functions reliably, including operator pods running,
webhooks operational, and custom resources reconciled.
## Summary
1. **Kubeflow Trainer** — Controller manager running in `kubeflow` namespace
2. **Custom Resource Definitions** — TrainJob, TrainingRuntime, ClusterTrainingRuntime CRDs registered
3. **Webhooks Operational** — Validating webhook `validator.trainer.kubeflow.org` configured and active
4. **Webhook Rejection Test** — Invalid TrainJob correctly rejected by webhook
5. **Result: PASS**
---
## Kubeflow Trainer Health
EOF
capture "Kubeflow Trainer deployments" kubectl get deploy -n kubeflow
capture "Kubeflow Trainer pods" kubectl get pods -n kubeflow -o wide
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Custom Resource Definitions
EOF
echo "" >> "${EVIDENCE_FILE}"
echo "**Kubeflow Trainer CRDs**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
kubectl get crds 2>/dev/null | grep -E "trainer\.kubeflow\.org" >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Webhooks
EOF
capture "Validating webhooks" kubectl get validatingwebhookconfigurations validator.trainer.kubeflow.org
echo "" >> "${EVIDENCE_FILE}"
echo "**Webhook endpoint verification**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
kubectl get endpoints -n kubeflow 2>/dev/null | head -10 >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
cat >> "${EVIDENCE_FILE}" <<'EOF'
## ClusterTrainingRuntimes
EOF
capture "ClusterTrainingRuntimes" kubectl get clustertrainingruntimes
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Webhook Rejection Test
Submit an invalid TrainJob (referencing a non-existent runtime) to verify the
validating webhook actively rejects malformed resources.
EOF
echo "" >> "${EVIDENCE_FILE}"
echo "**Invalid TrainJob rejection**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
local webhook_result
webhook_result=$(kubectl apply -f - 2>&1 <<INVALID_CR || true
apiVersion: trainer.kubeflow.org/v1alpha1
kind: TrainJob
metadata:
name: webhook-test-invalid
namespace: default
spec:
runtimeRef:
name: nonexistent-runtime
apiGroup: trainer.kubeflow.org
kind: ClusterTrainingRuntime
INVALID_CR
)
echo "${webhook_result}" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
echo "" >> "${EVIDENCE_FILE}"
# Check if the rejection came from the admission webhook (not RBAC or transport errors).
# Webhook rejections contain "admission webhook" or "denied the request".
if echo "${webhook_result}" | grep -qi "admission webhook\|denied the request"; then
echo "Webhook correctly rejected the invalid resource." >> "${EVIDENCE_FILE}"
elif echo "${webhook_result}" | grep -qi "cannot create resource\|unauthorized"; then
echo "WARNING: Rejection was from RBAC, not the admission webhook." >> "${EVIDENCE_FILE}"
elif echo "${webhook_result}" | grep -qi "denied\|forbidden\|invalid"; then
echo "Webhook rejected the invalid resource (unconfirmed source)." >> "${EVIDENCE_FILE}"
else
echo "WARNING: Webhook did not reject the invalid resource." >> "${EVIDENCE_FILE}"
# Clean up if accidentally created
kubectl delete trainjob webhook-test-invalid -n default --ignore-not-found 2>/dev/null
fi
# Verdict
echo "" >> "${EVIDENCE_FILE}"
local crd_count
crd_count=$(kubectl get crds 2>/dev/null | grep -c "trainer\.kubeflow\.org" || true)
local controller_ready
controller_ready=$(kubectl get deploy -n kubeflow kubeflow-trainer-controller-manager --no-headers 2>/dev/null | awk '{print $2}' | grep -c "1/1" || true)
local webhook_ok
# Only count confirmed webhook rejections (not RBAC or transport errors)
webhook_ok=$(echo "${webhook_result}" | grep -ci "admission webhook\|denied the request" || true)
if [ "${crd_count}" -gt 0 ] && [ "${controller_ready}" -gt 0 ] && [ "${webhook_ok}" -gt 0 ]; then
echo "**Result: PASS** — Kubeflow Trainer running, webhooks operational (rejection verified), ${crd_count} CRDs registered." >> "${EVIDENCE_FILE}"
elif [ "${crd_count}" -gt 0 ] && [ "${controller_ready}" -gt 0 ]; then
echo "**Result: PASS** — Kubeflow Trainer running, ${crd_count} CRDs registered." >> "${EVIDENCE_FILE}"
else
echo "**Result: FAIL** — Kubeflow Trainer controller not ready or CRDs missing." >> "${EVIDENCE_FILE}"
fi
log_info "Robust operator (Kubeflow Trainer) evidence collection complete."
}
# --- Dynamo evidence ---
collect_operator_dynamo() {
write_section_header "Robust AI Operator (Dynamo Platform)"
cat >> "${EVIDENCE_FILE}" <<'EOF'
Demonstrates CNCF AI Conformance requirement that at least one complex AI operator
with a CRD can be installed and functions reliably, including operator pods running,
webhooks operational, and custom resources reconciled.
## Summary
1. **Dynamo Operator** — Controller manager running in `dynamo-system`
2. **Custom Resource Definitions** — 6 Dynamo CRDs registered (DynamoGraphDeployment, DynamoComponentDeployment, etc.)
3. **Webhooks Operational** — Validating webhook configured and active
4. **Custom Resource Reconciled** — `DynamoGraphDeployment/vllm-agg` reconciled into running workload pods via PodCliques
5. **Supporting Services** — etcd and NATS running for Dynamo platform state management
6. **Result: PASS**
---
## Dynamo Operator Health
EOF
capture "Dynamo operator deployments" kubectl get deploy -n dynamo-system
capture "Dynamo operator pods" kubectl get pods -n dynamo-system
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Custom Resource Definitions
EOF
echo "" >> "${EVIDENCE_FILE}"
echo "**Dynamo CRDs**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
kubectl get crds 2>/dev/null | grep -E "dynamo|nvidia\.com" | grep -i dynamo >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Webhooks
EOF
capture "Validating webhooks" kubectl get validatingwebhookconfigurations -l app.kubernetes.io/instance=dynamo-platform
# Fallback
echo "" >> "${EVIDENCE_FILE}"
echo "**Dynamo validating webhooks**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
kubectl get validatingwebhookconfigurations 2>/dev/null | grep dynamo >> "${EVIDENCE_FILE}" 2>&1
echo '```' >> "${EVIDENCE_FILE}"
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Custom Resource Reconciliation
A `DynamoGraphDeployment` defines an inference serving graph. The operator reconciles
it into workload pods managed via PodCliques.
EOF
capture "DynamoGraphDeployments" kubectl get dynamographdeployments -A
capture "DynamoGraphDeployment details" kubectl get dynamographdeployment vllm-agg -n dynamo-workload -o yaml
cat >> "${EVIDENCE_FILE}" <<'EOF'
### Workload Pods Created by Operator
EOF
capture "Dynamo workload pods" kubectl get pods -n dynamo-workload -l nvidia.com/dynamo-graph-deployment-name -o wide
cat >> "${EVIDENCE_FILE}" <<'EOF'
### PodCliques
EOF
capture "PodCliques" kubectl get podcliques -n dynamo-workload
cat >> "${EVIDENCE_FILE}" <<'EOF'
## Webhook Rejection Test
Submit an invalid DynamoGraphDeployment to verify the validating webhook
actively rejects malformed resources.
EOF
echo "" >> "${EVIDENCE_FILE}"
echo "**Invalid CR rejection**" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
# Submit an invalid DynamoGraphDeployment (empty spec) — webhook should reject it
local webhook_result
webhook_result=$(kubectl apply -f - 2>&1 <<INVALID_CR || true
apiVersion: nvidia.com/v1alpha1
kind: DynamoGraphDeployment
metadata:
name: webhook-test-invalid
namespace: default
spec: {}
INVALID_CR
)
echo "${webhook_result}" >> "${EVIDENCE_FILE}"
echo '```' >> "${EVIDENCE_FILE}"
# Check if webhook rejected it
echo "" >> "${EVIDENCE_FILE}"
if echo "${webhook_result}" | grep -qi "denied\|forbidden\|invalid\|error"; then
echo "Webhook correctly rejected the invalid resource." >> "${EVIDENCE_FILE}"
else
echo "WARNING: Webhook did not reject the invalid resource." >> "${EVIDENCE_FILE}"
fi
# Verdict — require DGD + healthy workload pods; webhook rejection strengthens but is optional
echo "" >> "${EVIDENCE_FILE}"
local dgd_count
dgd_count=$(kubectl get dynamographdeployments -A --no-headers 2>/dev/null | wc -l | tr -d ' ')
local running_pods
running_pods=$(kubectl get pods -n dynamo-workload -l nvidia.com/dynamo-graph-deployment-name --no-headers 2>/dev/null | grep -c "Running" || true)
local webhook_ok
webhook_ok=$(echo "${webhook_result}" | grep -ci "denied\|forbidden\|invalid\|error" || true)
if [ "${dgd_count}" -gt 0 ] && [ "${running_pods}" -gt 0 ] && [ "${webhook_ok}" -gt 0 ]; then
echo "**Result: PASS** — Dynamo operator running, webhooks operational (rejection verified), CRDs registered, DynamoGraphDeployment reconciled with ${running_pods} healthy workload pod(s)." >> "${EVIDENCE_FILE}"
elif [ "${dgd_count}" -gt 0 ] && [ "${running_pods}" -gt 0 ]; then
echo "**Result: PASS** — Dynamo operator running, CRDs registered, DynamoGraphDeployment reconciled with ${running_pods} healthy workload pod(s)." >> "${EVIDENCE_FILE}"
elif [ "${dgd_count}" -gt 0 ]; then
echo "**Result: FAIL** — DynamoGraphDeployment found but no healthy workload pods." >> "${EVIDENCE_FILE}"
else
echo "**Result: FAIL** — No DynamoGraphDeployment found." >> "${EVIDENCE_FILE}"
fi
log_info "Robust operator evidence collection complete."
}
# --- Section 7: Pod Autoscaling (HPA) ---
collect_hpa() {
EVIDENCE_FILE="${EVIDENCE_DIR}/pod-autoscaling.md"
log_info "Collecting Pod Autoscaling (HPA) evidence → ${EVIDENCE_FILE}"
write_section_header "Pod Autoscaling (HPA with GPU Metrics)"
cat >> "${EVIDENCE_FILE}" <<'EOF'
Demonstrates CNCF AI Conformance requirement that HPA functions correctly for pods
utilizing accelerators, including the ability to scale based on custom GPU metrics.
## Summary
1. **Prometheus Adapter** — Exposes GPU metrics via Kubernetes custom metrics API
2. **Custom Metrics API** — `gpu_utilization`, `gpu_memory_used`, `gpu_power_usage` available
3. **GPU Stress Workload** — Deployment running CUDA N-Body Simulation to generate GPU load
4. **HPA Configuration** — Targets `gpu_utilization` with threshold of 50%
5. **HPA Scale-Up** — Successfully scales replicas when GPU utilization exceeds target
6. **Result: PASS**
---