Skip to content

infra360/apache-skywaking-demo

Repository files navigation

SkyWalking APM Demo Project

This project demonstrates the implementation of Apache SkyWalking APM (Application Performance Monitoring) with a microservices architecture. It consists of two Spring Boot services (Service A and Service B) and a Node.js service (Service C), all instrumented with SkyWalking agents for distributed tracing and monitoring.

Project Overview

The project includes:

  • Service A: A Spring Boot application that makes HTTP calls to external services
  • Service B: A Spring Boot application with MongoDB integration for customer data management
  • Service C: A Node.js application with SkyWalking agent integration
  • SkyWalking APM: Complete monitoring setup with OAP (Observability Analysis Platform) and UI
  • Elasticsearch: Backend storage for SkyWalking
  • MongoDB: Database for Service B
  • GitHub Actions: CI workflow to build and push image to dockerhub and update the k8s manifest images.

Version Information

Current project versions:

  • SkyWalking OAP Server: 10.2.0
  • SkyWalking UI: 10.2.0
  • SkyWalking Java Agent: 8.1.0
  • SkyWalking Node.js Agent: Latest version (via npm)

Prerequisites

  • Docker and Docker Compose
  • Java 17 or higher
  • Maven
  • Node.js 18 or higher
  • npm
  • Git
  • kubectl (for Kubernetes deployment)
  • kind (for local Kubernetes cluster)

Project Structure

skywalking-apm-demo/
├── ServiceA/                 # Spring Boot Service A
│   ├── agent/               # SkyWalking Java agent
│   └── src/                 # Service source code
├── ServiceB/                # Spring Boot Service B with MongoDB
│   ├── agent/               # SkyWalking Java agent
│   └── src/                # Service source code
├── ServiceC/                # Node.js Service
│   └── src/                # Service source code
├── k8s/                    # Kubernetes deployment files
├── docker-compose.yml      # Docker composition for all services
├── build.sh                # Build script for the project
└── deploy.sh               # Deployment script for Kubernetes

Components

Service A

  • Spring Boot application
  • Makes HTTP calls to external services
  • Integrated with SkyWalking Java agent
  • Runs on port 9090

Service B

  • Spring Boot application with MongoDB
  • Customer data management
  • Integrated with SkyWalking Java agent
  • Runs on port 8090

Service C

  • Node.js application
  • Express.js web server
  • Integrated with SkyWalking Node.js agent
  • Runs on port 3000

SkyWalking Setup

  • OAP Server (ports 11800, 12800)
  • SkyWalking UI (port 8080)
  • Elasticsearch backend (port 9200)

MongoDB

  • Database for Service B
  • Runs on port 27017

Deployment Options

This project supports two deployment methods:

  1. Docker Compose (Quick Start)
  2. Kubernetes (Production-like Environment)

Docker Compose Deployment

This is the quickest way to get started with the demo:

  1. Build the Services:
./build.sh
  1. Start the Infrastructure:
docker-compose up

Kubernetes Deployment

Prerequisites

  • kind (Kubernetes in Docker) installed
  • kubectl installed
  • Docker installed

Setup Steps

  1. Run the deployment script:
./deploy.sh

This script will:

  • Create a kind cluster
  • Deploy all necessary components
  • Set up port forwarding for accessing services

Manual Deployment Steps

  1. Create a kind cluster:
kind create cluster --config k8s/00-kind-config.yaml
  1. Create the namespace:
kubectl apply -f k8s/01-namespace.yml
  1. Deploy components:
kubectl apply -f k8s/02-elasticsearch.yml
kubectl apply -f k8s/03-oap.yml
kubectl apply -f k8s/04-ui.yml
  1. Deploy services:
kubectl apply -f k8s/05-service-a.yml
kubectl apply -f k8s/06-service-b.yml
kubectl apply -f k8s/08-service-c.yml

Accessing the Services

After deployment, the services will be available at:

Verify the Setup

Check if all pods are running:

kubectl get pods -n skywalking-apm-demo

Check the services:

kubectl get svc -n skywalking-apm-demo

View the logs:

# For OAP server
kubectl logs -f deployment/sw-oap -n skywalking-apm-demo

# For UI
kubectl logs -f deployment/sw-ui -n skywalking-apm-demo

# For services
kubectl logs -f deployment/service-a -n skywalking-apm-demo
kubectl logs -f deployment/service-b -n skywalking-apm-demo
kubectl logs -f deployment/service-c -n skywalking-apm-demo

Troubleshooting

Common Issues

  1. If pods are not starting:

    • Check pod events: kubectl describe pod <pod-name> -n skywalking-apm-demo
    • Check logs: kubectl logs <pod-name> -n skywalking-apm-demo
  2. If services are not accessible:

    • Verify the services: kubectl get svc -n skywalking-apm-demo
    • Check port forwarding: ps aux | grep "kubectl port-forward"
  3. If SkyWalking UI shows no data:

    • Verify OAP is connected to Elasticsearch
    • Check if the agents are properly configured in the services
    • Verify network connectivity between services and OAP

Agent Issues

  1. Java Agent:

    • Check agent.config settings
    • Verify agent logs in the container
    • Ensure correct agent version compatibility
  2. Node.js Agent:

    • Check environment variables for configuration
    • Verify agent initialization in the application
    • Check connection to OAP server

Cleanup

To remove all resources:

kubectl delete namespace skywalking-apm-demo

To delete the kind cluster:

kind delete cluster

CI/CD

This project includes GitHub Actions workflows for:

  • Building Docker images
  • Pushing to DockerHub
  • Updating Kubernetes manifests

Additional Resources