Skip to content

Update DRA APIs to v1 #115

@nojnhuh

Description

@nojnhuh

Kubernetes 1.34 introduces the resource.k8s.io/v1 version for the DRA APIs. The example driver should demonstrate how to implement and use the latest and greatest API. These are the rough steps to do that:

  1. Update all of the k8s.io dependencies to the latest 1.34 pre-release version (currently v1.34.0-rc.1). See Bump k8s.io dependencies to 1.33 #95 for an example (which also includes some changes specific to that upgrade that won't apply here).

  2. Importing the new k8s.io dependencies will require updating the driver itself to operate against the new API version. Imports like this should all be updated to use v1 instead of v1beta1:

    resourceapi "k8s.io/api/resource/v1beta1"

  3. Update the validating webhook to use v1:

    resourceapi "k8s.io/api/resource/v1beta1"

  4. Update the kind config to remove the config enabling API versions and the feature gate. The v1 API and the DRA feature gate are enabled by default and I think it's valuable to exercise that.

  5. Update YAML manifests to the new version, e.g. in examples, the Helm chart, and sample output.

  6. Call out the new minimum required Kubernetes version in the Helm chart as 1.34:

The differences between the APIs are fairly straightforward, e.g. from kubernetes/kubernetes@5c4f817:

  • ResourceSlice no longer contains the basic level of indirection:
    diff --git a/staging/src/k8s.io/dynamic-resource-allocation/structured/internal/allocatortesting/allocator_testing.go b/staging/src/k8s.io/dynamic-resource-allocation/structured/internal/allocatortesting/allocator_testing.go
    index ebd22fc217eeb..3d8c81b1fde01 100644
    --- a/staging/src/k8s.io/dynamic-resource-allocation/structured/internal/allocatortesting/allocator_testing.go
    +++ b/staging/src/k8s.io/dynamic-resource-allocation/structured/internal/allocatortesting/allocator_testing.go
    @@ -257,16 +259,14 @@ const (
     // generate a Device object with the given name, capacity and attributes.
     func device(name string, capacity any, attributes map[resourceapi.QualifiedName]resourceapi.DeviceAttribute) wrapDevice {
      device := resourceapi.Device{
    -		Name: name,
    -		Basic: &resourceapi.BasicDevice{
    -			Attributes: attributes,
    -		},
    +		Name:       name,
    +		Attributes: attributes,
      }
  • ResourceClaims now have an additional exactly level of indirection:
    diff --git a/test/e2e/dra/test-driver/deploy/example/pod-inline-multiple.yaml b/test/e2e/dra/test-driver/deploy/example/pod-inline-multiple.yaml
    index 520935c59265a..59cd7b63b59f5 100644
    --- a/test/e2e/dra/test-driver/deploy/example/pod-inline-multiple.yaml
    +++ b/test/e2e/dra/test-driver/deploy/example/pod-inline-multiple.yaml
    @@ -1,4 +1,4 @@
    -apiVersion: resource.k8s.io/v1beta1
    +apiVersion: resource.k8s.io/v1
     kind: ResourceClaimTemplate
     metadata:
       name: pause-template
    @@ -11,7 +11,8 @@ spec:
         devices:
           requests:
           - name: my-device
    -        deviceClassName: example
    +        exactly:
    +          deviceClassName: example
           config:
           - opaque:
               driver: test-driver.cdi.k8s.io

For reference, the v1beta2 APIs are documented here, which are equivalent to v1: https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/

/assign @alimaazamat

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions