Skip to content

kubernetes: trim client-go dependency surface#3707

Merged
AkihiroSuda merged 3 commits intodocker:masterfrom
tonistiigi:k8s-trim
Mar 8, 2026
Merged

kubernetes: trim client-go dependency surface#3707
AkihiroSuda merged 3 commits intodocker:masterfrom
tonistiigi:k8s-trim

Conversation

@tonistiigi
Copy link
Member

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.

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]>
@tonistiigi tonistiigi marked this pull request as ready for review March 7, 2026 01:24
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())
Copy link
Member Author

Choose a reason for hiding this comment

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

@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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Some EKS users are still using 1.29 and 1.30, until 23 Jul 2026
https://endoflife.date/amazon-eks

Copy link
Collaborator

Choose a reason for hiding this comment

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

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Alternatively you can just exec kubectl to significantly reduce the binary footprint and Go dependencies.

14M → 6.1M, in the case of Lima:

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I'd prefer to avoid the extra dependency for buildx users.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess it is safe to assume that the users of the buildx kubernetes driver should have already kubectl installed

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

@AkihiroSuda AkihiroSuda merged commit 9e632b4 into docker:master Mar 8, 2026
243 of 244 checks passed
@crazy-max crazy-max added this to the v0.33.0 milestone Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants