Skip to content

fix(discovery/kubernetes): adjust id length#12536

Merged
SkyeYoung merged 9 commits into
apache:masterfrom
SkyeYoung:young/fix/adjust-discovery-kubernetes-schema
Aug 28, 2025
Merged

fix(discovery/kubernetes): adjust id length#12536
SkyeYoung merged 9 commits into
apache:masterfrom
SkyeYoung:young/fix/adjust-discovery-kubernetes-schema

Conversation

@SkyeYoung

@SkyeYoung SkyeYoung commented Aug 20, 2025

Copy link
Copy Markdown
Member

Description

This PR is designed to solve problems found in #12479:

  1. discovery.kubernetes.id needs to support more than 8 characters.

These designs were originally artificially limited, and there was a lack of discussion at the time.

Considering that ids have common cases like aws-jp-common and aws-sgp-common, the following adjustments were made in this PR:

  1. Adjust discovery.kubernetes.id to support a maximum of 64 characters.

Which issue(s) this PR fixes:

Fixes #12479

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)

@SkyeYoung SkyeYoung changed the title fix(discovery/kubernetes): adjust id length and regexp of service.host schema fix(discovery/kubernetes): tweak schema to fit a wider range of use cases Aug 20, 2025
@SkyeYoung
SkyeYoung marked this pull request as ready for review August 20, 2025 08:08
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 20, 2025
@SkyeYoung
SkyeYoung requested a review from Copilot August 20, 2025 08:09
@dosubot dosubot Bot added the bug Something isn't working label Aug 20, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses schema limitations in the Kubernetes discovery module to support a wider range of use cases, specifically for EKS environments where API server addresses may contain uppercase letters and cluster IDs may exceed 8 characters.

  • Expand discovery.kubernetes.service.host pattern to accept uppercase letters in addition to lowercase
  • Increase discovery.kubernetes.id maximum length from 8 to 64 characters
  • Add comprehensive test coverage for both schema validation scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
apisix/discovery/kubernetes/schema.lua Updates schema patterns for host (uppercase support) and id (64 char limit)
t/core/kubernetes_schema.t Adds new test file with validation tests for id and host field constraints

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread apisix/discovery/kubernetes/schema.lua Outdated
@dosubot

dosubot Bot commented Aug 20, 2025

Copy link
Copy Markdown

Related Documentation

No published documentation to review for changes on this repository.
Write your first living document

How did I do? Any feedback?  Join Discord

@SkyeYoung
SkyeYoung marked this pull request as draft August 20, 2025 09:02
Comment thread apisix/discovery/kubernetes/schema.lua Outdated
local host_patterns = {
{ pattern = [[^\${[_A-Za-z]([_A-Za-z0-9]*[_A-Za-z])*}$]] },
{ pattern = [[^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$]] },
{ pattern = [[^[A-Za-z0-9]([-A-Za-z0-9]*[A-Za-z0-9])?]] ..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@moonming This document is for object names in Kubernetes, and the API server endpoint (e.g., https://5E1D0CEXAMPLEA591B746AFC5AB30262.yl4.us-west-2.eks.amazonaws.com) is not a Kubernetes object name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

rollbacked

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@SkyeYoung, please modify the corresponding description information.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Baoyuantop What descriptions need to be adjusted? 🤔

@SkyeYoung
SkyeYoung marked this pull request as ready for review August 25, 2025 01:06
@SkyeYoung SkyeYoung changed the title fix(discovery/kubernetes): tweak schema to fit a wider range of use cases fix(discovery/kubernetes): adjust id length Aug 25, 2025
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Aug 25, 2025
membphis
membphis previously approved these changes Aug 26, 2025
@SkyeYoung
SkyeYoung requested a review from membphis August 27, 2025 09:18
@SkyeYoung
SkyeYoung merged commit 0d758a4 into apache:master Aug 28, 2025
44 of 49 checks passed
@SkyeYoung
SkyeYoung deleted the young/fix/adjust-discovery-kubernetes-schema branch August 28, 2025 07:06
jizhuozhi pushed a commit to jizhuozhi/apisix that referenced this pull request Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

help request: about discovery kubernetes multi-cluster mode

7 participants