Consul Service Mesh

29/12/2020
Chưa phân loại
The service mesh is a software directed way to routing and segmentation. There used to be some issues and challenges running microservices and cloud infrastructure. It contains various features like load balancing, security policy management, service discovery, and routing. Service mesh brings different benefits as network observability, failure handling, ACL auth methods, traffic shifting, proxy ecosystem, etc. There are two key components of service mesh:

1. Control Plane: It holds a registry of the details of all the running services and different policies that handle the traffic. The control plane must be scalable to handle thousands of instances and update the data plane. 2. Data Plane: It is mainly responsible for the transmission of data between the services. It must be high performance and integrated with the control plane.

Prerequisite

  1. A new virtual instance server
  2. Consul installed on the server
  3. If in case you don’t have Consul installed then learnhere

Creating a Service Definition

You can create a service using any text editor. Here, we are using nano text editor. You can create a web service configuration file using the following command. nano /tmp/consul_services/web.json A web service configuration will look something similar to this:

{
 "services":[
  {
   "name":"serviceA",
   "port":5000,
   "check":{
     "args":[
       "curl",
       "localhost:5000"
        ],
      "interval":"3s"
    }
  },
  {
    "name":"serviceB",
    "port":8000,
    "check":{
      "args":[
        "curl",
        "localhost:8000"
       ],
    "interval":"3s"
    }
  }
 ]
}

Consul Connect

Consul Connect is a new feature in consul which gives you more secure transmission of data to service to service with the help of TLS encryption and identity-based authorization. It is easy to use and user-friendly. You can easily enable it with just one configuration option. And for the existing applications, you need to add just a single line to the service configuration.
There are many new functionalities available of consul with connect. Let’s get started to discuss some of them:

  • Native Integration: You can natively integrate sensitive applications with consul connect APIs to create connections without proxy.
  • Certificate Management: Consul generates and distributes certificates using a certificate authority provider.
  • Encrypted Traffic: Consul connect uses TLS encryption to secure the data in transit. So you can deploy the services in low trust environments also.
  • Proxy Sidecars: You can use proxy sidecars to create incoming and outgoing TLS connections automatically.

Proxy Sidecars

We know that we can use proxy sidecars to create incoming and outgoing connections. Here we will see an example of using proxy sidecars. Adding a single line to service configuration will enable that service to receive connect based connection. The line should start with connect like this:

{
  "service": {
    "name": "mysql",
    "port": 3306,
    "connect": { "proxy": {} }
    }
}

You can see in the above configuration by adding just one line in the configuration it will automatically design the consul to start and manage proxy process for this service. You can add more line of configuration in the connect block to communicate with other services. For example, if this service wants to communicate to db service over connect then the configuration will be like this:

"service": {
  "name": "mysql",
  "port": 3306,
  "connect": {
    "proxy": {
      "config": {
        "upstreams": [{
          "destination_name": "db",
          "local_bind_port": 9191
        }]
      }
     }
    }
  }
}

All the transmission between the mysql service and db service will be fully secured and encrypted. You can also see that by adding connect into the configuration there is no change in the previous mysql service. So, in this way, any existing application also enables the connect based connection by adding just one line in the configuration.

Web Interface

Open up your favorite web browser and visit http://YourDomain.com:8500 to access the consul dashboard. You can manage all your services, nodes and intentions from there. You can control the access between services from the Intention tab from the dashboard.

The intention is a policy that specifies the rule to communicate between services. You can also create new intentions to allow or deny access between any source service and destination service.

You can see a list of all the services under service tab from the dashboard.

Conclusion

In this guide, you have learned to install Consul on your server and using consul service mesh for communicating between services.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

How to Squash Git Commits

How to Squash Commits in Git to Keep Your History Clean When you are working with Git, it’s a good idea to commit often,...
28/12/2020

Làm việc với lệnh Find và Locate

1. Lệnh Find find đường_dẫn -name kí_tự_cần_tìm Lệnh này sẽ cung cấp cho bạn một danh...
30/12/2020

Chạy nhiều version PHP trên một Ubuntu 18.04 – server

Như chúng ta đã biết thì PHP thường được sử dụng để làm ngôn ngữ trong việc tạo ra một trang...
30/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Huớng dẫn dùng proxy cho ios, iphone 2023
23/09/2023

Cách gắn set proxy cho điện thoại android, oppo, giả lập android, Ldplayer Bằng Proxydroid
20/09/2023

Mua Proxy Socks5 VN Chơi Game Gia Lập Tăng Cường Trải Nghiệm Chơi Game
22/06/2023

Mua Proxy Mỹ, Us Nuôi Tài Khoản Etsy, eBay Tìm Hiểu Về Mua Proxy Mỹ tại Onet.com.vn
22/06/2023

Mua Proxy Game – Giải pháp tuyệt vời cho việc chơi game trên mạng mà không bị giới hạn về vị trí địa lý
03/06/2023