Skip to content

Commit fe08e3a

Browse files
committed
Add node env variable and revert cri-api to v1alpha2
Signed-off-by: ghokun <[email protected]>
1 parent 3ef0082 commit fe08e3a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

manifests/device-plugin.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ spec:
4545
capabilities:
4646
add: ["SYS_ADMIN"]
4747
containers:
48-
- image: ghcr.io/kuartis/kuartis-virtual-gpu-device-plugin:0.4.1
48+
- image: ghcr.io/kuartis/kuartis-virtual-gpu-device-plugin:0.4.2
4949
name: kuartis-virtual-gpu-device-plugin-ctr
5050
command:
5151
- /usr/bin/virtual-gpu-device-plugin
@@ -55,6 +55,11 @@ spec:
5555
allowPrivilegeEscalation: false
5656
capabilities:
5757
drop: ["ALL"]
58+
env:
59+
- name: NODE_NAME
60+
valueFrom:
61+
fieldRef:
62+
fieldPath: spec.nodeName
5863
ports:
5964
- containerPort: 8080
6065
name: metrics

pkg/gpu/nvidia/metrics.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ import (
1616

1717
"google.golang.org/grpc"
1818
"google.golang.org/grpc/credentials/insecure"
19-
pb "k8s.io/cri-api/pkg/apis/runtime/v1"
19+
pb "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
2020
)
2121

2222
const (
2323
containerdsocket = "/var/run/containerd/containerd.sock"
2424
timeout = 10 * time.Second
2525
)
2626

27+
var node = os.Getenv("NODE_NAME")
28+
2729
var metricsFormat = `
2830
# HELP container_per_gpu
2931
# TYPE container_per_gpu gauge
@@ -75,7 +77,7 @@ func collectMetrics(w http.ResponseWriter, r *http.Request) {
7577
containerMap := make(map[string]containerInfo)
7678
for _, container := range containers.GetContainers() {
7779
containerMap[container.Id] = containerInfo{
78-
Node: "",
80+
Node: node,
7981
Namespace: container.Labels["io.kubernetes.pod.namespace"],
8082
Pod: container.Labels["io.kubernetes.pod.name"],
8183
PodUid: container.Labels["io.kubernetes.pod.uid"],

0 commit comments

Comments
 (0)