Repository navigation
feat(registry): add kubernetes registry plugin - #5073
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@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 onmaster(for example run 45130231034 onb65720e0b, the base of this PR). Everything this PR changes passes: theregistry/kubernetes/...andcmd/defaultstests 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: thegithub.com/micro/plugins/v5/registry/kubernetesplugin, ported with import path changes only. No new dependencies; it uses its own small Kubernetes API client rather thanclient-go.init()tocmd/defaults, like the other in-repo registries, so--registry kubernetesworks with thecmd/defaultsimport.client/api: closes the response body on 404 and other error responses. Before, every failed call to the Kubernetes API leaked a connection, becauseDecodereturns before closing on an error. This was caught by the blockingbodycloselint.docs/plugins.md, with the plugin README updated for v6.Compatibility
Labels, annotation keys and the JSON annotation format are unchanged.
TestGetServiceDecodesV5Annotationdecodes the exact bytes a v5.20.0 service writes, so v5 and v6 services discover each other during a rolling upgrade.Tests
cmd/defaultsregistration.go test -race ./registry/kubernetes/... ./cmd/defaults/passes.golangci-lintv2.14.0 on Go 1.26.11 reports 0 issues.go test ./cmd/...fails only incmd/micro/chat(TestStreamedReferenceLinks), which fails the same way onmaster.