KubeSphere introduction

KubeSphere is a deep cloud native application system built in Kubernetes. IT is fully open source, supports multi-cloud and multi-cluster management automation, provides full-stack IT operation and maintenance capabilities, and simplifies enterprise DevOps workflow. Its architecture makes it easy to integrate applications with native ecosystem components in the cloud plug and play.

A full-stack multi-pipe container platform, KubeSphere provides an operation-friendly shape operation interface to help enterprises build a powerful and specialized container. KubeSphere provides users with reporting capabilities for building an enterprise-class Kubernetes environment, Multi-cloud and multi-cluster management, Kubernetes management, DevOps, life cycle management, micro-service management (service grid), and collection, service and network, multi-insight management, monitoring resource logs, events and audit, storage query management, access control, GPU support, network policy, supervision management and security management, etc.

Apache APISIX introduction

Apache APISIX is a pseudo-open source, dynamic cloud native gateway, which was donated to the Apache Foundation by Shenzhen Tributary Technology Co., LTD in 2019. It has become a popular project of the Apache Foundation and the latest portal project on GitHub. Apache APISIX covers API gateway, LB, Kubernetes Ingress, Service Mesh and many other scenarios.

postconditions

The existing Kubernetes cluster has been updated with KubeSphere management.

Deploy Apache APISIX and Apache APISIX Ingress Controller

We can refer to KubeSphere’s documentation to enable KubeSphere’s AppStore, or use Apache APISIX’s Helm repository for development. Here, we deploy directly using Apache APISIX’s Helm repository.

Run the following command to add the Helm repo of Apache APISIX and deploy it.

➜ ~ helm repo add apisix https://charts.apiseven.com "apisix" has had been added to the repositories ➜ ~ helm repo add Bitnami https://charts.bitnami.com/bitnami "bitnami" has had been added to the repositories ➜ ~ helm repo update ➜ ~ Kubectl create ns apisix namespace/apisix created ➜ ~ helm install apisix apisix/apisix --set gateway.type=NodePort -- Set ingress-controller.enabled=true -- Namespace apisix W0827 18:19:58.504653 294386 warnings. Go :70] Apiextensions. K8s. IO/v1beta1 CustomResourceDefinition is deprecated in v1.16 +, unavailable in v1.22 +; use apiextensions.k8s.io/v1 CustomResourceDefinition NAME: apisix LAST DEPLOYED: Fri Aug 27 18:20:00 2021 NAMESPACE: apisix STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: 1. Get the application URL by running these commands: export NODE_PORT=$(kubectl get --namespace apisix -o jsonpath="{.spec.ports[0].nodePort}" services apisix-gateway) export NODE_IP=$(kubectl get nodes --namespace apisix -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORTCopy the code

Verify that it has been successfully implemented and running:

➜ ~ kubectl-n apisix get Pods NAME READY STATUS RESTARTS AGE apisix-77d7545d4D-cvDHs 1/1 Running 0 4m7s apisix-etcd-0 1/1 Running 0 4m7s apisix-etcd-1 1/1 Running 0 4m7s apisix-etcd-2 1/1 Running 0 4m7s apisix-ingress-controller-74c6b5fbdd-94ngk 1/1 Running 0 4m7sCopy the code

You can see that all the related pods are working properly.

Deployment demonstration project

We use kennethreitz/httpbin as a sample project to demonstrate. Deployment is also done directly in KubeSphere.

Select services – Stateless services are easy to create.

After the service and load interface of KubeSphere has been visually expanded successfully, you can also directly check whether it has been expanded successfully under the terminal.

➜ ~ kubectl get Pods, svc-L app=httpbin NAME RESTARTS AGE pod/ httpbin-v1-7d6dC7d5F-5LCmg 1/1 Running 0 48s NAME TYPE cluster-ip external-ip PORT(S) AGE service/httpbin ClusterIP 10.96.0.5 < None > 80/TCP 48sCopy the code

Use Apache APIS as the gateway proxy

Let’s start by demonstrating how to use Apache APIIX as a service in the gateway proxy Kubernetes.

root@apisix:~$ kubectl -n apisix exec -it `kubectl -n apisix get pods -l app.kubernetes.io/name=apisix -o name` -- bash Bash - 5.1 # curl httpbin. Default/get {" args ": {}," headers ": {" Accept" : "* / *", "the Host" : "httpbin. Default", "the user-agent" : "Curl / 7.77.0"}, "origin" : "10.244.2.9", "url" : "http://httpbin.default/get"}Copy the code

You can see a sample project with normal access in The Pod of Apache APISIX. The following uses the example project of Apache APISIX for proxy.

Using curl to create a route to the admin interface of Apache APISIX. Forward all requests with host header httpbin.org to the actual application service httpbin.default:80.

