You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/09/19 14:29:57 UTC

[GitHub] [apisix] zhixiongdu027 opened a new pull request, #7944: doc: refactor kubernetes discovery

zhixiongdu027 opened a new pull request, #7944:
URL: https://github.com/apache/apisix/pull/7944

   ### Description
   
   <!-- Please include a summary of the change and which issue is fixed. -->
   <!-- Please also include relevant motivation and context. -->
   
   This Is doc for
   #7569 
   #7895
   
   ### 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](https://github.com/apache/apisix/tree/master#community) first)
   
   <!--
   
   Note
   
   1. Mark the PR as draft until it's ready to be reviewed.
   2. Always add/update tests for any changes unless you have a good reason.
   3. Always update the documentation to reflect the changes made in the PR.
   4. Make a new commit to resolve conversations instead of `push -f`.
   5. To resolve merge conflicts, merge master instead of rebasing.
   6. Use "request review" to notify the reviewer after making changes.
   7. Only a reviewer can mark a conversation as resolved.
   
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] zhixiongdu027 commented on pull request #7944: docs: refactor kubernetes discovery

Posted by GitBox <gi...@apache.org>.
zhixiongdu027 commented on PR #7944:
URL: https://github.com/apache/apisix/pull/7944#issuecomment-1251728712

   @spacewander @tzssangglass @tokers 
   Hi, docs is ready for review , Please help . 
   TKS,  @_@ 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] tzssangglass commented on a diff in pull request #7944: docs: refactor kubernetes discovery

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on code in PR #7944:
URL: https://github.com/apache/apisix/pull/7944#discussion_r974816400


