Skip to content

feat(discovery): add kubernetes discovery data warm-up in master process#13054

Open
ChuanFF wants to merge 1 commit intoapache:masterfrom
ChuanFF:feat-k8s-discovery-data-warm-up
Open

feat(discovery): add kubernetes discovery data warm-up in master process#13054
ChuanFF wants to merge 1 commit intoapache:masterfrom
ChuanFF:feat-k8s-discovery-data-warm-up

Conversation

@ChuanFF
Copy link
Contributor

@ChuanFF ChuanFF commented Mar 1, 2026

Description

This PR introduces a data warm-up mechanism for the Kubernetes discovery module. Previously, APISIX worker processes might start handling traffic before the Kubernetes endpoints cache was fully populated, potentially causing initial request failures due to missing upstream nodes.

With this change, the master process now performs an immediate, synchronous list operation against the Kubernetes API server during initialization (init phase), ensuring that endpoint data is pre-loaded into shared memory before worker processes are spawned.

The warm-up execution is synchronous and blocking but only runs once in the master process during startup. Since it performs a single list request (not watch), the latency impact is minimal and acceptable for initialization phase.

Other types of service discovery, such as Consul, can also implement init() to support the data warm-up.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Mar 1, 2026
@ChuanFF
Copy link
Contributor Author

ChuanFF commented Mar 1, 2026

threre is a bug :#13055, i modify order of KUBERNETES_CLIENT_TOKEN_FILE and KUBERNETES_CLIENT_TOKEN to avoid bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant