Skip to content

Commit

Permalink
feat: 支持容器化混合部署 TencentBlueKing#2620
Browse files Browse the repository at this point in the history
* feat: 支持容器化混合部署 TencentBlueKing#2620

* feat: 支持容器化混合部署 TencentBlueKing#2620

* feat: 服务转发到容器内 TencentBlueKing#2620
  • Loading branch information
owenlxu authored Oct 21, 2024
1 parent 4f9f225 commit 1ee8f6f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/gateway/lua/router_srv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ end
-- 访问限制的工具
local access_util = nil

-- 哪些服务需要转到容器中 --
local service_in_container = {} -- service in container
if config.service_in_container ~= nil and config.service_in_container ~= "" then
for c_service in string.gmatch(config.service_in_container, "([^,]+)") do
table.insert(service_in_container, c_service)
end
end

-- 限制访问频率
if access_util then
local access_result, err = access_util:isAccess()
Expand All @@ -75,6 +83,12 @@ if access_util then
end
end

-- 是否转发到容器服务
if arrayUtil:isInArray(service_name, service_in_container) then
ngx.var.target = config.container_url .. "/" .. service_name
return
end

ngx.var.target = hostUtil:get_addr(service_name)

if ngx.var.assembly ~= nil and ngx.var.assembly ~= "" then
Expand Down
4 changes: 3 additions & 1 deletion support-files/templates/gateway#lua#init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ config = {
port = "__BK_CI_PORT__"
},
security_paths = {
}
},
service_in_container = "__BK_REPO_SERVICE_IN_CONTAINER__",
container_url = "__BK_REPO_URL_CONTAINER__"
}

require("init_common")
Expand Down

0 comments on commit 1ee8f6f

Please sign in to comment.