Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yandex-cloud-examples/yc-webinar-split-monolith-into-microservices
Материалы вебинара «Как распилить монолит на микросервисы с помощью Yandex API Gateway и Yandex Cloud Functions».
https://github.com/yandex-cloud-examples/yc-webinar-split-monolith-into-microservices
api-gateway microservices serverless yandex-cloud yandex-function yandexcloud
Last synced: about 1 month ago
JSON representation
Материалы вебинара «Как распилить монолит на микросервисы с помощью Yandex API Gateway и Yandex Cloud Functions».
- Host: GitHub
- URL: https://github.com/yandex-cloud-examples/yc-webinar-split-monolith-into-microservices
- Owner: yandex-cloud-examples
- License: apache-2.0
- Created: 2023-12-08T12:14:46.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-11T10:00:44.000Z (about 1 year ago)
- Last Synced: 2023-12-11T11:24:12.847Z (about 1 year ago)
- Topics: api-gateway, microservices, serverless, yandex-cloud, yandex-function, yandexcloud
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Как перейти от монолитной архитектуре к микросервисной при помощи Yandex API Gateway и Yandex Cloud Functions
Структура проекта:
.
├── demo # Демонстарция работы
│ ├── migrate.sh # Фиксация канареечного релиза
│ ├── rollback.sh # Откат канареечного релиза
│ └── shoot.sh # 100 последовательных обращений к ресурсу
├── deploy # Развертывание инфраструктуры
│ ├── microservices # Развертывание 2х микросервисов: Posts и Users
│ │ └── ...
│ ├── monolith # Развертывание инраструктуры монолита
│ │ └── ...
│ └── registry # Развертывание Container registry и публикация образа монолита
│ └── ...
├── microservices
│ ├── post # Микросервис Posts
│ │ └── ...
│ └── user # Микросервис Users (отвечат 502 на любой запрос)
│ └── ...
├── monolith # Монолитное приложение с 2 сервисами: Posts и Users
│ └── ...
└── README.md## Инструкция по запуску примера
### 0. Настройте инструменты
Установите и настройте следующие инструменты: [YC CLI](https://cloud.yandex.ru/docs/cli/quickstart#install), [Terraform](https://cloud.yandex.ru/docs/tutorials/infrastructure-management/terraform-quickstart#install-terraform), [Docker](https://cloud.yandex.ru/blog/posts/2022/03/docker-containers)
### 1. Подготовьте образ монолитного приложения
Проинициализируйте terraform:
```shell
cd deploy/registry/ ; ./init.sh
```
Создайте Container registry:
```shell
cd deploy/registry/ ; ./tf.sh apply
```
Сконфигурируйте Docker:
```shell
cd deploy/registry/ ; ./docker_configure.sh apply
```
Соберите образ и загрузите его в созданный реестр:
```shell
cd deploy/registry/ ; ./push_image.sh apply
```
### 2. Разверните монолитное приложение
Проинициализируйте terraform:
```shell
cd deploy/monolith/ ; ./init.sh
```
Разверните инфраструктуру:
```shell
cd deploy/monolith/ ; ./tf.sh apply
```
Проверьте результат, обратитесь к балансировщику:
```shell
cd demo/ ; ./shoot.sh
```
### 3. Разверните микросервисы
Запакуйте исходный код микросервисов в архив:
```shell
cd deploy/microservices/resources/ ; ./build.sh
```
Проинициализируйте terraform:
```shell
cd deploy/microservices/ ; ./init.sh
```
Разверните инфраструктуру:
```shell
cd deploy/microservices/ ; ./tf.sh apply
```
Проверьте результат, обратитесь к ресурсу `/api/posts` API Gateway:
```shell
cd demo/ ; ./shoot.sh
```
Зафиксируйте канареечный релиз:
```shell
cd demo/ ; ./migrate.sh
```
### 4. (Опционально) Выкатите сломанный релиз и откатите его
Для этого замените API Gateway в спецификации на закомментирвоанный шлюз. Примените изменения:
```shell
cd deploy/microservices/ ; ./tf.sh apply
```
Убедитесь, что новый сервис возвращает код 502, обратившись к `/api/users?id=1` API Gateway:
```shell
cd demo/ ; ./shoot.sh
```
Откатите канареечный релиз:
```shell
cd demo/ ; ./rollback.sh
```