-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add labels for upstream object #2279
Conversation
labels can be used to specify additional attributes. Signed-off-by: imjoey <majunjiev@gmail.com>
c8550b7
to
508cd8c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need a test case, I think it should be invalid.
{
... ...
lables: {
key: {
sub_key: ["a", "b", "c"]
}
}
}
apisix/schema_def.lua
Outdated
@@ -332,6 +332,10 @@ local upstream_schema = { | |||
description = "enable websocket for request", | |||
type = "boolean" | |||
}, | |||
labels = { | |||
description = "key/value pairs to specify attributes", | |||
type = "table" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be object
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to limit the depth to 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@membphis agreed, nice catch, thanks. I would make changes as the your suggestions and add one more failure test case after I find the lua way. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@membphis PR is updated and labels are limited to string key/value pairs, so fix the depth problem. 😄
@imjoey One thing confuses me that the labels field is attached on the whole |
This is a very interesting topic. |
Hi @tokers , thanks for your feedback. I guess labels could be very useful for every single object in APISIX. While currently |
Your idea is great,
|
@gxthrj yep, glad to hear your thoughts. Yesterday I was about to migrate the functionality of RouteGroup from MySQL to etcd. But it seemed still under discussions in community. So I deliberated on the whole design, I guess labels could make the relationships of objects in APISIX much more loosely coupled, and also make the extensibility more easily. |
I think we don't need to separate nodes from upstream, just redefine the data structure of nodes. |
@nic-chen Just FYI, we could make use of the existing |
|
Signed-off-by: imjoey <majunjiev@gmail.com>
980e048
to
07ae2c7
Compare
@@ -273,6 +273,7 @@ APISIX 的 Upstream 除了基本的复杂均衡算法选择外,还支持对上 | |||
|checks |可选|配置健康检查的参数,详细可参考[health-check](../health-check.md)| | |||
|retries |可选|使用底层的 Nginx 重试机制将请求传递给下一个上游,默认 APISIX 会启用重试机制,根据配置的后端节点个数设置重试次数,如果此参数显式被设置将会覆盖系统默认设置的重试次数。| | |||
|enable_websocket|可选| 是否启用 `websocket`(布尔值),默认不启用| | |||
|labels |可选| 用于标识属性的键值对。 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need more doc, we need an example about how to use this field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@membphis thanks for reviewing. I will add more guidance docs about labels usage and best practice in APISIX after labels are added in all objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor document issues need to be fixed, LGTM
@imjoey many thx, merged |
Signed-off-by: imjoey majunjiev@gmail.com
What this PR does / why we need it:
Hi fellows, we could use
labels
(as it in Kubernetes) to specify attributes that attached an object. This is a kind of extensibility mechanism for developers. Once I had a short discussion with @moonming at apache/apisix-dashboard#431 (comment) , so this PR is going to takeupstream
as the starting point and add a newlabels
property, via a rather simple implementation.Looking forward to the feedback. Thanks.
Pre-submission checklist: