Skip to content

feat(registry): add kubernetes registry plugin - #5073

Merged
asim merged 1 commit into
micro:masterfrom
jejefferson:feat/registry-kubernetes
Nov 23, 2026
Merged

asim merged 1 commit into
micro:masterfrom
jejefferson:feat/registry-kubernetes

Conversation

@jejefferson

@jejefferson jejefferson commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

@asim the only failing check is Unit Tests, in cmd/micro/chat (TestStreamedReferenceLinks), which is not touched by this PR. It fails the same way on master (for example run 45130231034 on b65720e0b, the base of this PR). Everything this PR changes passes: the registry/kubernetes/... and cmd/defaults tests in the same run, plus golangci-lint, build, etcd integration and end-to-end.


Brings the Kubernetes registry into core, the same way #2755 brought consul, etcd, mdns and nats. Discussion: #5074.

What

  • registry/kubernetes: the github.com/micro/plugins/v5/registry/kubernetes plugin, ported with import path changes only. No new dependencies; it uses its own small Kubernetes API client rather than client-go.
  • Registration moved from the plugin's init() to cmd/defaults, like the other in-repo registries, so --registry kubernetes works with the cmd/defaults import.
  • client/api: closes the response body on 404 and other error responses. Before, every failed call to the Kubernetes API leaked a connection, because Decode returns before closing on an error. This was caught by the blocking bodyclose lint.
  • Docs: added to docs/plugins.md, with the plugin README updated for v6.

Compatibility

Labels, annotation keys and the JSON annotation format are unchanged. TestGetServiceDecodesV5Annotation decodes the exact bytes a v5.20.0 service writes, so v5 and v6 services discover each other during a rolling upgrade.

Tests

  • Existing plugin tests pass unchanged.
  • New tests: decoding a v5 annotation, skipping pending and terminating pods, not-found and malformed annotations, label key sanitizing, register and deregister errors, out-of-cluster construction, closing the body on error responses, and the cmd/defaults registration.
  • go test -race ./registry/kubernetes/... ./cmd/defaults/ passes. golangci-lint v2.14.0 on Go 1.26.11 reports 0 issues.
  • go test ./cmd/... fails only in cmd/micro/chat (TestStreamedReferenceLinks), which fails the same way on master.

Port github.com/micro/plugins/v5/registry/kubernetes into core as
go-micro.dev/v6/registry/kubernetes, the same way micro#2755 brought the
other registries in. Only import paths change; the pod labels,
annotation keys and annotation JSON stay compatible with v5, so v5 and
v6 services discover each other during an upgrade.

Register it from cmd/defaults instead of the plugin's init().

Close the response body on non-2xx responses from the Kubernetes API.
Decode returns before closing on an error, so every failed call leaked
a connection.
@asim
asim merged commit 018efdc into micro:master Nov 23, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants