Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deployment): support standalone #7405

Merged
merged 1 commit into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
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
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
end
Expand Down
26 changes: 26 additions & 0 deletions apisix/cli/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,32 @@ local deployment_schema = {
}
},
required = {"etcd", "role_control_plane"}
},
data_plane = {
properties = {
role_data_plane = {
properties = {
config_provider = {
enum = {"control_plane", "yaml"}
},
},
required = {"config_provider"}
},
certs = {
properties = {
cert = { type = "string" },
cert_key = { type = "string" },
trusted_ca_cert = { type = "string" },
},
dependencies = {
cert = {
required = {"cert_key"},
},
},
default = {},
},
},
required = {"role_data_plane"}
}
}

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"