Installation and Configuration of Apache APISIX 3.2 LTS and ETCD 3.5.4 API Gateway

APISIX is an API gateway that helps manage microservices, offering a scalable platform for all your APIs and microservices with high performance and security.

With its plugin-based architecture, APISIX allows for customization and extension of the platform to meet specific developer and company needs. Additionally, APISIX is capable of handling high traffic loads, making it an essential tool for companies that handle a large amount of API traffic.

APISIX also offers a wide variety of features for API creation, management, and scaling, such as API routing, rate limiting, load balancing, authentication, authorization, and more. The platform is highly customizable and scalable, allowing companies to adapt and grow easily.

Hardware and Software Requirements

Apache APISIX is a highly efficient API management platform that can run smoothly for thousands of requests with just 1 vCore, 2GB of RAM, and 20GB of disk. Because it primarily acts as a router, the resource consumption is minimal.

In this article, we will cover the installation and configuration of APISIX on a single server with the following specifications:

  • Sistema Operativo: Debian 11
  • CPU: 1Vcore
  • RAM: 2GB
  • Disco: 10GB
  • Apache Apisix 3.2 LTS
  • ETCD 3.5.4

*For production environments, it is recommended to install Apache APISIX on a cluster of at least three nodes. This way, it is possible to configure ETCD in a cluster and a load balancer from Google, AWS, or Cloudflare to distribute the workload among the nodes in the cluster.

This will not only increase the availability of the platform, but also improve its scalability and reliability in the event of unexpected traffic spikes. Furthermore, with a properly configured load balancer, a uniform distribution of workload can be ensured across the cluster, ensuring optimal performance at all times.

Prerequisite Installation

To start with the installation, it is necessary to install the previous dependencies. In this sense, we will proceed to install ETCD using the following commands:

We update the operating system:

# apt update & apt upgrade -y

We install git, vim, wget, curl, gnupg, and gnupg2, which we will need for the installation of ETCD:

# apt install git vim wget curl gnupg gnupg2 -y

We generate three environment variables to indicate the version and where to download ETCD from:

# ETCD_VER=v3.5.4

We download ETCD:

# curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
# cd /tmp

We extract ETCD from the downloaded tar.gz file:
# tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test --strip-components=1

Delete the download
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz

We access the extracted directory and move the binaries

# cd /tmp/etcd-download-test
# mv etcd etcdctl etcdutl /usr/local/bin

We check the versions:
root@debian:/tmp/etcd-download-test# etcd --version
etcd Version: 3.5.4
Git SHA: 08407ff76
Go Version: go1.16.15
Go OS/Arch: linux/amd64

root@debian:/tmp/etcd-download-test# etcdctl version
etcdctl version: 3.5.4
API version: 3.5

root@debian:/tmp/etcd-download-test# etcdutl version
etcdutl version: 3.5.4
API version: 3.5

We create directories for the configuration files and data storage:
# mkdir -p /var/lib/etcd/
# mkdir /etc/etcd

We create a user and group for ETCD without shell access.
# /usr/sbin/groupadd --system etcd
# /usr/sbin/useradd -s /sbin/nologin --system -g etcd etcd

We assign permissions:

# chown -R etcd:etcd /var/lib/etcd/

We configure Systemd for automatic startup when the server starts:
# vim /etc/systemd/system/etcd.service

Description=etcd key-value store



# systemctl daemon-reload
# systemctl start etcd.service
# systemctl enable etcd.service
# systemctl status etcd.service

Check that ETCD has run correctly:

# ss -tunelp | grep 2379

# etcdctl endpoint health

Once these simple steps are completed, ETCD will be installed and you can proceed with the installation of APISIX.

Installation of Apache APISIX

To simplify the installation process and ensure efficient management and updates of APISIX, it is recommended to use the available repositories. The following are the necessary steps to add the corresponding repository:

# echo "deb bullseye openresty" | tee /etc/apt/sources.list.d/openresty.list

# wget -O - | apt-key add -
# echo "deb bullseye main" | tee /etc/apt/sources.list.d/apisix.list
# apt update

If installing the pubkey for openresty gives an error, the solution would be:# curl -O
# apt-key add pubkey.gpg

This would allow us to perform the update.

# apt install -y apisix=3.2.0-0

Inicializamos Apisix

# ulimit -n 2048

# apisix init

# apisix start

First configurations recommendations

  • The configuration file for Apisix is located at /usr/local/apisix/config-default.yaml, which we need to copy to /usr/local/apisix/config.yaml.
  • Comment out the listener for port 9080 and leave only port 9443.
  • If access to the API gateway is done from any location, edit port 9443 to 443, since many internet providers have port 9443 blocked.
  • Generate a new admin key, as it would be unsafe to keep the default one.

After configuring Apisix, we can now run Apisix.

# systemctl enable apisix
# systemctl start apisix
# systemctl status apisix

Great, now that we have followed the previous steps, the installation of APISIX on the system will have been completed. However, it is important to mention that certain additional configurations can be made to ensure proper and improved operation of the tool.

For example, APISIX can be configured to work with a load balancer or caching system, among other options. Likewise, access and security of APISIX can be customized by creating API keys, implementing authentication and authorization, among other functionalities.

Therefore, once the installation is completed, it is recommended to review and adjust the corresponding configurations to ensure proper implementation and use of APISIX in your project.