Oracle Backend for Spring Boot and Microservices
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Apache APISIX Gateway

Apache APISIX is an open source cloud native API platform that supports the full lifecycle of API management including publishing, traffic management, deployment strategies, and circuit breakers.

Accessing Apache APISIX dashboard

Oracle Backend for Spring Boot and Microservices deploys Apache APISIX Gateway and Dashboard in the apisix namespace. The gateway is exposed through the external load balancer and ingress controller. To access the Apache APISIX Dashboard, you must use the kubectl port-forward command to create a secure channel to service/apisix-dashboard. Process the following steps:

  1. To expose the Apache APISIX Dashboard using this command:

    kubectl port-forward -n apisix svc/apisix-dashboard 8080:80
    
  2. Open the Apache APISIX Dashboard URL: http://localhost:8080

    • username: admin
    • Password is retrieved using the following command:
    kubectl get secret -n apisix apisix-dashboard -o jsonpath='{.data.conf\.yaml}' | base64 -d | grep 'password:'; echo
    

    NOTE: Oracle recommends that you change the default password when you log in the first time. Even though the dashboard is not accessible externally, Oracle still recommends using strong passwords to maximize security.

    APISIX Login
    APISIX Login

Enable tracing in APISIX routes

The OpenTelemetry plugin is enabled by default in APISIX. To enable tracing for your routes add the following to the route configuration:

"plugins": {
    "opentelemetry": {
        "sampler": {
            "name": "always_on"
        }
    }
}

For more configuration option for the OpenTelemetry plugin; APISIX Documentation

Exposing a Spring Application Through the API Gateway and Load Balancer

Once you have your application deployed and running, you may want to expose it to the outside world. Some applications may not need to be exposed if they are only called by other applications in the platform. To expose your application, create a “route” in the Apache APISIX API Gateway by processing these steps:

  1. Create a route to the service. For example:

    1. In the Apache APISIX Dashboard, click Routes in the menu on the left side.
    APISIX Routes
    APISIX Routes
    1. Click Create to create a new route.

    2. Fill out the necessary details (anything not mentioned here can be left at the default value). For example, for the “slow service” to be included in the Sample Applications, provide these details:

    • name = slow

    • path = /fruit*

    • method = get, options

    • upstream type = service discovery

    • discovery type = eureka

    • service name = SLOW (note that this is case sensitive, this is the key from the Eureka dashboard)

      NOTE: The API Gateway is pre-configured with both “Eureka” and “Kubernetes” discovery types. For Eureka, the service name is the key used to deploy the service in Eureka, which is normally the value from spring.application.name in the Spring Boot configuration file (src/main/resources/application.yaml), in uppercase characters. For Kubernetes, the service name is in the format namespace/service:port where namespace is the Kubernetes namespace in which the Spring Boot application is deployed, service is the name of the Kubernetes service for that application, and port is the name of the port in that service. If you deployed your Spring Boot application with the Oracle Backend for Spring Boot and Microservices CLI, the port name will be spring. For example, an application called slow-service deployed in the my-apps namespace would be my-apps/slow-service:spring.

      APISIX Routes Step1
      APISIX Routes Step1

      APISIX Routes Step2
      APISIX Routes Step2

      APISIX Routes Step3
      APISIX Routes Step3

    1. Save the route that you created.
      APISIX Routes Step4
      APISIX Routes Step4

      APISIX Routes Step5
      APISIX Routes Step5

  2. Test a route to the service. For example:

    1. Get the Apache APISIX Gateway external IP using this command:
    kubectl -n ingress-nginx get svc ingress-nginx-controller
    

    The result of the command should look similar to this:

    NAME                       TYPE           CLUSTER-IP      EXTERNAL-IP       PORT(S)                      AGE
    ingress-nginx-controller   LoadBalancer   10.96.172.148   146.235.207.230   80:31393/TCP,443:30506/TCP   25h
    
    1. Call the API using the Apache APISIX Gateway address plus path. For example:
    curl http://APISIX_IP/fruit
    

    You should get “banana” or “fallback fruit is apple” back as the response.