Get APISIX
Apache APISIX is a dynamic, real-time, and high-performance API Gateway. It is a top-level project of the Apache Software Foundation.
You can use APISIX API Gateway as a traffic entrance to process all business data. It offers features including dynamic routing, dynamic upstream, dynamic certificates, A/B testing, canary release, blue-green deployment, limit rate, defense against malicious attacks, metrics, monitoring alarms, service observability, service governance, and more.
In addition, the project also offers APISIX Ingress Controller, an open-source ingress controller that allows you to manage external client traffic to services running in a Kubernetes cluster. The APISIX Ingress Controller routes incoming traffic to specific services based on the requested URL path or hostname.
This tutorial covers two installation methods for you to quickly get started with APISIX:
- Start APISIX in a Docker container with a quickstart script and configure APISIX using Admin API
- Start APISIX Ingress Controller on a kind Kubernetes cluster.
Alternatively, you can also use API7 Cloud, a cloud service, to manage APISIX.
Prerequisite(s)â
- Docker
- Kubernetes
Get APISIXâ
- Docker
- Kubernetes
To provide a better experience in this tutorial, the requirement of Admin API key is switched off by default. Please turn on the API key requirement of Admin API in the production environment.
Start APISIX in Docker with the quickstart script:
curl -sL "https://run.api7.ai/apisix/quickstart" | sh
The script starts two Docker containers, apisix-quickstart
and etcd-quickstart
in the apisix-quickstart-net
Docker network, where etcd is used to store APISIX configurations.
You should see the following message once APISIX is ready:
â APISIX is ready!
(Optional) Install API Declarative CLI (ADC)â
You can also install the API Declarative CLI (ADC) to manage APISIX declaratively:
curl -sL "https://run.api7.ai/adc/install" | bash
To verify the installation, run:
adc help
You should see the following response:
Usage: adc [options] [command]
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
ping [options] Verify connectivity with backend
dump [options] Dump configurations from the backend
diff [options] Show the difference between local and backend configurations
sync [options] Sync local configurations to backend
convert [options] Convert other API spec to ADC configurations
lint [options] Check provided configuration files, local execution only, ensuring inputs meet ADC requirements
help [command] display help for command
By default, the backend is set to apisix
and the server is set to http://localhost:9180
. To verify connectivity with APISIX, run:
adc ping
You should see the following response:
Connected to the "apisix" backend successfully!
See the Command Reference for more details on the available commands.
In this section, you will be creating a kind cluster and starting APISIX Ingress Controller on the cluster.
Start a Kind Cluster
Ensure you have Docker running and start a kind cluster:
kind create cluster
You should see the following response:
Creating cluster "kind" ...
â Ensuring node image (kindest/node:v1.30.0) đŧ
â Preparing nodes đĻ
â Writing configuration đ
â Starting control-plane đšī¸
â Installing CNI đ
â Installing StorageClass đž
Set kubectl context to "kind-kind"
You can now use your cluster with:
kubectl cluster-info --context kind-kind
Create Namespace
Create a new namespace ingress-apisix
:
kubectl create namespace ingress-apisix
You should see a response:
namespace/ingress-apisix created
Set Preferred Namespace
Set the namespace to ingress-apisix
so that subsequent commands do not need to explicitly specify the namespace every time:
kubectl config set-context --current --namespace=ingress-apisix
To verify if the default namespace is modified:
kubectl config view --minify | grep namespace:
You should see the namespace has been set:
namespace: ingress-apisix
Install APISIX Ingress Controller
Add the APISIX and Bitnami chart repositories and update:
helm repo add apisix https://charts.apiseven.com \
&& helm repo add bitnami https://charts.bitnami.com/bitnami \
&& helm repo update
Install APISIX Ingress controller:
helm install apisix apisix/apisix \
--set service.type=NodePort \
--set ingress-controller.enabled=true \
--set ingress-controller.config.kubernetes.enableGatewayAPI=true \
--set ingress-controller.config.apisix.adminAPIVersion=v3
âļ Configure the service type as NodePort
, which can be changed to LoadBalancer
type if you would like to use a load balancer to expose the service.
⡠Install APISIX Ingress Controller along with the APISIX chart.
⸠Enable the Gateway API.
âš Use the v3 Admin API.
You should see a response showing APISIX Ingress Controller is deployed:
NAME: apisix
LAST DEPLOYED: Thu May 30 14:19:38 2024
NAMESPACE: ingress-apisix
STATUS: deployed
REVISION: 1
TEST SUITE: None
Verify Installationâ
- Docker
- Kubernetes
Send a request to see if APISIX is running:
curl -sI "http://127.0.0.1:9080" | grep Server
If everything is ok, you should see the APISIX version:
Server: APISIX/3.11.0
APISIX is now installed and running.
Check Pod Statuses
To verify that APISIX Ingress Controller is installed and running, check the status of the pods:
kubectl get pods
If everything is ok, you should see that all pods in the Running
status:
NAME READY STATUS RESTARTS AGE
apisix-897965b56-47nrq 1/1 Running 0 8m
apisix-etcd-1 1/1 Running 0 8m
apisix-etcd-2 1/1 Running 0 8m
apisix-etcd-0 1/1 Running 0 8m
apisix-ingress-controller-77bbf59f54-7gcwb 1/1 Running 0 8m
Check Service Statuses
You can also check the status of the services:
kubectl get services
If everything is ok, you should see a response similar to the following:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
apisix-admin ClusterIP 10.96.155.100 <none> 9180/TCP 8m
apisix-etcd ClusterIP 10.96.117.186 <none> 2379/TCP,2380/TCP 8m
apisix-etcd-headless ClusterIP None <none> 2379/TCP,2380/TCP 8m
apisix-gateway NodePort 10.96.9.154 <none> 80:30883/TCP 8m
apisix-ingress-controller ClusterIP 10.96.109.21 <none> 80/TCP 8m
apisix-ingress-controller-apisix-gateway NodePort 10.96.212.53 <none> 80:30310/TCP,443:31174/TCP 8m
Verify Installed APISIX Version
To verify the installed APISIX version, first map port 80
of the apisix-gateway
service to port 8080
on the local machine:
kubectl port-forward svc/apisix-gateway 9080:80 &
Then send a request to the gateway:
curl -sI "http://127.0.0.1:9080" | grep Server
If everything is ok, you should see the APISIX version:
Server: APISIX/3.11.0
If you would like to use a load balancer to expose the service on the kind cluster as an alternative to port forwarding, see load balancer kind documentation.
APISIX Ingress Controller is now installed and running.
Next Stepsâ
Please keep the APISIX or APISIX Ingress Controller instance started in this tutorial running to proceed with the following tutorials:
The APISIX instance started with the quickstart script and the APISIX Ingress Controller instance started with kind are not optimized for production. For production installation, please see the production installation options for more information.