Essentially, the Apache APISIX controller will configure the same standard Dapr Annotations to inject DAPrd Sidecar. Exposing this SIDecar allows external applications to communicate with DAPR-enabled applications in the cluster.

The following figure shows the architectural flow in the actual project:

Basic project overview

Apache APISIX Ingress

In the K8s ecosystem, Ingress is a resource that represents the entrance of K8s traffic. To make it effective, an Ingress Controller needs to monitor the Ingress resources in K8s, analyze the corresponding rules of these resources and actually carry the traffic. In current trends, Ingress Controller implementations like Kubernetes Ingress Nginx are the most widely used.

APISIX Ingress is another implementation of Ingress Controller. The difference between Kubernetes Ingress Nginx and Kubernetes Ingress Nginx lies in that APISIX Ingress uses Apache APISIX as the actual data plane to carry the service traffic. As shown in the figure below, when a user requests a specific service /API/ web page, the entire business traffic/user request is transmitted to the K8s cluster through an external agent, and then APISIX Ingress for subsequent processing.

As you can see from the image above, APISIX Ingress is divided into two parts. One part is the APISIX Ingress Controller, which serves as the control surface for configuration management and distribution. APISIX Proxy Pod is responsible for carrying business traffic through Custom Resource Definitions (CRD). Apache APISIX Ingress supports native K8s Ingress resources in addition to custom resources.

More details may refer to: www.apiseven.com/zh/blog/api…

Dapr

Dapr is a portable, event-driven runtime. It makes it easy for developers to build resilient, stateless, and stateful applications that run on the cloud and Edge, and includes multiple languages and developer frameworks.

Today, we are experiencing a wave of cloud applications. Developers are familiar with Web + database application architectures (such as classic 3-tier designs), but not with microservice application architectures that are distributed in nature. Developers want to focus on business logic while relying on the platform to inject scalability, resiliency, maintainability, resilience, and other attributes of local cloud architecture into their applications.

That’s where Dapr comes in.

Dapr codifies best practices for building microservice applications into open, stand-alone building blocks, enabling users to build portable applications using a language and framework of their choice. Each building block is completely independent and you can use one or more of them in your application.

In addition, Dapr is platform-agnostic, meaning users can run applications locally on any Kubernetes cluster and other managed environments that integrate with Dapr.

More details can be found at: docs. Dappl. IO/zh-Hans /con…

The practice started

Environment to prepare

  • Kubernetes 1.19+ cluster, on which Dapr has been configured

  • The Helm CLI 3X is installed

  • Kubectl CLI is installed and configured to access the cluster

  • Optional: OpenSSL for creating self-signed certificates

  • The Helm Chart version of Apache APISIX is 0.7.2+. Specific reasons: github.com/apache/apis…

Step 1: Configure the Apache APISIX Helm

Add the latest Helm Chart repo to the Apache APISIX controller by running the following command:

$ helm repo add apisix https://charts.apiseven.com
$ helm repo update
Copy the code

Step 2: Create the Apache APISIX Ingerss namespace

Ensure that the current Kubectl context points to the correct Kubernetes cluster, then run the following command:

kubectl create namespace ingress-apisix
Copy the code

Step 3: Install the APISIX controller that supports Dapr

Use the following to create a file called Dabr-Annotations. Yaml to set annotations on Apache APISIX Proxy Pod.

apisix: podAnnotations: dapr.io/enabled: "true" dapr.io/app-id: " apisix-gateway" dapr.io/app-port: "9080" dapr.io/enable-metrics: "true" dapr.io/metrics-port: "9099" dapr.io/sidecar-listen-addresses: 0.0.0.0 dapr. IO/config: ingress - apisix - configCopy the code

Note: App-port tells DAPRD which port sidecar Proxy is listening on. For a complete list of supported annotations, refer to the Dapr Kubernetes POD annotation specification [1].

Here’s an example of dapar-Annotations that I personally installed on AKS.

