1 Star 0 Fork 12

herb / easemesh

forked from MegaEase / easemesh 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

EaseMesh

test file

1.6

1.7

1.8

1.9

2.0

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.

EaseMesh logo

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

The architecture diagram

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.
  • 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.
  • 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

  1. EaseAgent
  2. Easegress

6. Quick Start

6.1 Environment Requirement

  • Linux kernel version 4.15+
  • Kubernetes version 1.18+
  • Mysql version 14.14+

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.

The topology migration diagram

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 4: 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 3: 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 Easegress

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 use NGINX'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.

EaseMesh Canary topology

  • 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.

plugin

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. #testtt

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2020 Open Service Mesh Authors. and others that have contributed code to the public domain. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

A service mesh implementation for connecting, control, and observe services in spring-cloud. 展开 收起
Go
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/sunlitg/easemesh.git
git@gitee.com:sunlitg/easemesh.git
sunlitg
easemesh
easemesh
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891