Skip to content

up1/workshop-microservices-202509

Repository files navigation

Workshop :: Microservices develop, test and deploy

  • API gateway
  • Distributed Tracing with OpenTelemetry

1. API Gateway with Kong

Kong with Database mode

$git clone https://github.com/Kong/docker-kong
$cd docker-kong/compose/
$KONG_DATABASE=postgres docker compose --profile database up -d

Status of Kong server and database

$docker compose ps
NAME             IMAGE          COMMAND                  SERVICE   CREATED          STATUS                    PORTS
compose-db-1     postgres:9.5   "docker-entrypoint.s…"   db        49 seconds ago   Up 49 seconds (healthy)   5432/tcp
compose-kong-1   kong:latest    "/docker-entrypoint.…"   kong      49 seconds ago   Up 44 seconds (healthy)   0.0.0.0:8000-8002->8000-8002/tcp, [::]:8001-8002->8001-8002/tcp, 0.0.0.0:8443-8444->8443-8444/tcp, [::]:8444->8444/tcp

Gateway API's urls :

2. Build custom plugin with Kong

$cd kong-plugins
$docker image build -t mykong .

Start Kong server with image=mykong

$docker compose --profile database down
$docker volume prune

$export KONG_DOCKER_TAG=mykong
$KONG_DATABASE=postgres docker compose --profile database up -d
$docker compose ps

List of plugins in Kong manager

3. Working with Kong API Gateway

Add service

$curl http://127.0.0.1:8001/services \
    -d name=demo-api \
    -d url=https://jsonplaceholder.typicode.com

Add route to service

$curl http://127.0.0.1:8001/services/demo-api/routes \
    -d name=demo-api \
	-d 'paths[]=/test'

Check

4. Start auth-service

$docker compose build auth-service
$docker compose up -d auth-service

List of urls

Check from API Gateway

5. Add observability for services

  • List of services
    • API gateway with Kong
    • Auth service

Add plugins in Kong with Global scope

6. Start LGTM Stack

  • Log
  • Grafana
  • Trace
  • Metric
$docker compose up -d lgtm
$docker compose up ps

Edit traces_endpoint

Check data in Grafana dashboard

7. Tracing with Python service

7.1 Build and run

$docker compose build python-service
$docker compose up -d python-service

List of urls

7.2 Add python-service to API gateway

  • Add service
  • Add route to service

Add service

$curl http://127.0.0.1:8001/services \
    -d name=python-service \
    -d url=http://python-service:8000

Add route to service

$curl http://127.0.0.1:8001/services/python-service/routes \
    -d name=python-service \
	-d 'paths[]=/python'

Check from API Gateway

8. Tracing with NodeJS service

8.1 Build and run

$docker compose build nodejs-service
$docker compose up -d nodejs-service

List of urls

8.2 Add nodejs-service to API gateway

  • Add service
  • Add route to service

Add service

$curl http://127.0.0.1:8001/services \
    -d name=nodejs-service \
    -d url=http://nodejs-service:3000

Add route to service

$curl http://127.0.0.1:8001/services/nodejs-service/routes \
    -d name=nodejs-service \
	-d 'paths[]=/nodejs'

Check from API Gateway

9. Application metrics with Prometheus

9.1 Install and config Prometheus server

  • Config in file prometheus/prometheus.yml
  • Start server

File prometheus.yml

scrape_configs:
  - job_name: 'api-gateway'
    scrape_interval: 5s
    metrics_path: '/metrics'
    static_configs:
      - targets: ['kong:8001']
        labels:
          application: 'kong'

  - job_name: 'python-service'
    scrape_interval: 5s
    metrics_path: '/metrics'
    static_configs:
      - targets: ['python-service:8000']
        labels:
          application: 'python-service'
          
  - job_name: 'nodejs-service'
    scrape_interval: 5s
    metrics_path: '/metrics'
    static_configs:
      - targets: ['nodejs-service:3000']
        labels:
          application: 'nodejs-service'

Start server

$docker compose up -d prometheus
$docker compose ps

Access to prometheus

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published