https://github.com/robert076/logger
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.
https://github.com/robert076/logger
docker docker-compose golang http kubernetes kubernetes-jobs microservice port-forwarding scalability
Last synced: about 13 hours ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/robert076/logger
- Owner: Robert076
- License: apache-2.0
- Created: 2025-05-06T04:35:34.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-11T09:30:56.000Z (about 1 year ago)
- Last Synced: 2025-10-18T23:52:21.731Z (9 months ago)
- Topics: docker, docker-compose, golang, http, kubernetes, kubernetes-jobs, microservice, port-forwarding, scalability
- Language: Go
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🚀 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:
```bash
git clone https://github.com/Robert076/logger.git
```
2. Start your local *minikube* server:
```bash
minikube start
```
3. Run the *Kubernetes* deployment:
```bash
kubectl apply -f kubernetes/
```
4. Port forward the logger port from inside the minikube
```bash
kubectl port-forward service/logger-service 8080:8080
```
5. Visit [localhost:8080/pings](http://localhost:8080/pings) on your browser.
---
### Project structure
```bash
📁 .
├── 📜 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
```