feat: stream subsystem support kubernetes service discovery#8640
Conversation
| local endpoint_dict = ngx.shared["kubernetes-" .. id] | ||
| if not is_http then | ||
| endpoint_dict = ngx.shared["kubernetes-" .. id .. "-stream"] | ||
| end |
There was a problem hiding this comment.
It would be better to refactor these three changes into a function, instead of three if-else blocks.
|
|
||
|
|
||
| export OPENRESTY_VERSION=1.19.3.2 | ||
| export OPENRESTY_VERSION=1.19.9.1 |
There was a problem hiding this comment.
We have promised to support the latest three versions of OpenResty, so we still need to cover 1.19.3.2.
What about updating the test case and only running it when the version is matched, like https://github.com/apache/apisix/blob/release/2.14/t/plugin/ext-plugin/sanity-openresty-1-19.t?
It would be better to refuse to start when the OpenResty is too old and k8s discovery is used in the stream.
There was a problem hiding this comment.
We have promised to support the latest three versions of OpenResty, so we still need to cover 1.19.3.2.
What about updating the test case and only running it when the version is matched, like https://github.com/apache/apisix/blob/release/2.14/t/plugin/ext-plugin/sanity-openresty-1-19.t?
ok, i will try it later.
It would be better to refuse to start when the OpenResty is too old and k8s discovery is used in the stream.
Is it a good choice if we add a boolean field like enable_stream(default is false) into apisix/discovery/kubernetes/schema.lua as a property and check OpenResty version when enable_stream is true?
Can you give me some hints? thanks.
There was a problem hiding this comment.
- first, it will cause err like below when start apisix with openresty 1.19.3.2, because
local discovery = require("apisix.discovery.init").discoveryinapisix/upstream.lua:19will importdiscovery/kubernetes/init.lua.
$ ./bin/apisix start
/usr/local/openresty-debug//luajit/bin/luajit ./apisix/cli/apisix.lua start
nginx: [error] init_by_lua error: /usr/local/openresty-debug/lualib/ngx/process.lua:5: unsupported subsystem: stream
stack traceback:
[C]: in function 'error'
/usr/local/openresty-debug/lualib/resty/core/base.lua:223: in function 'allows_subsystem'
/usr/local/openresty-debug/lualib/ngx/process.lua:5: in main chunk
[C]: in function 'require'
...ng/Documents/apisix/apisix/discovery/kubernetes/init.lua:29: in main chunk
[C]: in function 'require'
/home/ronething/Documents/apisix/apisix/discovery/init.lua:28: in main chunk
[C]: in function 'require'
/home/ronething/Documents/apisix/apisix/upstream.lua:19: in main chunk
[C]: in function 'require'
/home/ronething/Documents/apisix/apisix/http/service.lua:18: in main chunk
[C]: in function 'require'
/home/ronething/Documents/apisix/apisix/init.lua:35: in main chunk
[C]: in function 'require'
init_by_lua:3: in main chunk
- then, something like
if conf.pass_host == "node" and conf.nodes andincheck_upstream_conffunction may only print error log when check upstream ifin_dpis true, or cause err when create/modify upstream or other resource which need to check upstream_conf both in http and stream subsystem. But we need to refuse to start apisix when the OpenResty is too old and k8s discovery is used in the stream?
so maybe we should consider other solutions? if something i was wrong, please tell me, thanks.
There was a problem hiding this comment.
But we need to refuse to start apisix when the OpenResty is too old and k8s discovery is used in the stream?
Yes. Unlike the upstream conf which is a runtime conf, the wrong discovery conf in the yaml can't be corrected without restarting APISIX.
And we need to provide a clear error message so people don't need to debug it.
| ngx.timer.at(0, timer_runner) | ||
| end | ||
|
|
||
| local function get_endpoint_dict(shm) |
There was a problem hiding this comment.
We can pass the id as the argument, and put the constant kubernetes in this function? There is no need to repeat it.
| function _M.init_worker() | ||
| if not support_process then | ||
| core.log.error("kubernetes discovery not support in subsystem: " | ||
| .. ngx.config.subsystem |
There was a problem hiding this comment.
@spacewander do you mean something like below? .. ngx.config.subsystem .. ", "
if not support_process then
core.log.error("kubernetes discovery not support in subsystem: "
.. ngx.config.subsystem .. ", "
.. "please check if your openresty version >= 1.19.9.1 or not")
return
endThere was a problem hiding this comment.
Err. What I mean is that we can use ',' instead of '..'.
There was a problem hiding this comment.
ok, i see. I will change it later.
* upstream/master: (67 commits) fix: grpc-transcode plugin: fix map data population (apache#8731) change(jwt-auth): unify apisix/core/vault.lua and apisix/secret/vault.lua (apache#8660) feat: stream subsystem support consul_kv service discovery (apache#8633) fix(proxy-mirror): use with uri rewrite (apache#8718) ci: move helper script to the right dir (apache#8691) refactor(pubsub): simpify the get_cmd implementation (apache#8608) feat: stream subsystem support kubernetes service discovery (apache#8640) docs: fix deployment links (apache#8714) fix: remove backslash before slash when encoding (apache#8684) ci: kafka should register port in the zookeeper same as exposed (apache#8672) docs: fix plugin config naming (apache#8701) docs: fix code block (apache#8700) docs: rename kms to secret (apache#8697) docs: replace transparent logos with white background logos (apache#8689) fix: upgrade lua-resty-etcd to 1.10.3 (apache#8668) fix: upgrade casbin to 1.41.3 to improve performance (apache#8676) chore: make send_stream_request more clear (apache#8627) feat: stream subsystem support nacos service discovery (apache#8584) feat: stream subsystem support dns service discovery (apache#8593) refactor(admin): refactor resource routes (apache#8611) ...
Description
Fixes #7779
because of kubernetes service discovery use lua_shared_dict, so i add
discovery_shared_dictswithstreamsuffix to stream subsystem inngx_tpl.lua.for test case, i use
extra_stream_configto get nodes and return response.because of openresty version 1.19.3.2 do not implemented ngx.process API for stream subsystem, so ci failed. see https://github.com/apache/apisix/actions/runs/3874260736/jobs/6605244559
i change openresty version from 1.19.3.2 to 1.19.9.1 to solve this problem, refer: https://openresty.org/en/changelog-1019009.html
Checklist