Skip to content

Commit

Permalink
feat(deployment): support standalone (#7405)
Browse files Browse the repository at this point in the history
Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander authored Jul 14, 2022
1 parent 64eaa38 commit c3b939a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apisix/cli/file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ function _M.read_yaml_conf(apisix_home)
default_conf.apisix.enable_admin = true

elseif default_conf.deployment.role == "data_plane" then
default_conf.etcd = default_conf.deployment.role_data_plane.control_plane
if default_conf.deployment.role_data_plane.config_provider == "yaml" then
default_conf.apisix.config_center = "yaml"
else
default_conf.etcd = default_conf.deployment.role_data_plane.control_plane
end
default_conf.apisix.enable_admin = false
end

Expand Down
43 changes: 43 additions & 0 deletions t/cli/test_standalone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,46 @@ if [ ! $code -eq 200 ]; then
fi

echo "passed: resolve variables in apisix.yaml conf success"

# configure standalone via deployment
echo '
deployment:
role: data_plane
role_data_plane:
config_provider: yaml
' > conf/config.yaml

var_test_path=/test make run
sleep 0.1
code=$(curl -o /dev/null -s -m 5 -w %{http_code} http://127.0.0.1:9080/apisix/admin/routes)
if [ ! $code -eq 404 ]; then
echo "failed: admin API should be disabled automatically"
exit 1
fi

echo "passed: admin API should be disabled automatically"

# support environment variables
echo '
routes:
-
uri: ${{var_test_path}}
plugins:
proxy-rewrite:
uri: ${{var_test_proxy_rewrite_uri:=/apisix/nginx_status}}
upstream:
nodes:
"127.0.0.1:9091": 1
type: roundrobin
#END
' > conf/apisix.yaml

var_test_path=/test make run
sleep 0.1
code=$(curl -o /dev/null -s -m 5 -w %{http_code} http://127.0.0.1:9080/test)
if [ ! $code -eq 200 ]; then
echo "failed: resolve variables in apisix.yaml conf failed"
exit 1
fi

echo "passed: resolve variables in apisix.yaml conf success"

0 comments on commit c3b939a

Please sign in to comment.