Background
Use Gitpod as the Apache APISIX development and startup environment, which is convenient for new users to use, develop, and contribute.
Terminology
Apache APISIX
A new generation of API gateways under the Apache Software Foundation, watch the video What’s API Gateway to learn more.
ETCD
The configuration storage center of Apache APISIX, which can be understood as a database (but not completely equivalent).
Gitpod
Developer tools running in the browser (with VS Code embedded). No need to configure the environment, deploy code in our own machines, which is easier to unify the development environment.
Steps
Register and Login GitHub.com
Please follow GitHub’s Docs here.
Fork apache/apisix
Repository
- Visit https://github.com/apache/apisix to enter the homepage of the
apache/apisix
project. - Click the
Fork
button in the upper right corner to enter the following page - Click the
Create fork
button and wait a moment - The fork is successful when your GitHub account name is displayed in the
upper left corner
- Click
Code -> HTTPS -> Copy
(this link will be used below)
Import project to Gitpod
- Visit https://www.gitpod.io/ , click
Try now
, and log in withGitHub
- Select the default option
VS Code Browser
and clickContinue
- Click on
New Workspace
and paste the Repository link copied above - Click this link and go to the following page
- When the following interface is displayed, it means ready (directory on the left, code editing box on the upper right, command line area on the lower right)
Install ETCD
# Go to the parent directory of the apisix folder to install ETCD
cd ..
ETCD_VERSION='3.4.13'
wget https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-linux-amd64.tar.gz
tar -xvf etcd-v${ETCD_VERSION}-linux-amd64.tar.gz && cd etcd-v${ETCD_VERSION}-linux-amd64 && sudo cp -a etcd etcdctl /usr/bin/
nohup etcd >/tmp/etcd.log 2>&1 &
cd ../apisix
Install Dependencies
- See the
Gitpod command line
, the current default is themaster
branch, in this tutorial we use the2.14.1
tag; - Enter the following command in the command line and press
Enter
, the command line will displaygitpod /workspace/apisix (2.14.1)
indicating that the switch is successful;
git checkout 2.14.1
- If you have fork the
apache/apisix
repository before, please execute the following command to synchronize the latest code. Otherwise, please go directly to the next step.
git fetch --tags
git checkout 2.14.1
- Install dependencies and build the project: Enter the following command on the command line and press
Enter
curl https://raw.githubusercontent.com/apache/apisix/master/utils/install-dependencies.sh -sL | bash -
make deps
Run apisix
Execute the following command to start apisix.
make run
Execute the following command to verify that apisix is installed and started successfully.
curl localhost:9080
# After executing the above command, the following content will be displayed, indicating that the startup is successful
# {"error_msg":"404 Route Not Found"}
Stop apisix
make stop
Rebuild the project after editing codes
make stop
make run
Submit code changes
Using the file directory panel on the left side of Gitpod, select the code you want to commit.
Advanced
If you want to operate the Apache APISIX instance through the
Admin API
, and createRoutes
,Upstreams
, etc., you can continue reading below.
The Apache APISIX instance exposes the Admin API for operators to call. To avoid malicious access, you need to carry the key when calling the API. You can find the Apache APISIX default key
by viewing the /conf/config.yaml
file. The following is an example of calling: If you need to query the list of routes that have been created, you can access:
curl -i -X GET http://127.0.0.1:9080/apisix/admin/routes -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1"
If the key is correct, it will return something like this:
HTTP/1.1 200 OK
Date: Thu, 19 May 2022 03:05:28 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Server: APISIX/2.14.1
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: *
Access-Control-Max-Age: 3600
# The above is the HTTP Response Header of the HTTP request, but please focus on the following: If nodes is empty, it means that no Route is currently created.
{"action":"get","count":0,"node":{"nodes":[],"key":"\/apisix\/routes","dir":true}}
Other
If you encounter any questions, please join the Slack community and ask for help.