-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
docs: mention the support for env var in apisix.yaml
#10509
Comments
I'll pick this up tomorrow. |
Great! Thanks for jumping in on it. |
hi @kayx23 I craeted the following route: - uri: /b92/*
upstream:
nodes:
"${{EP_MYHOST_1:=}}:443": 1
type: roundrobin
scheme: https and configured EP_MYHOST_1 environment variable in docker compose file by adding: environment:
- EP_MYHOST_1=b92.net I then started the container and logged in to the running container to confirm: apisix@e9512d0cfdaa:/usr/local/apisix$ echo $EP_MYHOST_1
b92.net However, when I try to access the route, I get the following response: C:\Users\Marko.Kocic>curl http://localhost:9080/b92/
<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body>
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>openresty</center>
<p><em>Powered by <a href="https://apisix.apache.org/">APISIX</a>.</em></p></body>
</html> Apisix logs also shows the same error:
However, when I update apisix.yml file to use host name instead of a variable, everything works ok. At this point, I tend to believe that the documentation is correct that it doesn't mention apisix.yml supporting environment variable substitution. Maybe it should be explicit about not supporting, since initially, I also wrongly believed that it should support it. Or a feat ticket should be created to enable this support in apisix.yml. |
Thanks for checking. I'm not sure what went off in your test yet but I double checked the code and test -- it does look like Let me run some tests. |
I tested and could see in the log that APISIX attempts to resolve the variable but failed: The env var was also properly set in the container as seen in the screenshot. I started the container with: docker run -d \
--name apisix-standalone \
-p9080:9080 -p9443:9443 -p9090:9092 \
-e APISIX_STAND_ALONE=true \
-e UPSTREAM_NODE_HTTPBIN=httpbin.org \
apache/apisix So something's not right here. But I do expect it to work: https://github.com/apache/apisix/blob/master/t/cli/test_standalone.sh#L72-L97 |
Hi @markokocic, as the CLI tests pass just fine, I suspect this has something to do with Docker, though I cannot advise what the issue is atm. To not make this doc effort stagnant, I would reference the CLI tests for this doc update. If you are in the spirit to check further, you can do the same experiment with APISIX installed on host. This should be the scenario covered by the test cases. What do you think? |
hi @kayx23 I don't have a problem with updating docs, but would rather wait until the underlaying issue is fixed. |
Background
The doc currently only provides examples for the usage of env var in
config.yaml
. It could lead users to think onlyconfig.yaml
supports env var and notapisix.yaml
, which isn't true.apisix.yaml
supports env var.In additional, you can not only use env var in yaml values, but also keys. For details, see https://github.com/apache/apisix/blob/master/t/cli/test_standalone.sh
Desired State
Update https://apisix.apache.org/docs/apisix/profile/#using-environment-variables-in-the-configuration-file
Specifically, you should mention
apisix.yaml
supports env varGiven how the section is currently presented, you might want to break the info into smaller sections with h3
###
.The text was updated successfully, but these errors were encountered: