Skip to content

Commit 1193ff1

Browse files
committed
DRA driver: optionally support kubelet 1.31
Supporting the alpha gRPC interface isn't enough anymore to be compatible with kubelet 1.31: the "supported versions" must contain version numbers, otherwise the older kubelet refuses to register the driver. With this change, a DRA driver can decide to support both kubelet 1.31 and kubelet 1.32 by registering *only* the alpha gRPC interface (NodeV1alpha4(true) and NodeV1beta1(false) as options for Start). The default is to provide both interfaces and using the registration mechanism for 1.32, which makes DRA drivers compatible only with Kubernetes >= 1.32.
1 parent 2c23fe1 commit 1193ff1

File tree

1 file changed

+15
-0
lines changed
  • staging/src/k8s.io/dynamic-resource-allocation/kubeletplugin

1 file changed

+15
-0
lines changed

staging/src/k8s.io/dynamic-resource-allocation/kubeletplugin/draplugin.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ type draPlugin struct {
271271
//
272272
// If the plugin will be used to publish resources, [KubeClient] and [NodeName]
273273
// options are mandatory.
274+
//
275+
// By default, the DRA driver gets registered so that the plugin is compatible
276+
// with Kubernetes >= 1.32. To be compatible with Kubernetes >= 1.31, a driver
277+
// has to ask specifically to register only the alpha gRPC API, i.e. use:
278+
//
279+
// Start(..., NodeV1beta1(false))
274280
func Start(ctx context.Context, nodeServer interface{}, opts ...Option) (result DRAPlugin, finalErr error) {
275281
logger := klog.FromContext(ctx)
276282
o := options{
@@ -351,6 +357,15 @@ func Start(ctx context.Context, nodeServer interface{}, opts ...Option) (result
351357
return nil, errors.New("no supported DRA gRPC API is implemented and enabled")
352358
}
353359

360+
// Backwards compatibility hack: if only the alpha gRPC service is enabled,
361+
// then we can support registration against a 1.31 kubelet by reporting "1.0.0"
362+
// as version. That also works with 1.32 because 1.32 supports that legacy
363+
// behavior and 1.31 works because it doesn't fail while parsing "v1alpha3.Node"
364+
// as version.
365+
if len(supportedServices) == 1 && supportedServices[0] == drapbv1alpha4.NodeService {
366+
supportedServices = []string{"1.0.0"}
367+
}
368+
354369
// Now make it available to kubelet.
355370
registrar, err := startRegistrar(klog.NewContext(ctx, klog.LoggerWithName(logger, "registrar")), o.grpcVerbosity, o.unaryInterceptors, o.streamInterceptors, o.driverName, supportedServices, o.draAddress, o.pluginRegistrationEndpoint)
356371
if err != nil {

0 commit comments

Comments
 (0)