Fall back to identity AuditTokenRequest API when appscode.com is unreachable#69
Merged
Merged
Conversation
Splits the registration call out of NatsClient.connect so the lib can try the public appscode.com Register endpoint first and, if that fails with a no-connectivity error (DNS failure, connection refused, timeout, network unreachable), retry the same registration via the in-cluster identity.k8s.appscode.com NatsCredentialRequest extended API. Auth/4xx/5xx responses from appscode.com still propagate unchanged. Vendor bump is hand-applied and will be replaced by a normal go mod vendor once the resource-metadata change lands. Signed-off-by: Tamal Saha <tamal@appscode.com>
Replaces the hand-rolled http.Post with identitylib.Client.GetNatsCredentialForCluster so the wire format and TLS handling live in one place. Drops the now-unused verifier.Options / json / bytes / io / http imports. Signed-off-by: Tamal Saha <tamal@appscode.com>
Signed-off-by: Tamal Saha <tamal@appscode.com>
Drops the throwaway Client construction; the function now takes the http client / baseURL / token explicitly, so audit can pass the defaults inline. Signed-off-by: Tamal Saha <tamal@appscode.com>
This reverts commit f879232. Signed-off-by: Tamal Saha <tamal@appscode.com>
Drops the four nil/empty arguments at the call site. Signed-off-by: Tamal Saha <tamal@appscode.com>
Signed-off-by: Tamal Saha <tamal@appscode.com>
Signed-off-by: Tamal Saha <tamal@appscode.com>
8dbba01 to
c241c8b
Compare
Signed-off-by: Tamal Saha <tamal@appscode.com>
Signed-off-by: Tamal Saha <tamal@appscode.com>
Signed-off-by: Tamal Saha <tamal@appscode.com>
registerViaExtendedAPI now calls identityclient.NewForConfig(cfg).AuditTokenRequests().Create instead of hand-rolling a rest.RESTClient and serializer. Drops the local identityScheme/serializer wiring; brings in the typed clientset, the multi-group scheme and x-helm.dev/apimachinery via go mod vendor. Signed-off-by: Tamal Saha <tamal@appscode.com>
This was referenced Jun 4, 2026
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.
Summary
NatsClient.connectnow tries the publicappscode.com/api/v1/registerendpoint first viaidentitylib.NewDefaultClient().GetAuditTokenForCluster(...).identity.k8s.appscode.com/v1alpha1/AuditTokenRequestextended API hosted by ui-server.kmodules.xyz/resource-metadatato the merged master commit (ba20b6454).Why
The audit lib is vendored into many AppsCode controllers, each of which currently needs direct egress to
appscode.comto register and obtain NATS credentials. Disconnected/air-gapped clusters can't reach that endpoint, but they can reach their own API server, which now proxies the same call via the new extended API.Depends on
Test plan
go build ./...go vet ./...*.appscode.comand verify the in-cluster fallback succeeds