Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: 1.25.5
go-version: 1.26.2
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
test:
strategy:
matrix:
version: ['1.25.5' ]
version: ['1.26.2' ]
platform: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.cache/
.config/
vendor/
[._]*.sw[a-p]

Expand Down
2 changes: 1 addition & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ options:
substitution_option: ALLOW_LOOSE
machineType: E2_HIGHCPU_32
steps:
- name: gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20251110-7ccd542560 # Go 1.25
- name: gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20260205-38cfa9523f # Go 1.25
entrypoint: make
env:
- DRIVER_IMAGE_REGISTRY=us-central1-docker.pkg.dev/k8s-staging-images/dra-example-driver
Expand Down
15 changes: 13 additions & 2 deletions cmd/dra-example-kubeletplugin/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/apimachinery/pkg/types"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
coreclientset "k8s.io/client-go/kubernetes"
"k8s.io/dynamic-resource-allocation/api/metadata/v1alpha1"
"k8s.io/dynamic-resource-allocation/kubeletplugin"
"k8s.io/klog/v2"
)
Expand Down Expand Up @@ -56,6 +57,8 @@ func NewDriver(ctx context.Context, config *Config) (*driver, error) {
kubeletplugin.RegistrarDirectoryPath(config.flags.kubeletRegistrarDirectoryPath),
kubeletplugin.PluginDataDirectoryPath(config.DriverPluginPath()),
kubeletplugin.RollingUpdate(types.UID(config.flags.podUID)),
kubeletplugin.MetadataVersions(v1alpha1.SchemeGroupVersion),
kubeletplugin.EnableDeviceMetadata(config.flags.enableDeviceMetadata),
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -106,12 +109,20 @@ func (d *driver) prepareResourceClaim(ctx context.Context, claim *resourceapi.Re
}
var prepared []kubeletplugin.Device
for _, preparedPB := range preparedPBs {
prepared = append(prepared, kubeletplugin.Device{
dev := kubeletplugin.Device{
Requests: preparedPB.GetRequestNames(),
PoolName: preparedPB.GetPoolName(),
DeviceName: preparedPB.GetDeviceName(),
CDIDeviceIDs: preparedPB.GetCdiDeviceIds(),
})
}
if allocDev, ok := d.state.allocatable[preparedPB.GetDeviceName()]; ok && len(allocDev.Attributes) > 0 {
attrs := make(map[string]resourceapi.DeviceAttribute, len(allocDev.Attributes))
for k, v := range allocDev.Attributes {
attrs[string(k)] = v
}
dev.Metadata = &kubeletplugin.DeviceMetadata{Attributes: attrs}
}
prepared = append(prepared, dev)
}

logger.Info("Returning newly prepared devices for claim", "uid", claim.UID, "devices", prepared)
Expand Down
8 changes: 8 additions & 0 deletions cmd/dra-example-kubeletplugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type Flags struct {
profile string
driverName string
podUID string
enableDeviceMetadata bool
}

type Config struct {
Expand Down Expand Up @@ -154,6 +155,13 @@ func newApp() *cli.App {
Destination: &flags.podUID,
EnvVars: []string{"POD_UID"},
},
&cli.BoolFlag{
Name: "enable-device-metadata",
Usage: "Enable DRA in-container device metadata files for prepared devices.",
Value: false,
Destination: &flags.enableDeviceMetadata,
EnvVars: []string{"ENABLE_DEVICE_METADATA"},
},
}
cliFlags = append(cliFlags, flags.kubeClientConfig.Flags()...)
cliFlags = append(cliFlags, flags.loggingConfig.Flags()...)
Expand Down
2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

GOLANG_VERSION ?= 1.25.5
GOLANG_VERSION ?= 1.26.2

DRIVER_NAME := dra-example-driver
MODULE := sigs.k8s.io/$(DRIVER_NAME)
Expand Down
42 changes: 42 additions & 0 deletions demo/gpu-test10.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# One pod, one container
# Verifies in-container device metadata for directly referenced ResourceClaims (KEP-5304)

---
apiVersion: v1
kind: Namespace
metadata:
name: gpu-test10

---
apiVersion: resource.k8s.io/v1
kind: ResourceClaim
metadata:
namespace: gpu-test10
name: single-gpu
spec:
devices:
requests:
- name: gpu
exactly:
deviceClassName: gpu.example.com

---
apiVersion: v1
kind: Pod
metadata:
namespace: gpu-test10
name: pod0
labels:
app: pod
spec:
containers:
- name: ctr0
image: ubuntu:22.04
command: ["bash", "-c"]
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
resources:
claims:
- name: gpu
resourceClaims:
- name: gpu
resourceClaimName: single-gpu
43 changes: 43 additions & 0 deletions demo/gpu-test9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# One pod, one container
# Verifies in-container device metadata for ResourceClaimTemplate-based claims (KEP-5304)

---
apiVersion: v1
kind: Namespace
metadata:
name: gpu-test9

---
apiVersion: resource.k8s.io/v1
kind: ResourceClaimTemplate
metadata:
namespace: gpu-test9
name: single-gpu
spec:
spec:
devices:
requests:
- name: gpu
exactly:
deviceClassName: gpu.example.com

---
apiVersion: v1
kind: Pod
metadata:
namespace: gpu-test9
name: pod0
labels:
app: pod
spec:
containers:
- name: ctr0
image: ubuntu:22.04
command: ["bash", "-c"]
args: ["export; trap 'exit 0' TERM; sleep 9999 & wait"]
resources:
claims:
- name: gpu
resourceClaims:
- name: gpu
resourceClaimTemplateName: single-gpu
2 changes: 1 addition & 1 deletion demo/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SCRIPTS_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"

# The kubernetes tag to build the kind cluster from
# From ${KIND_K8S_REPO}/tags
: ${KIND_K8S_TAG:="v1.35.0"}
: ${KIND_K8S_TAG:="v1.36.0"}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1.36.0 is unavailable.

~ » skopeo list-tags docker://docker.io/kindest/node | jq '.Tags[-1]'                                          kiki@zhanxis-MacBook-Pro
"v1.35.1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could set BUILD_KIND_IMAGE based on whether $KIND_IMAGE exists instead of a static true/false.

# At present, kind has a new enough node image that we don't need to build our
# own. This won't always be true and we may need to set the variable below to
# 'true' from time to time as things change.
: ${BUILD_KIND_IMAGE:="false"}

I've noticed resource constraint issues with building the kind image from source in CI. Then we could refactor demo/scripts/build-kind-image.sh to allow building the image from release artifacts. We would need a way to pass --type release <version> here instead of a file path to the cloned repo:

${KIND} build node-image --image "${KIND_IMAGE}" "${KIND_K8S_DIR}"

A generic variable like KIND_BUILD_NODE_IMAGE_ARGS is probably good enough to handle a variety of use cases.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying this out in #188.


# At present, kind has a new enough node image that we don't need to build our
# own. This won't always be true and we may need to set the variable below to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.uid
{{- if .Values.kubeletPlugin.enableDeviceMetadata }}
- name: ENABLE_DEVICE_METADATA
value: {{ .Values.kubeletPlugin.enableDeviceMetadata | quote }}
{{- end }}
volumeMounts:
- name: plugins-registry
mountPath: {{ .Values.kubeletPlugin.kubeletRegistrarDirectoryPath | quote }}
Expand Down
1 change: 1 addition & 0 deletions deployments/helm/dra-example-driver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ kubeletPlugin:
affinity: {}
kubeletRegistrarDirectoryPath: /var/lib/kubelet/plugins_registry
kubeletPluginsDirectoryPath: /var/lib/kubelet/plugins
enableDeviceMetadata: false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update the e2e tests to enable and exercise this flag?

#153 refactors all of the e2e logic but I think that will merge soon, so you may want to hold off on that until that merges.

containers:
init:
securityContext: {}
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.devel
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ RUN go install github.com/gordonklaus/ineffassign@latest && \

RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.0
RUN go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.20.0
RUN go install k8s.io/code-generator/cmd/client-gen@v0.35.0
RUN go install k8s.io/code-generator/cmd/client-gen@v0.36.0
45 changes: 24 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
module sigs.k8s.io/dra-example-driver

go 1.25.0
go 1.26.0

require (
github.com/google/uuid v1.6.0
github.com/onsi/ginkgo/v2 v2.28.1
github.com/onsi/gomega v1.39.0
github.com/onsi/gomega v1.39.1
github.com/spf13/pflag v1.0.10
github.com/stretchr/testify v1.11.1
github.com/urfave/cli/v2 v2.27.7
google.golang.org/grpc v1.80.0
k8s.io/api v0.35.4
k8s.io/apimachinery v0.35.4
k8s.io/client-go v0.35.4
k8s.io/component-base v0.35.4
k8s.io/dynamic-resource-allocation v0.35.4
k8s.io/api v0.36.0
k8s.io/apimachinery v0.36.0
k8s.io/client-go v0.36.0
k8s.io/component-base v0.36.0
k8s.io/dynamic-resource-allocation v0.36.0
k8s.io/klog/v2 v2.140.0
k8s.io/kubelet v0.35.4
k8s.io/kubernetes v1.35.4
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
k8s.io/kubelet v0.36.0
k8s.io/kubernetes v1.36.0-rc.1
k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2
tags.cncf.io/container-device-interface v1.1.0
tags.cncf.io/container-device-interface/specs-go v1.1.0
)
Expand All @@ -30,7 +30,7 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
Expand All @@ -42,10 +42,12 @@ require (
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/moby/spdystream v0.5.1 // indirect
github.com/moby/sys/capability v0.4.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
Expand All @@ -55,17 +57,17 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/prometheus/common v0.67.5 // indirect
github.com/prometheus/procfs v0.19.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/cobra v1.10.0 // indirect
github.com/spf13/cobra v1.10.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.6.5 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.6.8 // indirect
go.opentelemetry.io/otel v1.41.0 // indirect
go.opentelemetry.io/otel/trace v1.41.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
go.uber.org/zap v1.27.1 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/mod v0.32.0 // indirect
Expand All @@ -75,16 +77,17 @@ require (
golang.org/x/sys v0.40.0 // indirect
golang.org/x/term v0.39.0 // indirect
golang.org/x/text v0.33.0 // indirect
golang.org/x/time v0.9.0 // indirect
golang.org/x/time v0.14.0 // indirect
golang.org/x/tools v0.41.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260120221211-b8f7ae30c516 // indirect
google.golang.org/protobuf v1.36.11 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a // indirect
k8s.io/streaming v0.36.0 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
Loading
Loading