Итегра
Итегра — это система управления трафиком, разработанная для облачных сред. Она обеспечивает:
Архитектура Итегры:
Управление сервисами
Примечание: эта функция используется EaseMesh.
Расширяемость
Высокая производительность и доступность
Сжатие: сжимает тело ответа.
Горячее обновление: обновляет конфигурацию и двоичный файл Easegress на месте без потери соединений.
Работа
egctl
), MegaEase Portal, HTTP-клиенты, такие как curl, postman и т. д.Следующие примеры показывают, как использовать Easegress для различных сценариев.
Полный список см. в Cookbook.
Основное общее использование Easegress заключается в быстрой настройке прокси для бэкенд-серверов. Мы разделили его на несколько простых шагов, чтобы проиллюстрировать основные концепции и операции.
Мы можем загрузить двоичный файл со страницы выпуска (https://github.com/megaease/easegress/releases). Например, мы используем версию для Linux:
$ mkdir easegress
$ wget https://github.com/megaease/easegress/releases/download/v1.1.0/easegress-v1.1.0-linux-amd64.tar.gz
$ tar zxvf easegress-v1.1.0-linux-amd64.tar.gz -C easegress && cd easegress
или использовать исходный код:
$ git clone https://github.com/megaease/easegress && cd easegress
$ make
Затем мы можем добавить каталог двоичных файлов в PATH и запустить сервер:
$ export PATH=${PATH}:$(pwd)/bin/
$ easegress-server
2021-05-17T16:45:38.185+08:00 INFO cluster/config.go:84 etcd config: init-cluster:eg-default-name=http://localhost:2380 cluster-state:new force-new-cluster:false
2021-05-17T16:45:38.185+08:00 INFO cluster/cluster.go:379 client is ready
2021-05-17T16:45:39.189+08:00 INFO cluster/cluster.go:590 server is ready
2021-05-17T16:45:39.21+08:00 INFO cluster/cluster.go:451 lease is ready
2021-05-17T16:45:39.231+08:00 INFO cluster/cluster.go:187 cluster is ready
2021-05-17T16:45:39.253+08:00 INFO supervisor/supervisor.go:180 create system controller StatusSyncController
2021-05-17T16:45:39.253+08:00 INFO cluster/cluster.go:496 session is ready
``` 2021-05-17T16:45:39.253+08:00 INFO api/api.go:96 api server running in localhost:2381
2021-05-17T16:45:44.235+08:00 INFO cluster/member.go:210 self ID changed from 0 to 689e371e88f78b6a
2021-05-17T16:45:44.236+08:00 INFO cluster/member.go:137 store clusterMembers: eg-default-name(689e371e88f78b6a)=http://localhost:2380
2021-05-17T16:45:44.236+08:00 INFO cluster/member.go:138 store knownMembers : eg-default-name(689e371e88f78b6a)=http://localhost:2380
The default target of Makefile is to compile two binary into the directory `bin/`. `bin/easegress-server` is the server-side binary, `bin/egctl` is the client-side binary. We could add it to the `$PATH` for simplifying the following commands.
We could run `easegress-server` without specifying any arguments, which launch itself by opening default ports 2379, 2380, 2381. Of course, we can change them in the config file or command arguments that are explained well in `easegress-server --help`.
```bash
$ egctl member list
- options:
name: eg-default-name
labels: {}
cluster-name: eg-cluster-default-name
cluster-role: writer
cluster-request-timeout: 10s
cluster-listen-client-urls:
- http://127.0.0.1:2379
cluster-listen-peer-urls:
- http://127.0.0.1:2380
cluster-advertise-client-urls:
- http://127.0.0.1:2379
cluster-initial-advertise-peer-urls:
- http://127.0.0.1:2380
cluster-join-urls: []
api-addr: localhost:2381
debug: false
home-dir: ./
data-dir: data
wal-dir: ""
log-dir: log
member-dir: member
cpu-profile-file: ""
memory-profile-file: ""
lastHeartbeatTime: "2021-05-05T15:43:27+08:00"
etcd:
id: a30c34bf7ec77546
startTime: "2021-05-05T15:42:37+08:00"
state: Leader
After launched successfully, we could check the status of the one-node cluster. It shows the static options and dynamic status of heartbeat and etcd.
Now let's create an HTTPServer listening on port 10080 to handle the HTTP traffic.
$ echo '
kind: HTTPServer
name: server-demo
port: 10080
keepAlive: true
https: false
rules:
- paths:
- pathPrefix: /pipeline
backend: pipeline-demo' | egctl object create
The rules of routers above mean that it will lead the traffic with the prefix /pipeline
to the pipeline pipeline-demo
, which will be created below. If we curl
it before created, it will return 503.
$ echo '
name: pipeline-demo
kind: HTTPPipeline
flow:
- filter: proxy
filters:
- name: proxy
kind: Proxy
mainPool:
servers:
- url: http://127.0.0.1:9095
- url: http://127.0.0.1:9096
- url: http://127.0.0.1:9097
loadBalance:
policy: roundRobin' | egctl object create
The pipeline means it will do proxy for 3 backend endpoints in load balance policy roundRobin
.
Now you can use some HTTP clients such as curl
to test the feature:
$ curl -v http://127.0.0.1:10080/pipeline
If you are not set up some applications to handle the 9095, 9096, and 9097 in the localhost, it will return 503 too. We prepare a simple service to let us test handily, the example shows:
$ go run example/backend-service/mirror/mirror.go & # Running in background
$ curl http://127.0.0.1:10080/pipeline -d 'Hello, Easegress'
Your Request
===============
Method: POST
URL : /pipeline
Header: map[Accept:[*/*] Accept-Encoding:[gzip] Content-Type:[application/x-www-form-urlencoded] User-Agent:[curl/7.64.1]]
Body : Hello, Easegress
Now we want to add more features to the pipeline, then we could add kinds of filters to the pipeline. For example, we want validation and request adaptation for the pipeline-demo
.
$ cat pipeline-demo.yaml
name: pipeline-demo
kind: HTTPPipeline
flow:
- filter: validator
jumpIf: { invalid: END }
- filter: requestAdaptor
- filter: proxy
filters:
- name: validator
kind: Validator
headers: **Тип содержимого:**
значения:
- application/json
- имя: requestAdaptor
вид: RequestAdaptor
заголовок:
установлено:
X-Adapt-Key: goodplan
- имя: proxy
вид: Proxy
основной пул:
серверы:
- URL: http://127.0.0.1:9095
- URL: http://127.0.0.1:9096
- URL: http://127.0.0.1:9097
балансировка нагрузки:
политика: roundRobin
После обновления конвейера оригинальный curl -v http://127.0.0.1:10080/pipeline будет возвращать 400 из-за проверки. Поэтому мы изменили его, чтобы удовлетворить ограничение:
```bash
$ curl http://127.0.0.1:10080/pipeline -H 'Content-Type: application/json' -d '{"message": "Hello, Easegress"}'
Ваш запрос
===============
Метод: POST
URL : /pipeline
Заголовок: map[Accept:[*/*] Accept-Encoding:[gzip] Content-Type:[application/json] User-Agent:[curl/7.64.1] X-Adapt-Key:[goodplan]]
Тело : {"message": "Hello, Easegress"}
Мы также видим, что Easegress отправляет ещё один заголовок X-Adapt-Key: goodplan
в зеркальную службу.
См. справку и руководство разработчика для получения дополнительной информации.
Подробности см. в плане развития Easegress.
Easegress находится под лицензией Apache 2.0. См. файл LICENSE для подробностей.
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Комментарии ( 0 )