Awesome
EaseMesh
EaseMesh is a service mesh that is compatible with the Spring Cloud ecosystem. It is based on Easegress for the sidecar of service management and EaseAgent for the monitor of service observing.
<a href="https://megaease.com/easemesh"> <img src="./imgs/easemesh.svg" alt="EaseMesh logo" title="EaseMesh" height="175" width="175" align="right"/> </a>- EaseMesh
- 1. Purposes
- 2. Principles
- 3. Architecture
- 4. Features
- 5. Dependent Projects
- 6. Quick Start
- 7. Demonstration
- 8. Roadmap
- 9. Contributing
- 10. License
- 11. User Manual
1. Purposes
Why do we reinvent another wheel?
-
Service mesh compatible with Spring Cloud ecosystem: Micro-service in Spring Cloud ecosystem has its own service registry/discovery components. It is quite different from Kubernetes ecosystem using DNS for service discovery. The major Service Mesh solution (e.g. Istio) using the Kubernetes domain technology. It is painful and conflicted with Java Spring Cloud ecosystem. EaseMesh aims to make Service Mesh compatible with Java Spring Cloud completely.
-
Integrated Observability: Currently Kubernetes-based service mesh only can see the ingress/egress traffic, and it has no idea what's happened in service/application. So, combining with Java Agent technology, we can have the full capability to observe everything inside and outside of service/application.
-
Sophisticated capability of traffic split: The EaseMesh has the sophisticated capability of traffic split, it can split traffic of a request chain into not only first service but also last. The capability could be applied in the canary deployment, online production testing scenarios.
Shortly, the EaseMesh leverages the Kubernetes sidecar and Java Agent techniques to make Java applications have service governance and integrated observability without change a line of source code.
2. Principles
- Spring Cloud Compatibility: Spring Cloud domain service management and resilient design.
- No Code Changes: Using sidecar & Java-agent for completed service governance and integrated observability.
- Service Insight: Service running metrics/tracing/logs monitoring.
3. Architecture
4. Features
- Non-intrusive Design: Zero code modification for Java Spring Cloud application migration, only small configuration update needed.
- Java Register/Discovery: Compatible with popular Java Spring Cloud ecosystem's Service registry/discovery.
- Multiple tenants(namespace) Supporting multiple tenants' service registration, isolate services from different tenants.
- Share (global) tenant Support share tenants, all services have visibility to the service registered in the global tenant.
- Compatible
- Be compatible with the Eureka registry.
- Be compatible with the Consul registry.
- Be compatible with the Nacos registry.
- Extensibility Support registering services with metadata.
- Resource Management: Rely on Kubernetes platform for CPU/Memory resources management.
- Traffic Orchestration
- Rich Routing Rules: Exact path, path prefix, regular expression of the path, method, headers.
- Traffic Splitting Coloring & Scheduling east-west and north-south traffic to configured services.
- LoadBalance Support Round Robin, Weight Round Robin, Random, Hash by Client IP Address, Hash by HTTP Headers.
- Resilience: Including Timeout/CircuitBreaker/Retryer/Limiter, completely follow sophisticated resilience design.
- Resilience&Fault Tolerance
- Circuit breaker: Temporarily blocks possible failures.
- Rate limiter: Limits the rate of incoming requests.
- Retryer: Repeats failed executions.
- Time limiter: Limits the duration of execution.
- Chaos engineering
- Fault injection Working in progress.
- Delay injection Working in progress.
- Resilience&Fault Tolerance
- Observability:
- Logs
- Access Logs Generate HTTP access log for all requests per service.
- Application log Automatically inject the tracing context into log data.
- Tracing
- JDBC Tracing for invocation of the JDBC.
- HTTP Request Tracing for HTTP RPC.
- Kafka Tracing for messages delivered by Kafka.
- Redis Tracing for Redis cache accessing.
- RabbitMQ Tracing for messages delivered by the RabbitMQ.
- Sampling
- Support probabilistic sampling.
- Support QPS sampling.
- Metrics
- HTTP Request Reporting throughput latency per URL.
- JDBC Reporting throughput and latency per SQL.
- Kafka Reporting throughput and latency per consumer, producer, and topic.
- Redis Reporting throughput and latency per method.
- RabbitMQ Reporting throughput and latency per topic.
- Logs
- Security
- mTLS Working in progress.
- mTLS Enforcement Working in progress.
- External CA certificate Working in progress.
- Service-to-Service Authorization Rules Working in progress.
The throughput is represented by m1, m5, m15 The latency is represented by P99, P98, P95, P90, P80, P75, P50, etc...
5. Dependent Projects
6. Quick Start
6.1 Environment Requirement
- Linux kernel version 4.15+
- Kubernetes version 1.18+
- MySQL version 5.7+
6.2 Sanity Checking
- Running
kubectl get nodes
to check your Kubernetes cluster's healthy.
6.3 Installation
Please check out install.md to install EaseMesh.
7. Demonstration
-
Spring Cloud PetClinic microservice example.
-
It uses Spring Cloud Gateway, Spring Cloud Circuit Breaker, Spring Cloud Config, Spring Cloud Sleuth, Resilience4j, Micrometer and Eureka Service Discovery from Spring Cloud Netflix technology stack.
Prepare the emctl
git clone https://github.com/megaease/easemesh
cd emctl && make
export PATH=$(pwd)/bin:${PATH}
7.1 Start PetClinic in EaseMesh
7.1.1 Step 1: Apply mesh configuration
Apply the EaseMesh configuration files
emctl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/mesh-conf/a-pet-tenant.yaml
emctl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/mesh-conf/api-gateway.yaml
emctl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/mesh-conf/customers.yaml
emctl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/mesh-conf/ingress.yaml
emctl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/mesh-conf/vets.yaml
emctl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/mesh-conf/visits.yaml
7.1.2 Step 2: Create namespace
leverage kubectl to create spring-petclinic
namespace
We support to automatically inject sidecar and the JavaAgent when a deployment was created or updated in an interested namespace. So you need to create a namespace with a specific label, we are prepared a spring-petclinic namespace, you can create it via:
kubectl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/namespace/spring-petclinic.yaml
7.1.3 Step 3: Setup Database
The pet clinic demo needs to access database, the default is memory database. But in the EaseMesh quick start, you could to use memory database by default.
If you want to use the MySQL database, you could create the DB table schemes and import records from PetClinic example to set up yours.
7.1.4 Step 4: Apply petclinic stack
Deploy petclinic resources to k8s cluster, we have developed an operator to manage the custom resource (MeshDeployment) of the EaseMesh. Meshdeployment
contains a K8s' complete deployment spec and a piece of extra information about the service.
The Operator of the EaseMesh will automatically inject a sidecar to pod and a JavaAgent into the application's JVM
Now, we support injecting the JavaAgent and sidecar into the native deployment, but you need to explicitly specify the service name in the Deployment spec via mesh.megaease.com/service-name: "{service-name}"
of the annotation. EaseMesh has a admission control
server, which will watch Create/Update operation of Deployments in the specified namespace. If a deployment with mesh.megaease.com/service-name
annotation was created in the specific namespace (labeled with key mesh.megaease.com/mesh-service
), the admission control server will mutate the deployment spec and inject the sidecar and the JavaAgent.
kubectl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/deployments/01-vets.yaml
kubectl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/deployments/02-visits.yaml
kubectl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/deployments/03-customers.yaml
kubectl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/deployments/04-api-gateway.yaml
ATTENTION: There is a ConfigMap spec in yaml file, if you to want to use the MySQL database, you need to change it per your environments.
7.1.5 Get exposed port of EaseMesh ingress
service
kubectl get service -n easemesh easemesh-ingress-service
ATTENTION: From the output, you may notice exposed port of the Ingress service. If you needn't use reverse proxy service, you can directly access pet-clinic application via http://{your_host}:{exposed_port}/
7.1.6 Step 5: Configure reverse proxy
ATTENTION: The step is optional. It can be omitted when you have no requirements about reverse proxy.
7.1.6.1 Config reverse proxy via Easegress
ATTENTION: Only for scenarios that the Easegress acts as the role of reverse proxy service
If you leverage the Easegress as a reverse proxy service, the following configuration can be applied.
HTTP Server spec (file name: http-server.yaml):
kind: HTTPServer
name: spring-petclinic-example
port: 443
https: true
keepAlive: true
keepAliveTimeout: 75s
maxConnection: 10240
cacheSize: 0
certs:
key: {add your certs information to here}
rules:
- paths:
- pathPrefix: /
backend: http-petclinic-pipeline
HTTP Pipeline spec (file name: http-petclinic-pipeline.yaml):
name: http-petclinic-pipeline
kind: HTTPPipeline
flow:
- filter: requestAdaptor
- filter: proxy
filters:
- name: requestAdaptor
kind: RequestAdaptor
method: ""
path: null
header:
del: []
set:
Host: "{you host name, can be omitted}"
X-Forwarded-Proto: "https"
Connection: "upgrade"
add:
Host: "{you host name, can be omitted}"
- name: proxy
kind: Proxy
mainPool:
servers:
- url: http://{node1_of_k8s_cluster}:{port_exposed_by_ingress_service}
- url: http://{node2_of_k8s_cluster}:{port_exposed_by_ingress_service}
loadBalance:
policy: roundRobin
Change contents in {}
as per your environment, and apply it via Easegress client command tool egctl
:
egctl apply -f http-server.yaml
egctl apply -f http-petclinic-pipeline.yaml
egctl is the client command line of the Easegress
Visiting PetClinic website with $your_domain/#!/welcome
7.1.6.2 Config reverse proxy via Nginx
ATTENTION: Only for scenarios that the Nginx acts as the role of reverse proxy service
if you leverage the Nginx as a reverse proxy service, the following configuration should be added.
Then configure the NodPort IP address and port number into your traffic gateway's routing address, e.g, add config to NGINX:
location /pet/ {
proxy_pass http://{node1_of_k8s_cluster}:{port_exposed_by_ingress_service}/;
}
ATTENTION: that the PetClinic website should be routed by the
/
subpath, or it should useNGINX
's replacing response content feature for correcting resource URL:
location /pet/ {
proxy_pass http://{node1_of_k8s_cluster}:{port_exposed_by_ingress_service/;
sub_filter 'href="/' 'href="/pet/';
sub_filter 'src="/' 'src="/pet/';
sub_filter_once off;
}
Visiting PetClinic website with $your_domain/pet/#!/welcome
.
7.2 Canary Deployment
Canary deployment demonstrates how to route coloring traffic (request) to a canary version of the specific service.
Customer Service (v2)
is the canary version service.- The line of red color in the diagram represents coloring traffic (request).
- The coloring traffic is correctly routed into canary version service after it has passed through the first service (API Gateway).
7.2.1 Step 1: Coloring traffic
Coloring traffic with HTTP header X-Canary: lv1
by using Chrome browser's ModHeader plugin. Then EaseMesh will route this colored traffic into the Customer service's canary version instance.
7.2.2 Step 2: Apply canary configuration of the EaseMesh
Apply mesh configuration file:
emctl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/canary/customer-canary.yaml`
7.2.3 Step 3: Prepare a canary version of the application
ATTENTION You can skip the step, we have provides the canary image to docker hub
megaease/spring-petclinic-customers-service:canary
you can found it in the docker hub.
Developing a canary version of Customer service to add an extra suffix to the city field for each record.
diff --git a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java
index 360e765..cc2df3d 100644
--- a/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java
+++ b/spring-petclinic-customers-service/src/main/java/org/springframework/samples/petclinic/customers/model/Owner.java
@@ -99,7 +99,7 @@ public class Owner {
}
public String getAddress() {
- return this.address;
+ return this.address + " - US";
}
public void setAddress(String address) {k
7.2.4 Step 4: Build canary image
ATTENTION You can skip the step, we have provides the canary image to docker hub
megaease/spring-petclinic-customers-service:canary
you can found it in the docker hub.
Building the canary Customer service's image, and update image version in https://github.com/megaease/easemesh-spring-petclinic/blob/main/canary/customers-service-deployment-canary.yaml
. Or just use our default canary image which already was in it.
7.2.5 Step 5. Deploy canary version
Being similar to 7.1.4, we leverage kubectl to deploy the canary version of the Deployment
kubectl apply -f https://raw.githubusercontent.com/megaease/easemesh-spring-petclinic/main/canary/customers-service-deployment-canary.yaml`
ATTENTION: There is a ConfigMap spec in echo yaml spec, it describes how to connect the database for applications. You need to change its contents for your environment.
7.2.6 Step 6: Sending coloring traffic
Turning on the chrome ModHeader plugin to color the traffic, then visit PetClinic website. You can see the change to the table which adds an "-US" suffix to every city record.
ModHeader is a chrome extension, we use it solely for demonstrating coloring the requests.
7.3 Clean
- Run
kubectl delete namespace spring-petclinic
. - Run
emctl delete ingress pet-ingress
emctl delete service api-gateway
emctl delete service customers-service
emctl delete service vets-service
emctl delete service visits-service
emctl delete tenant pet
8. Roadmap
See EaseMesh Roadmap for details.
9. Contributing
See MegaEase Community to follow our contributing details.
10. License
EaseMesh is under the Apache 2.0 license. See the LICENSE file for details.
11. User Manual
See EaseMesh User Manual for details.