Skip to content

Go-based logger app with two microservices: one logs messages, the other sends pings every 5 seconds. Runs on Minikube with Kubernetes, using a job to auto-init the database table for setup.

License

Notifications You must be signed in to change notification settings

Robert076/logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 logger app

Contains 2 main services: One spams the other with messages while the other logs the messages it received.

🌐 First service: Logger

  • Every time the route /ping is being called with an http post request, it adds a log of the message in the request body.
  • Displays all the logs from its database.

💻 Second service: Pinger

  • Pings the logger service and sends http post requests with a random message every 5 seconds to that /ping route.

🏁 Running the app (locally, using minikube and macOS)

  1. Clone the repository:
git clone https://github.com/Robert076/logger.git
  1. Start your local minikube server:
minikube start
  1. Run the Kubernetes deployment:
kubectl apply -f kubernetes/
  1. Port forward the logger port from inside the minikube
kubectl port-forward service/logger-service 8080:8080
  1. Visit localhost:8080/pings on your browser.

Project structure

📁 .
├── 📜 LICENSE
├── 📘 README.md
├── 📁 kubernetes
│   ├── 📦 db-deployment.yml                # deployment for the postgres container
│   ├── 💾 db-pvc.yml                       # persistent volume claim so we don't lose the data from the database
│   ├── 🌐 db-service.yml                   # k8s service for the database
│   │── ⚙️ init-ping-table.yml              # k8s job to automatically create the table in he database so the program works as expected with no manual intervention
│   ├── ⚙️ logger-config.yml                # config map for the project's env vars
│   ├── 📦 logger-deployment.yml            # deployment for the logger service
│   ├── 🌐 logger-service.yml               # k8s service for the logger
│   ├── 📦 pg-deployment.yml                # deployment for the pg container (optional, we don't use pg anyways)
│   └── 🌐 pg-service.yml                   # k8s service for the pg service (optional, we don't use pg anyways)
├── 📁 logger-service
│   ├── 🐳 Dockerfile                       # Dockerfile for building the logger image
│   ├── 📁 db
│   │   └── 🛢️ db.go                        # database module for the logger app
│   ├── 🐙 docker-compose.yml               # docker-compose for local development, run with this if you don't want to use k8s
│   ├── 📦 go.mod                           # go module
│   ├── 📦 go.sum                           # imports for the logger app
│   ├── 🚀 main.go                          # main for the logger service
│   └── 📁 ping            
│       └── 📄 ping.go                      # data structure for the ping
└── 📁 pinger-service
    ├── 📦 go.mod                           # go module
    ├── 🚀 main.go                          # main for the pinger service
    └── 📁 messages
        └── 💬 messages.go                  # 20 random hardcoded messages

About

Go-based logger app with two microservices: one logs messages, the other sends pings every 5 seconds. Runs on Minikube with Kubernetes, using a job to auto-init the database table for setup.

Topics

Resources

License

Stars

Watchers

Forks