kubernetes: trim client-go dependency surface#3707
kubernetes: trim client-go dependency surface#3707AkihiroSuda merged 3 commits intodocker:masterfrom
Conversation
Replace the full generated clientset and global Kubernetes scheme with a small local REST client layer and minimal scheme registration. This keeps the existing kubeconfig/auth and remote exec behavior while significantly reducing the linked and vendored Kubernetes dependency set. Signed-off-by: Tonis Tiigi <[email protected]>
Use sync.OnceValue to initialize the kubeclient scheme, codec factory, and parameter codec as a single lazy-loaded bundle. Signed-off-by: Tonis Tiigi <[email protected]>
Drops the gogo-proto XXX_* methods. Signed-off-by: Tonis Tiigi <[email protected]>
| TTY: false, | ||
| }, scheme.ParameterCodec) | ||
| }, kubeclient.ParameterCodec()) | ||
| exec, err := remotecommand.NewSPDYExecutor(restConfig, "POST", req.URL()) |
There was a problem hiding this comment.
@AkihiroSuda Iiuc we could also replace this spdy dependency with kubernetes/enhancements#4006 . Seems that would require k8s 1.31+ . When do you think we could do that?
There was a problem hiding this comment.
Some EKS users are still using 1.29 and 1.30, until 23 Jul 2026
https://endoflife.date/amazon-eks
There was a problem hiding this comment.
AKS 1.30 until 31 Jul 2026
https://endoflife.date/azure-kubernetes-service
| k8s.io/client-go v0.34.1 | ||
| k8s.io/api v0.35.2 | ||
| k8s.io/apimachinery v0.35.2 | ||
| k8s.io/client-go v0.35.2 |
There was a problem hiding this comment.
Alternatively you can just exec kubectl to significantly reduce the binary footprint and Go dependencies.
14M → 6.1M, in the case of Lima:
There was a problem hiding this comment.
I think I'd prefer to avoid the extra dependency for buildx users.
There was a problem hiding this comment.
I guess it is safe to assume that the users of the buildx kubernetes driver should have already kubectl installed
There was a problem hiding this comment.
I'm not so sure about it. I think it is messier to manage flag parsing and output reads, and I'm not sure how stable the CLI is, even if it is considered.
Replace the full generated clientset and global Kubernetes scheme with a small local REST client layer and minimal scheme registration.
This keeps the existing kubeconfig/auth and remote exec behavior while significantly reducing the linked and vendored Kubernetes dependency set.