##########
docs/en/latest/discovery/kubernetes.md:
##########
@@ -24,12 +24,17 @@ title: Kubernetes
 ## Summary
 
 The [_Kubernetes_](https://kubernetes.io/) service discovery [_List-Watch_](https://kubernetes.io/docs/reference/using-api/api-concepts/) real-time changes of [_Endpoints_](https://kubernetes.io/docs/concepts/services-networking/service/) resources,
-then store theirs value into ngx.shared.kubernetes \
-Discovery also provides a query interface in accordance with the [_APISIX Discovery Specification_](https://github.com/apache/apisix/blob/master/docs/en/latest/discovery.md)
+then store theirs value into ngx.shared.DICT \
+Discovery also provides a node query interface in accordance with the [_APISIX Discovery Specification_](https://github.com/apache/apisix/blob/master/docs/en/latest/discovery.md)
 
-## Configuration
+## How To Use
 
-A detailed configuration for the kubernetes service discovery is as follows:
+kubernetes service discovery both support single-cluster and multi-cluster mode, \
+applicable to the case where the service is distributed in a single or multiple kubernetes clusters.

Review Comment:
   ```suggestion
   Kubernetes service discovery both support single-cluster and multi-cluster mode, applicable to the case where the service is distributed in single or multiple Kubernetes clusters.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] SylviaBABY commented on a diff in pull request #7944: docs: refactor kubernetes discovery

Posted by GitBox <gi...@apache.org>.
SylviaBABY commented on code in PR #7944:
URL: https://github.com/apache/apisix/pull/7944#discussion_r974819097


##########
conf/config-default.yaml:
##########
@@ -303,6 +302,10 @@ nginx_config:                     # config for render the template to generate n
 #       path: "logs/consul_kv.dump"
 #       expire: 2592000            # unit sec, here is 30 day
 #  kubernetes:
+#    ### kubernetes service discovery both support single-cluster and multi-cluster mode
+#    ### applicable to the case where the service is distributed in a single or multiple kubernetes clusters.
+#
+#    ### Single-Cluster Mode ###

Review Comment:
   Hi, I see `single-cluster` appearing multiple times in this article. Please keep the same way of writing, either `single-cluster` or `Single-Cluster`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] SylviaBABY merged pull request #7944: docs: refactor kubernetes discovery

Posted by GitBox <gi...@apache.org>.
SylviaBABY merged PR #7944:
URL: https://github.com/apache/apisix/pull/7944


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] zhixiongdu027 commented on pull request #7944: docs: refactor kubernetes discovery

Posted by GitBox <gi...@apache.org>.
zhixiongdu027 commented on PR #7944:
URL: https://github.com/apache/apisix/pull/7944#issuecomment-1251821842

   @SylviaBABY 
   Tks your review ,very nice.  @_@


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] tzssangglass commented on a diff in pull request #7944: docs: refactor kubernetes discovery

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on code in PR #7944:
URL: https://github.com/apache/apisix/pull/7944#discussion_r974816791


##########
docs/en/latest/discovery/kubernetes.md:
##########
@@ -24,12 +24,17 @@ title: Kubernetes
 ## Summary
 
 The [_Kubernetes_](https://kubernetes.io/) service discovery [_List-Watch_](https://kubernetes.io/docs/reference/using-api/api-concepts/) real-time changes of [_Endpoints_](https://kubernetes.io/docs/concepts/services-networking/service/) resources,
-then store theirs value into ngx.shared.kubernetes \
-Discovery also provides a query interface in accordance with the [_APISIX Discovery Specification_](https://github.com/apache/apisix/blob/master/docs/en/latest/discovery.md)
+then store theirs value into ngx.shared.DICT \
+Discovery also provides a node query interface in accordance with the [_APISIX Discovery Specification_](https://github.com/apache/apisix/blob/master/docs/en/latest/discovery.md)
 
-## Configuration
+## How To Use
 
-A detailed configuration for the kubernetes service discovery is as follows:
+kubernetes service discovery both support single-cluster and multi-cluster mode, \
+applicable to the case where the service is distributed in a single or multiple kubernetes clusters.

Review Comment:
   `kubernetes` --> `Kubernetes` in this article, I remember that this is the proprietary name.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] SylviaBABY commented on a diff in pull request #7944: docs: refactor kubernetes discovery

Posted by GitBox <gi...@apache.org>.
SylviaBABY commented on code in PR #7944:
URL: https://github.com/apache/apisix/pull/7944#discussion_r974849411


##########
docs/zh/latest/discovery/kubernetes.md:
##########
@@ -73,20 +77,23 @@ discovery:
        #- default
        #- ^my-[a-z]+$
 
-    # kubernetes discovery plugin support use label_selector
+    # kubernetes discovery support label_selector
     # for the expression of label_selector, please refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
     label_selector: |-
       first="a",second="b"
+
+    # reserved lua shared memory size, 1m memory can store about 1000 pieces of endpoint
+    shared_size: 1m #default 1m
 ```
 
-如果 Kubernetes 服务发现模块运行在 Pod 内,你可以使用最简配置:
+如果 Kubernetes 服务发现运行在 Pod 内,你可以使用最简配置

Review Comment:
   ```suggestion
   如果 Kubernetes 服务发现运行在 Pod 内,你可以使用如下最简配置:
   ```



##########
docs/zh/latest/discovery/kubernetes.md:
##########
@@ -23,13 +23,17 @@ title: Kubernetes
 
 ## 基于 Kubernetes 的服务发现
 
-Kubernetes 服务发现模块以 [_List-Watch_](https://kubernetes.io/docs/reference/using-api/api-concepts) 方式监听 [_Kubernetes_](https://kubernetes.io) 集群 [_Endpoints_](https://kubernetes.io/docs/concepts/services-networking/service) 资源的实时变化,
-并将其值存储到 ngx.shared.kubernetes 中 \
-模块同时遵循 [_APISIX Discovery 规范_](https://github.com/apache/apisix/blob/master/docs/zh/latest/discovery.md) 提供了节点查询接口
+Kubernetes 服务发现以 [_List-Watch_](https://kubernetes.io/docs/reference/using-api/api-concepts) 方式监听 [_Kubernetes_](https://kubernetes.io) 集群 [_Endpoints_](https://kubernetes.io/docs/concepts/services-networking/service) 资源的实时变化,
+资源,并将其值存储到 ngx.shared.DICT 中 \
+同时遵循 [_APISIX Discovery 规范_](https://github.com/apache/apisix/blob/master/docs/zh/latest/discovery.md) 提供了节点查询接口
 
-## Kubernetes 服务发现模块的配置
+## Kubernetes 服务发现的使用
 
-Kubernetes 服务发现模块的完整配置如下:
+Kubernetes 服务发现支持单集群,多集群模式。分别适用于待发现的服务分布在单个或多个 Kubernetes 的情况。

Review Comment:
   ```suggestion
   目前 Kubernetes 服务发现支持单集群和多集群模式,分别适用于待发现的服务分布在单个或多个 Kubernetes 的场景。
   ```



##########
docs/zh/latest/discovery/kubernetes.md:
##########
@@ -97,12 +104,12 @@ discovery:
       port: # enter apiServer port value here
     client:
       token: # enter serviceaccount token value here
-      #token_file: # enter file path here
+      #token_file: # enter token file path here
 ```
 
-## Kubernetes 服务发现模块的查询接口
+### 单集群模式 Kubernetes 服务发现的查询接口
 
-Kubernetes 服务发现模块遵循 [_APISIX Discovery 规范_](https://github.com/apache/apisix/blob/master/docs/zh/latest/discovery.md) 提供查询接口
+单集群模式 Kubernetes 服务发现遵循 [_APISIX Discovery 规范_](https://github.com/apache/apisix/blob/master/docs/zh/latest/discovery.md) 提供节点查询接口

Review Comment:
   ```suggestion
   单集群模式 Kubernetes 服务发现遵循 [_APISIX Discovery 规范_](https://github.com/apache/apisix/blob/master/docs/zh/latest/discovery.md) 提供节点查询接口。
   ```



##########
docs/zh/latest/discovery/kubernetes.md:
##########
@@ -131,9 +138,121 @@ service_name 必须满足格式: [namespace]/[name]:[portName]
         - ip: "10.5.10.110"
       ports:
         - port: 3306
+          name: port
   ```
 
-nodes("default/plat-dev:3306") 调用会得到如下的返回值:
+nodes("default/plat-dev:port") 调用会得到如下的返回值:
+
+  ```
+   {
+       {
+           host="10.5.10.109",
+           port= 3306,
+           weight= 50,
+       },
+       {
+           host="10.5.10.110",
+           port= 3306,
+           weight= 50,
+       },
+   }
+  ```
+
+### 多集群模式 Kubernetes 服务发现的配置格式
+
+多集群模式 Kubernetes 服务发现的完整配置如下:
+
+```yaml
+discovery:
+  kubernetes:
+  - id: release  # a custom name refer to the cluster, pattern ^[a-z0-9]{1,8}
+    service:
+      # apiserver schema, options [http, https]
+      schema: https #default https
+
+      # apiserver host, options [ipv4, ipv6, domain, environment variable]
+      host: "1.cluster.com"
+
+      # apiserver port, options [port number, environment variable]
+      port: "6443"
+
+    client:
+      # serviceaccount token or token_file
+      token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
+
+      #token: |-
+       # eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEif
+       # 6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEifeyJhbGciOiJSUzI1NiIsImtpZCI
+
+    default_weight: 50 # weight assigned to each discovered endpoint. default 50, minimum 0
+
+    # kubernetes discovery support namespace_selector
+    # you can use one of [equal, not_equal, match, not_match] filter namespace
+    namespace_selector:
+      # only save endpoints with namespace equal default
+      equal: default
+
+      # only save endpoints with namespace not equal default
+      #not_equal: default
+
+      # only save endpoints with namespace match one of [default, ^my-[a-z]+$]
+      #match:
+       #- default
+       #- ^my-[a-z]+$
+
+      # only save endpoints with namespace not match one of [default, ^my-[a-z]+$]
+      #not_match:
+       #- default
+       #- ^my-[a-z]+$
+
+    # kubernetes discovery support label_selector
+    # for the expression of label_selector, please refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
+    label_selector: |-
+      first="a",second="b"
+
+    # reserved lua shared memory size,1m memory can store about 1000 pieces of endpoint
+    shared_size: 1m #default 1m
+```
+
+多集群模式 Kubernetes 服务发现没有为 service,client 域填充默认值,你需要根据集群配置情况自行填充。

Review Comment:
   ```suggestion
   多集群模式 Kubernetes 服务发现没有为 `service` 和 `client` 域填充默认值,你需要根据集群配置情况自行填充。
   ```



##########
docs/en/latest/discovery/kubernetes.md:
##########
@@ -133,9 +141,123 @@ the kubernetes service discovery provides a query interface in accordance with t
         - ip: "10.5.10.110"
       ports:
         - port: 3306
+          name: port
   ```
 
-  a nodes("default/plat-dev:3306") call will get follow result:
+  a nodes("default/plat-dev:port") call will get follow result:
+
+  ```
+   {
+       {
+           host="10.5.10.109",
+           port= 3306,
+           weight= 50,
+       },
+       {
+           host="10.5.10.110",
+           port= 3306,
+           weight= 50,
+       },
+   }
+  ```
+
+### Multi-Cluster Mode Configuration
+
+A detailed configuration for multi-cluster mode Kubernetes service discovery is as follows:
+
+```yaml
+discovery:
+  kubernetes:
+  - id: release  # a custom name refer to the cluster, pattern ^[a-z0-9]{1,8}
+    service:
+      # apiserver schema, options [http, https]
+      schema: https #default https
+
+      # apiserver host, options [ipv4, ipv6, domain, environment variable]
+      host: "1.cluster.com"
+
+      # apiserver port, options [port number, environment variable]
+      port: "6443"
+
+    client:
+      # serviceaccount token or token_file
+      token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
+
+      #token: |-
+       # eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEif
+       # 6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEifeyJhbGciOiJSUzI1NiIsImtpZCI
+
+    default_weight: 50 # weight assigned to each discovered endpoint. default 50, minimum 0
+
+    # kubernetes discovery support namespace_selector
+    # you can use one of [equal, not_equal, match, not_match] filter namespace
+    namespace_selector:
+      # only save endpoints with namespace equal default
+      equal: default
+
+      # only save endpoints with namespace not equal default
+      #not_equal: default
+
+      # only save endpoints with namespace match one of [default, ^my-[a-z]+$]
+      #match:
+       #- default
+       #- ^my-[a-z]+$
+
+      # only save endpoints with namespace not match one of [default, ^my-[a-z]+$]
+      #not_match:
+       #- default
+       #- ^my-[a-z]+$
+
+    # kubernetes discovery support label_selector
+    # for the expression of label_selector, please refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
+    label_selector: |-
+      first="a",second="b"
+
+    # reserved lua shared memory size,1m memory can store about 1000 pieces of endpoint
+    shared_size: 1m #default 1m
+```
+
+Multi-Kubernetes service discovery does not fill default values for service and client fields,\
+you need to fill them according to cluster configuration.
+
+### Multi-Cluster Mode Query Interface
+
+the Kubernetes service discovery provides a query interface in accordance with the [_APISIX Discovery Specification_](https://github.com/apache/apisix/blob/master/docs/en/latest/discovery.md)

Review Comment:
   ```suggestion
   The Kubernetes service discovery provides a query interface in accordance with the [_APISIX Discovery Specification_](https://github.com/apache/apisix/blob/master/docs/en/latest/discovery.md).
   ```



##########
docs/en/latest/discovery/kubernetes.md:
##########
@@ -133,9 +141,123 @@ the kubernetes service discovery provides a query interface in accordance with t
         - ip: "10.5.10.110"
       ports:
         - port: 3306
+          name: port
   ```
 
-  a nodes("default/plat-dev:3306") call will get follow result:
+  a nodes("default/plat-dev:port") call will get follow result:
+
+  ```
+   {
+       {
+           host="10.5.10.109",
+           port= 3306,
+           weight= 50,
+       },
+       {
+           host="10.5.10.110",
+           port= 3306,
+           weight= 50,
+       },
+   }
+  ```
+
+### Multi-Cluster Mode Configuration
+
+A detailed configuration for multi-cluster mode Kubernetes service discovery is as follows:
+
+```yaml
+discovery:
+  kubernetes:
+  - id: release  # a custom name refer to the cluster, pattern ^[a-z0-9]{1,8}
+    service:
+      # apiserver schema, options [http, https]
+      schema: https #default https
+
+      # apiserver host, options [ipv4, ipv6, domain, environment variable]
+      host: "1.cluster.com"
+
+      # apiserver port, options [port number, environment variable]
+      port: "6443"
+
+    client:
+      # serviceaccount token or token_file
+      token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
+
+      #token: |-
+       # eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEif
+       # 6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEifeyJhbGciOiJSUzI1NiIsImtpZCI
+
+    default_weight: 50 # weight assigned to each discovered endpoint. default 50, minimum 0
+
+    # kubernetes discovery support namespace_selector
+    # you can use one of [equal, not_equal, match, not_match] filter namespace
+    namespace_selector:
+      # only save endpoints with namespace equal default
+      equal: default
+
+      # only save endpoints with namespace not equal default
+      #not_equal: default
+
+      # only save endpoints with namespace match one of [default, ^my-[a-z]+$]
+      #match:
+       #- default
+       #- ^my-[a-z]+$
+
+      # only save endpoints with namespace not match one of [default, ^my-[a-z]+$]
+      #not_match:
+       #- default
+       #- ^my-[a-z]+$
+
+    # kubernetes discovery support label_selector
+    # for the expression of label_selector, please refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
+    label_selector: |-
+      first="a",second="b"
+
+    # reserved lua shared memory size,1m memory can store about 1000 pieces of endpoint
+    shared_size: 1m #default 1m
+```
+
+Multi-Kubernetes service discovery does not fill default values for service and client fields,\

Review Comment:
   ```suggestion
   Multi-Kubernetes service discovery does not fill default values for service and client fields, you need to fill them according to the cluster configuration.
   ```



##########
docs/zh/latest/discovery/kubernetes.md:
##########
@@ -23,13 +23,17 @@ title: Kubernetes
 
 ## 基于 Kubernetes 的服务发现
 
-Kubernetes 服务发现模块以 [_List-Watch_](https://kubernetes.io/docs/reference/using-api/api-concepts) 方式监听 [_Kubernetes_](https://kubernetes.io) 集群 [_Endpoints_](https://kubernetes.io/docs/concepts/services-networking/service) 资源的实时变化,
-并将其值存储到 ngx.shared.kubernetes 中 \
-模块同时遵循 [_APISIX Discovery 规范_](https://github.com/apache/apisix/blob/master/docs/zh/latest/discovery.md) 提供了节点查询接口
+Kubernetes 服务发现以 [_List-Watch_](https://kubernetes.io/docs/reference/using-api/api-concepts) 方式监听 [_Kubernetes_](https://kubernetes.io) 集群 [_Endpoints_](https://kubernetes.io/docs/concepts/services-networking/service) 资源的实时变化,
+资源,并将其值存储到 ngx.shared.DICT 中 \

Review Comment:
   ```suggestion
   ```



##########
docs/en/latest/discovery/kubernetes.md:
##########
@@ -133,9 +141,123 @@ the kubernetes service discovery provides a query interface in accordance with t
         - ip: "10.5.10.110"
       ports:
         - port: 3306
+          name: port
   ```
 
-  a nodes("default/plat-dev:3306") call will get follow result:
+  a nodes("default/plat-dev:port") call will get follow result:
+
+  ```
+   {
+       {
+           host="10.5.10.109",
+           port= 3306,
+           weight= 50,
+       },
+       {
+           host="10.5.10.110",
+           port= 3306,
+           weight= 50,
+       },
+   }
+  ```
+
+### Multi-Cluster Mode Configuration
+
+A detailed configuration for multi-cluster mode Kubernetes service discovery is as follows:
+
+```yaml
+discovery:
+  kubernetes:
+  - id: release  # a custom name refer to the cluster, pattern ^[a-z0-9]{1,8}
+    service:
+      # apiserver schema, options [http, https]
+      schema: https #default https
+
+      # apiserver host, options [ipv4, ipv6, domain, environment variable]
+      host: "1.cluster.com"
+
+      # apiserver port, options [port number, environment variable]
+      port: "6443"
+
+    client:
+      # serviceaccount token or token_file
+      token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
+
+      #token: |-
+       # eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEif
+       # 6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEifeyJhbGciOiJSUzI1NiIsImtpZCI
+
+    default_weight: 50 # weight assigned to each discovered endpoint. default 50, minimum 0
+
+    # kubernetes discovery support namespace_selector
+    # you can use one of [equal, not_equal, match, not_match] filter namespace
+    namespace_selector:
+      # only save endpoints with namespace equal default
+      equal: default
+
+      # only save endpoints with namespace not equal default
+      #not_equal: default
+
+      # only save endpoints with namespace match one of [default, ^my-[a-z]+$]
+      #match:
+       #- default
+       #- ^my-[a-z]+$
+
+      # only save endpoints with namespace not match one of [default, ^my-[a-z]+$]
+      #not_match:
+       #- default
+       #- ^my-[a-z]+$
+
+    # kubernetes discovery support label_selector
+    # for the expression of label_selector, please refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
+    label_selector: |-
+      first="a",second="b"
+
+    # reserved lua shared memory size,1m memory can store about 1000 pieces of endpoint
+    shared_size: 1m #default 1m
+```
+
+Multi-Kubernetes service discovery does not fill default values for service and client fields,\
+you need to fill them according to cluster configuration.

Review Comment:
   ```suggestion
   ```



##########
docs/zh/latest/discovery/kubernetes.md:
##########
@@ -23,13 +23,17 @@ title: Kubernetes
 
 ## 基于 Kubernetes 的服务发现
 
-Kubernetes 服务发现模块以 [_List-Watch_](https://kubernetes.io/docs/reference/using-api/api-concepts) 方式监听 [_Kubernetes_](https://kubernetes.io) 集群 [_Endpoints_](https://kubernetes.io/docs/concepts/services-networking/service) 资源的实时变化,
-并将其值存储到 ngx.shared.kubernetes 中 \
-模块同时遵循 [_APISIX Discovery 规范_](https://github.com/apache/apisix/blob/master/docs/zh/latest/discovery.md) 提供了节点查询接口
+Kubernetes 服务发现以 [_List-Watch_](https://kubernetes.io/docs/reference/using-api/api-concepts) 方式监听 [_Kubernetes_](https://kubernetes.io) 集群 [_Endpoints_](https://kubernetes.io/docs/concepts/services-networking/service) 资源的实时变化,

Review Comment:
   ```suggestion
   Kubernetes 服务发现以 [_List-Watch_](https://kubernetes.io/docs/reference/using-api/api-concepts) 方式监听 [_Kubernetes_](https://kubernetes.io) 集群 [_Endpoints_](https://kubernetes.io/docs/concepts/services-networking/service) 资源的实时变化,并将其值存储到 ngx.shared.DICT 中。
   ```



##########
docs/en/latest/discovery/kubernetes.md:
##########
@@ -101,25 +109,25 @@ discovery:
       #token_file: # enter file path here
 ```
 
-## Interface
+### Single-Cluster Mode Query Interface
 
-the kubernetes service discovery provides a query interface in accordance with the [_APISIX Discovery Specification_](https://github.com/apache/apisix/blob/master/docs/en/latest/discovery.md)
+the Kubernetes service discovery provides a query interface in accordance with the [_APISIX Discovery Specification_](https://github.com/apache/apisix/blob/master/docs/en/latest/discovery.md)

Review Comment:
   ```suggestion
   The Kubernetes service discovery provides a query interface in accordance with the [_APISIX Discovery Specification_](https://github.com/apache/apisix/blob/master/docs/en/latest/discovery.md).
   ```



##########
docs/en/latest/discovery/kubernetes.md:
##########
@@ -73,20 +78,23 @@ discovery:
        #- default
        #- ^my-[a-z]+$
 
-    # kubernetes discovery plugin support use label_selector
+    # kubernetes discovery support label_selector
     # for the expression of label_selector, please refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
     label_selector: |-
       first="a",second="b"
+
+    # reserved lua shared memory size,1m memory can store about 1000 pieces of endpoint
+    shared_size: 1m #default 1m
 ```
 
-If the kubernetes service discovery runs inside a pod, you can use minimal configuration:
+If the Kubernetes service discovery runs inside a pod, you can use minimal configuration:
 
 ```yaml
 discovery:
   kubernetes: { }
 ```
 
-If the kubernetes service discovery runs outside a pod, you need to create or select a specified [_ServiceAccount_](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/),
+If the Kubernetes service discovery runs outside a pod, you need to create or select a specified [_ServiceAccount_](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/),
 then get its token value, and use following configuration:

Review Comment:
   ```suggestion
   ```



##########
docs/zh/latest/discovery/kubernetes.md:
##########
@@ -131,9 +138,121 @@ service_name 必须满足格式: [namespace]/[name]:[portName]
         - ip: "10.5.10.110"
       ports:
         - port: 3306
+          name: port
   ```
 
-nodes("default/plat-dev:3306") 调用会得到如下的返回值:
+nodes("default/plat-dev:port") 调用会得到如下的返回值:
+
+  ```
+   {
+       {
+           host="10.5.10.109",
+           port= 3306,
+           weight= 50,
+       },
+       {
+           host="10.5.10.110",
+           port= 3306,
+           weight= 50,
+       },
+   }
+  ```
+
+### 多集群模式 Kubernetes 服务发现的配置格式
+
+多集群模式 Kubernetes 服务发现的完整配置如下:
+
+```yaml
+discovery:
+  kubernetes:
+  - id: release  # a custom name refer to the cluster, pattern ^[a-z0-9]{1,8}
+    service:
+      # apiserver schema, options [http, https]
+      schema: https #default https
+
+      # apiserver host, options [ipv4, ipv6, domain, environment variable]
+      host: "1.cluster.com"
+
+      # apiserver port, options [port number, environment variable]
+      port: "6443"
+
+    client:
+      # serviceaccount token or token_file
+      token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
+
+      #token: |-
+       # eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEif
+       # 6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEifeyJhbGciOiJSUzI1NiIsImtpZCI
+
+    default_weight: 50 # weight assigned to each discovered endpoint. default 50, minimum 0
+
+    # kubernetes discovery support namespace_selector
+    # you can use one of [equal, not_equal, match, not_match] filter namespace
+    namespace_selector:
+      # only save endpoints with namespace equal default
+      equal: default
+
+      # only save endpoints with namespace not equal default
+      #not_equal: default
+
+      # only save endpoints with namespace match one of [default, ^my-[a-z]+$]
+      #match:
+       #- default
+       #- ^my-[a-z]+$
+
+      # only save endpoints with namespace not match one of [default, ^my-[a-z]+$]
+      #not_match:
+       #- default
+       #- ^my-[a-z]+$
+
+    # kubernetes discovery support label_selector
+    # for the expression of label_selector, please refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
+    label_selector: |-
+      first="a",second="b"
+
+    # reserved lua shared memory size,1m memory can store about 1000 pieces of endpoint
+    shared_size: 1m #default 1m
+```
+
+多集群模式 Kubernetes 服务发现没有为 service,client 域填充默认值,你需要根据集群配置情况自行填充。
+
+### 多集群模式 Kubernetes 服务发现的查询接口
+
+多集群模式 Kubernetes 服务发现遵循 [_APISIX Discovery 规范_](https://github.com/apache/apisix/blob/master/docs/zh/latest/discovery.md) 提供节点查询接口

Review Comment:
   ```suggestion
   多集群模式 Kubernetes 服务发现遵循 [_APISIX Discovery 规范_](https://github.com/apache/apisix/blob/master/docs/zh/latest/discovery.md) 提供节点查询接口。
   ```



##########
docs/zh/latest/discovery/kubernetes.md:
##########
@@ -23,13 +23,17 @@ title: Kubernetes
 
 ## 基于 Kubernetes 的服务发现
 
-Kubernetes 服务发现模块以 [_List-Watch_](https://kubernetes.io/docs/reference/using-api/api-concepts) 方式监听 [_Kubernetes_](https://kubernetes.io) 集群 [_Endpoints_](https://kubernetes.io/docs/concepts/services-networking/service) 资源的实时变化,
-并将其值存储到 ngx.shared.kubernetes 中 \
-模块同时遵循 [_APISIX Discovery 规范_](https://github.com/apache/apisix/blob/master/docs/zh/latest/discovery.md) 提供了节点查询接口
+Kubernetes 服务发现以 [_List-Watch_](https://kubernetes.io/docs/reference/using-api/api-concepts) 方式监听 [_Kubernetes_](https://kubernetes.io) 集群 [_Endpoints_](https://kubernetes.io/docs/concepts/services-networking/service) 资源的实时变化,
+资源,并将其值存储到 ngx.shared.DICT 中 \
+同时遵循 [_APISIX Discovery 规范_](https://github.com/apache/apisix/blob/master/docs/zh/latest/discovery.md) 提供了节点查询接口

Review Comment:
   ```suggestion
   
   同时遵循 [_APISIX Discovery 规范_](https://github.com/apache/apisix/blob/master/docs/zh/latest/discovery.md) 提供了节点查询接口。
   ```



##########
docs/en/latest/discovery/kubernetes.md:
##########
@@ -73,20 +78,23 @@ discovery:
        #- default
        #- ^my-[a-z]+$
 
-    # kubernetes discovery plugin support use label_selector
+    # kubernetes discovery support label_selector
     # for the expression of label_selector, please refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
     label_selector: |-
       first="a",second="b"
+
+    # reserved lua shared memory size,1m memory can store about 1000 pieces of endpoint
+    shared_size: 1m #default 1m
 ```
 
-If the kubernetes service discovery runs inside a pod, you can use minimal configuration:
+If the Kubernetes service discovery runs inside a pod, you can use minimal configuration:
 
 ```yaml
 discovery:
   kubernetes: { }
 ```
 
-If the kubernetes service discovery runs outside a pod, you need to create or select a specified [_ServiceAccount_](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/),
+If the Kubernetes service discovery runs outside a pod, you need to create or select a specified [_ServiceAccount_](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/),

Review Comment:
   ```suggestion
   If the Kubernetes service discovery runs outside a pod, you need to create or select a specified [_ServiceAccount_](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/), then get its token value, and use following configuration:
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] SylviaBABY commented on pull request #7944: docs: refactor kubernetes discovery

Posted by GitBox <gi...@apache.org>.
SylviaBABY commented on PR #7944:
URL: https://github.com/apache/apisix/pull/7944#issuecomment-1253060846

   Since there are some formatting problems in these documents, this PR will be merged first, and I will modify these small errors later.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org