Bash - 5.1 # curl "http://127.0.0.1:9180/apisix/admin/routes/1" - H "X - API - KEY: edd1c9f034335f136f87ad84b625c8f1" -X PUT -d ' { "uri": "/get", "host": "httpbin.org", "upstream": { "type": "roundrobin", "nodes": { "httpbin.default:80": 1}}} ' {"node":{"key":"\/apisix\/routes\/1","value":{"host":"httpbin.org","update_time":1630060883,"uri":"\/*","create_time":16 30060883,"priority":0,"upstream":{"type":"roundrobin","pass_host":"pass","nodes":{"httpbin.default:80":1},"hash_on":"var s","scheme":"http"},"id":"1","status":1}},"action":"set"}Copy the code

You should get output similar to the one above, then verify that the proxy succeeded:

Bash - 5.1 # curl http://127.0.0.1:9080/get - H "HOST: httpbin.org" {" args ": {}," headers ": {" Accept" : "* / *", "the HOST" : "Httpbin.org", "the user-agent" : "curl / 7.77.0", "X - Forwarded - Host" : "httpbin.org"}, "origin" : "127.0.0.1", "url" : "http://httpbin.org/get" }Copy the code

The output above shows that the sample project’s traffic has been brokered through Apache APISIX. Next, let’s try accessing the sample project outside the cluster via Apache APISIX.

root@apisix:~$ kubectl -n apisix get svc -l app.kubernetes.io/name=apisix NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE Apisix-admin ClusterIP 10.96.33.97 < None > 9180/TCP 22m Apisix-gateway NodePort 10.96.126.83 < None > 80:31441/TCP 22mCopy the code

When deployed using Helm Chart, the Apache APISIX port is exposed via NodePort by default. We use the port of Node IP + NodePort for access testing.

Root @ apisix: ~ $curl http://172.18.0.5:31441/get - H "HOST: httpbin.org" {" args ": {}," headers ": {" Accept" : "* / *", "the Host" : "httpbin.org", "the user-agent" : "curl / 7.76.1", "X - Forwarded - Host" : "httpbin.org"}, "origin" : "10.244.2.1", "url" : "http://httpbin.org/get"}Copy the code

As you can see, Apache APISIX is already available outside the cluster as a gateway proxy for Kubernetes services within the cluster.

Use the APISIX Ingress Controller agent service

The Apache APISIX Ingress Controller will automatically synchronize the routing rules to Apache APISIX to complete the proxy of the service.

Note we added kubernetes. IO/ingress. Class: apisix annotation configuration, used to support the cluster more ingress – controller.

After saving, you can see the following interface:

Test whether the agent is successful in terminal:

Root @ apisix: ~ $curl http://172.18.0.5:31441/get - H "HOST: http-ing.org" {" args ": {}," headers ": {" Accept" : "* / *", "the Host" : "http-ing.org", "the user-agent" : "curl / 7.76.1", "X - Forwarded - Host" : "http-ing.org"}, "origin" : "10.244.2.1", "url" : "http://http-ing.org/get"}Copy the code

You can see that the proxy is working.

In addition to the above methods, Apache APISIX Ingress Controller extends Kubernetes via CRD. You can also expose services in Kubernetes by publishing custom resources such as ApisixRoute.

conclusion

You can deploy Apache APISIX and APISIX Ingress Controller directly in KubeSphere using Apache APISIX’s official Helm repository. And Apache APISIX can be used as a gateway, or APISIX Ingress Controller data plane to carry business traffic.

future

Apache APISIX has partnered with the KubeSphere community to find Apache APISIX directly in KubeSphere’s own application repository, without manually adding the Helm repository.

About the Apache APISIX

Apache APISIX is a dynamic, real-time, high-performance open source API gateway that provides rich traffic management features such as load balancing, dynamic upstream, grayscale publishing, service circuit breaker, authentication, observability, and more. Apache APISIX helps enterprises quickly and securely handle API and microservice traffic, including gateways, Kubernetes Ingress, and service grids.

World has hundreds of companies using Apache APISIX processing key business flow, covering financial, Internet, manufacturing, retail, operators, etc., such as NASA (NASA), the European Union, letter of digital factory, Air China, China mobile, tencent, huawei, weibo, netease, shell to find room, 360, taikang, nai snow tea, etc.

More than 200 contributors contribute to Apache APISIX, the world’s most active open source gateway project. Smart developers! Join this vibrant and diverse community to bring more good to the world!

  • Apache APISIX GitHub: github.com/apache/apis…
  • Apache APISIX website: apisix.apache.org/
  • Apache APISIX document: apisix.apache.org/zh/docs/api…