Skip to content

Commit

Permalink
docs: improve kubernetes.md
Browse files Browse the repository at this point in the history
  • Loading branch information
zhixiongdu027 committed Feb 19, 2022
1 parent b2940ab commit 2276693
Showing 1 changed file with 37 additions and 23 deletions.
60 changes: 37 additions & 23 deletions docs/zh/latest/discovery/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,52 @@

# 基于 Kubernetes 的服务发现

Kubernetes 服务发现插件以 ListWatch 方式监听 Kubernetes 集群的 的 v1.endpoints 的实时变化,
并将其值存储在 ngx.shared.DICT 中, 同时遵循 APISix Discovery 规范提供对外查询接口
Kubernetes 服务发现插件以 ListWatch 方式监听 Kubernetes 集群 v1.endpoints 的实时变化,
并将其值存储在 ngx.shared.dict 中, 同时遵循 APISIX Discovery 规范提供查询接口

# Kubernetes 服务发现插件的配置

Kubernetes 服务发现的样例配置如下:
Kubernetes 服务发现插件的样例配置如下:

```yaml
discovery:
kubernetes:
service:
# kubernetes apiserver schema, options [ http | https ]
# apiserver schema, options [http, https]
schema: https #default https

# kubernetes apiserver host, options [ ipv4 | ipv6 | domain | env variable]
host: 10.0.8.95 #default ${KUBERNETES_SERVICE_HOST}
# apiserver host, options [ipv4, ipv6, domain, environment variable]
host: ${KUBERNETES_SERVICE_HOST} #default ${KUBERNETES_SERVICE_HOST}

# kubernetes apiserver port, you can enter port number or environment variable
port: 6443 #default ${KUBERNETES_SERVICE_PORT}
# apiserver port, options [port number, environment variable]
port: ${KUBERNETES_SERVICE_PORT} #default ${KUBERNETES_SERVICE_PORT}

client:
# kubernetes serviceaccount token or token_file
token_file: "/var/run/secrets/kubernetes.io/serviceaccount/token"
#token:
# serviceaccount token or token_file
token_file: /var/run/secrets/kubernetes.io/serviceaccount/token

#token: |-
# eyJhbGciOiJSUzI1NiIsImtpZCI6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEif
# 6Ikx5ME1DNWdnbmhQNkZCNlZYMXBsT3pYU3BBS2swYzBPSkN3ZnBESGpkUEEifeyJhbGciOiJSUzI1NiIsImtpZCI

# kubernetes discovery plugin support use namespace_selector
# you can use one of [ equal | not_equal | match | not_match ] filter namespace
# you can use one of [equal, not_equal, match, not_match] filter namespace
namespace_selector:
# only save endpoints with namespace equal default
equal: default
#not_equal:

# 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 plugin support use label_selector
# for the expression of label_selector, please refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
Expand All @@ -71,12 +85,12 @@ discovery:
discovery:
kubernetes:
service:
host: # Enter ApiServer Host Value Here
port: # Enter ApiServer Port Value Here
schema: https
host: # enter apiserver host value here
port: # enter apiServer port value here
client:
token: # Enter ServiceAccount Token Value Here
#token_file: # Enter File Path Here
token: # enter serviceaccount token value here
#token_file: # enter file path here
```

# Kubernetes 服务发现插件的使用
Expand All @@ -89,18 +103,18 @@ service_name 的 pattern 如下:

# Q&A

> Q: 为什么只支持配置 token 来访问 kubernetes apiserver \
> A: 通常情况下,我们会使用三种方式与 kubernetes apiserver 通信 :
> Q: 为什么只支持配置 token 来访问 Kubernetes ApiServer \
> A: 通常情况下,我们会使用三种方式与 Kubernetes ApiServer 通信 :
>
>+ mTLS
>+ token
>+ basic authentication
>
> 因为 lua-resty-http 目前不支持 mTLS ,以及 basic authentication 不被推荐使用,\
> 因为 lua-resty-http 目前不支持 mTLS, 以及 basic authentication 不被推荐使用,\
> 所以当前只实现了 token 认证方式
-------

> Q: APISix 是多进程模型, 是否意味着每个 APISix 业务进程都会去监听 kubernetes apiserver \
> A: Kubernetes 服务发现插件只使用特权进程监听 kubernetes 集群,然后将结果存储在 ngx.shared.DICT中, \
> 业务进程是通过查询 ngx.shared.DICT 获取结果的
> Q: APISIX 是多进程模型, 是否意味着每个 APISIX 工作进程都会监听 Kubernetes v1.endpoints \
> A: Kubernetes 服务发现插件只使用特权进程监听 Kubernetes v1.endpoints, 然后将结果存储\
> 在 ngx.shared.dict 中, 业务进程是通过查询 ngx.shared.dict 来获取结果的

0 comments on commit 2276693

Please sign in to comment.