apisix: podAnnotations: dapr.io/app-id: apisix-gateway dapr.io/app-port: '9080' dapr.io/enable-metrics: IO /config: 'true' dabr. IO /enabled: 'true' dabr. IO /metrics-port: '9099' dabr. IO /sidecar-listen-addresses: 0.0.0.0 dabr. IO /config: ingress-apisix-config gateway: type: LoadBalancer ingress-controller: enabled: true dashboard: enabled: trueCopy the code

Next run the following command (referencing the above file) :

helm install apisix apisix/apisix -f dapr-annotations.yaml -n ingress-apisix
Copy the code

Step 4: Create the Dapr Sidecar resource for Apache APISIX

First, configure Apache APISIX upstream-Apisix-DAPR.

Enter apisix-gateway-dapr as the host name and 3500 as the port number.

{
"nodes": [
{
"host": "apisix-gateway-dapr",
"port": 3500,
"weight": 1
}
],
"retries": 1,
"timeout": {
"connect": 6,
"read": 6,
"send": 6
},
"type": "roundrobin",
"scheme": "http",
"pass_host": "pass",
"name": "apisix-dapr"
}
Copy the code

Then configure the Apache APISIX service apisix-gateway-DAPr, and select Apisix-DAPr for the upstream service.

{
"name": "apisix-gateway-dapr",
"upstream_id": "376187148778341098"
}
Copy the code

Step 5: Deploy the test sample project

HTTPBin is a tool written in Python+Flask that covers a variety of HTTP scenarios and returns for each interface. Next, we use Kennethreitz /httpbin as a sample project to demonstrate.

``
kubectl apply -f 01.namespace.yaml
kubectl apply -f 02.deployment.yaml
kubectl apply -f 03.svc.yaml
``
Copy the code

The figure above assumes a microservice running with Dapr app-id Kennethreitz-httpbin.

Path matching rewriting

Here are some additional Settings for path matching. For example, the request gateway is /httpbin/*, the back-end receive path should be /*, and the intermediate httpbin serves only as the service name identifier.

On namespace-enabled hosting platforms, Dapr application ids are in a valid FQDN format, including the target namespace. For example, the following string contains the application ID (svC-kennethreitZ-httpbin) and the namespace in which the application is running (kind-test).

Finally can visit: http://20.195.90.43/httpbin/get to view your agent was successful.

Additional notes

Of course, Apache APISIX and APISIX Ingress Controller can also be deployed directly in Kubernetes using the Apache APISIX official Helm repository. In this way, Apache APISIX can be directly used as the gateway to carry service traffic on the data plane of APISIX Ingress Controller.

Finally, Dapr was injected into Apache APISIX Proxy Pod through Sidecar Annotations, and the microservices in the cluster were called through the service invocation module to realize the complete process deployment.

Example Delete the Apache APISIX controller

If you want to delete the Apache APISIX controller at the end of the project, follow the command below (remember to delete the namespace ingress-apisix you created earlier).

helm delete apisix -n ingress-apisix
Copy the code

Upcoming events

After the first session of Apache APISIX was held, people commented in the comments section that they were full of harvest, not satisfied and looking forward to the next session!

At 19:30, November 30th, the second phase of the big guy came face-to-face as promised, This week’s guests are Yunyunco-founder and CTO Yang Pan, Co-founder and Chief Architect of Kyligence Shi Shaofeng, Founder of KubeSphere Zhou Xiaosi, Apache APISIX Committer-Wang Ye and in return, In the face of workplace change and transformation bifurcated, technical people engaged in the field of To B issues and challenges.

  • Why is it difficult for Chinese To B enterprises To develop?

  • What are the reasons for the success of technical people in THE field of To B, and what are the reasons for the failure of transformation?

  • Is it the only way to do technology when you are young and management when you are old? What are other ways to grow your career?

  • What are the differences between open source infrastructure software To B commercialization and traditional infrastructure software To B commercialization?

The group of communication

Scan the qr code below, or reply to [live exchange group] in the background of the official account, join the Apache APISIX live exchange group online, learn more about the community dynamics!