DRA kubelet: separate beta and alpha gRPC APIs

Reusing types from the alpha in the beta made it possible to provide and use
both versions without conversion. The downside was that removal of the alpha
would have been harder, if not impossible. DRA drivers could continue to
use the alpha types and provided the beta interface automatically.

Now the two versions are completely separate gRPC APIs, although in practice
there are no differences besides the name. Support for the alpha API in kubelet
is provided via automatically generated conversion and manually written
interface wrappers.

Those are provided as part of the v1alpha4 package. The advantage of having all
of that in a central place is that it'll be easier to remove when no longer
needed.
This commit is contained in:
Patrick Ohly
2024-11-07 07:38:10 +01:00
parent e273349f3a
commit 9261a182bb
10 changed files with 2924 additions and 84 deletions

View File

@@ -39,6 +39,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/dynamic-resource-allocation/kubeletplugin"
"k8s.io/klog/v2"
drapbv1alpha4 "k8s.io/kubelet/pkg/apis/dra/v1alpha4"
drapb "k8s.io/kubelet/pkg/apis/dra/v1beta1"
)
@@ -165,7 +166,15 @@ func StartPlugin(ctx context.Context, cdiDir, driverName string, kubeClient kube
kubeletplugin.GRPCInterceptor(ex.recordGRPCCall),
kubeletplugin.GRPCStreamInterceptor(ex.recordGRPCStream),
)
d, err := kubeletplugin.Start(ctx, ex, opts...)
// Both APIs get provided, the legacy one via wrapping. The options
// determine which one(s) really get served (by default, both).
// The options are a bit redundant now because a single instance cannot
// implement both, but that might be different in the future.
nodeServers := []any{
drapb.DRAPluginServer(ex), // Casting is done only for clarity here, it's not needed.
drapbv1alpha4.V1Beta1ServerWrapper{DRAPluginServer: ex},
}
d, err := kubeletplugin.Start(ctx, nodeServers, opts...)
if err != nil {
return nil, fmt.Errorf("start kubelet plugin: %w", err)
}