Wu Shuyang, Apache APISIX Committer, API7 development engineer. At present, he is mainly responsible for the practice of chaos engineering on APISIX. By reading this article, you’ll learn how to use our new migration tool to smoothly migrate Kong to Apache APISIX to one-click.

Apache APISIX is a production available, open source, seven-tier, full traffic processing platform that acts as an API gateway to handle business entry traffic with extremely high performance, ultra-low latency, official support for Dashboard and over 50 plug-ins. If you are using Kong and are interested in APISIX but struggling To get started, try our new open source migration tool Kong-to-Apisix To help you smooth migration with one click.

Project function

Kong-to-apisix uses the declarative configuration files of Kong and APISIX To realize the migration of configuration data and make corresponding adaptation according To the different architectures and functions of the two sides. Currently we support configuration migration for Route, Service, Upstream, Target, Consumer, and Rate Caching, Proxy Caching, and Key Authentication on Kong. A minimal demo was completed using Kong’s Getting Started Guide as an example.

Method of use

  1. Use Deck to export the Kong declarative configuration file

Specific steps reference: docs.konghq.com/deck/1.7.x/…

  1. Download the repository and run the migration tool, which generates a declarative configuration fileapisix.yamlTo be used
$ git clone https://github.com/api7/kong-to-apisix
​
$ cd kong-to-apisix
​
$ make build
​
$ ./bin/kong-to-apisix migrate --input kong.yaml --output apisix.yaml
​
migrate succeed
Copy the code
  1. useapisix.yamlConfigure APISIX. For details, seeApisix.apache.org/docs/apisix….

The Demo test

  1. Ensure the normal operation of Docker, deploy the test environment, and use docker-compose to pull up APISIX and Kong
git clone https://github.com/apache/apisix-docker
cd kong-to-apisix
./tools/setup.sh
Copy the code
  1. Add a configuration for Kong and test it according to Kong’s Getting Started Guide: a. Expose services through Service and Route for routing and forwarding. Set Rate Limitation and Proxy Caching to c. Set Key Authentication plug-in for Authentication d. Set load balancing using Upstream and Target
./examples/kong-example.sh
Copy the code
  1. Export Kong’s declarative configuration file to kong.yaml

    go run ./cmd/dumpkong/main.go
    Copy the code
    1. Run the migration tool and importkong.yamlThe APISIX configuration file is generatedapisix.yamlTo the docker volumes
    export EXPORT_PATH=./repos/apisix-docker/example/apisix_conf
    ​
    go run ./cmd/kong-to-apisix/main.go
    Copy the code
    1. On the APISIX side, verify that routes, load balancing, and plug-ins are running properly after migration

      A. Test the key Auth plug-in

    Curl - k - I - m - o/dev/null - 20 s - w % {http_code} http://127.0.0.1:9080/mock # output: 401Copy the code

    B. Test the Proxy Cache plug-in

    # the access for the first time the curl - k - I - s - o/dev/null "apikey: apikey" - http://127.0.0.1:9080/mock - H H "Host: "# mockbin.org see if got cached curl - I - s - X GET http://127.0.0.1:9080/mock - H" apikey: apikey "-h" Host: Mockbin.org "# output: # HTTP/1.1 200 OK #... # Apisix-Cache-Status: HITCopy the code

    C. Test the Limit Count plug-in

    for i in {1.. 5}; Do the curl - s - o/dev/null - X GET http://127.0.0.1:9080/mock - H "apikey: apikey" - H "Host: Mockbin.org "done curl - k - I - m - o/dev/null - 20 s - w % {http_code} http://127.0.0.1:9080/mock - H" apikey: apikey" -H "Host: mockbin.org" # output: 429Copy the code

    D. Test load balancing

    httpbin_num=0 mockbin_num=0for i in {1.. 8}; Do body = $(curl - k - http://127.0.0.1:9080/mock - I - s H "apikey: apikey -h Host: mockbin.org") if [[ $body == *"httpbin"* ]]; then httpbin_num=$((httpbin_num+1)) elif [[ $body == *"mockbin"* ]]; Then mockbin_num=$((mockbin_num+1)) fi sleep 1.5done echo "${httpbin_num}", mockbin number: "${mockbin_num} # output: # httpbin number: 6, mockbin number: 2Copy the code

    conclusion

    Kong-to-apisix GitHub repository is under the Roadmap for the migration tool. Welcome To visit the GitHub repository of Kong-to-Apisix at github.com/api7/kong-t… , test and use Kong-to-apisix. Anyone who is interested in this project is welcome to come along and contribute to this project! Any questions can be discussed in the Issues section of the repository.

    About the Apache APISIX