Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletions apisix/discovery/kubernetes/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -619,21 +619,20 @@ end
function _M.dump_data()

local eps = {}
for _, conf in ipairs(local_conf.discovery.kubernetes) do

local id = conf.id
local endpoint_dict = get_endpoint_dict(id)
local discovery_conf = local_conf.discovery.kubernetes
if #discovery_conf == 0 then
local endpoint_dict = get_endpoint_dict()
local keys, err = endpoint_dict:get_keys()
if err then
error(err)
break
end

if keys then
local k8s = {}
for i = 1, #keys do

local key = keys[i]

--skip key with suffix #version
if key:sub(-#"#version") ~= "#version" then
local value = endpoint_dict:get(key)
Expand All @@ -646,11 +645,45 @@ function _M.dump_data()
end

core.table.insert(eps, {
id = conf.id,
id = 0,
endpoints = k8s
})

end
else
for _, conf in ipairs(local_conf.discovery.kubernetes) do
local id = conf.id
local endpoint_dict = get_endpoint_dict(id)
local keys, err = endpoint_dict:get_keys()
if err then
error(err)
break
end

if keys then
local k8s = {}
for i = 1, #keys do

local key = keys[i]

--skip key with suffix #version
if key:sub(-#"#version") ~= "#version" then
local value = endpoint_dict:get(key)

core.table.insert(k8s, {
name = key,
value = value
})
end
end

core.table.insert(eps, {
id = conf.id,
endpoints = k8s
})

end
end
end

return {config = local_conf.discovery.kubernetes, endpoints = eps}
Expand Down
Loading