|
| 1 | +# **Motivation** |
| 2 | + |
| 3 | +Pro tip: Don't drive blindfolded. 🏎️ 👮♂️ |
| 4 | + |
| 5 | +This project demonstrates a **production-grade observability setup** for a distributed system, capturing all three pillars of observability: |
| 6 | +- **Logs** |
| 7 | +- **Metrics** |
| 8 | +- **Traces** |
| 9 | + |
| 10 | +### **Okitou! why This Demo?** |
| 11 | +The stack includes: |
| 12 | +- A **Golang API** (because why not?) with **MongoDB**, **EventStore** and **Elasticsearch**. |
| 13 | +- **Kubernetes manifests** across three namespaces (`prod`, `monitoring`, `istio-system`) to simulate a real multi-environment setup |
| 14 | +- The full **observability toolkit**: |
| 15 | + - **Prometheus** + **Node Exporter** (metrics, because $htop is *so* 1999) |
| 16 | + - **Grafana** (With enough dashboards) |
| 17 | + - **Loki** + **Promtail** |
| 18 | + - **Jaeger** (To play detective) |
| 19 | + - **Kiali** (Who knows what's up with Istio) |
| 20 | + |
| 21 | +Although you might not need EVERYTHING in this repo, this setup mirrors real-world observability needs, ensuring you can **monitor, alert, and troubleshoot** before users notice anything’s wrong. |
| 22 | + |
| 23 | +#### Key Configuration |
| 24 | +* Kustomize overlays for environment-specific configurations, although only worked on a "prod" setup. |
| 25 | +* Separate RBAC restrictions for developer-base in production VS sre role. |
| 26 | +* A base cluster policy using **kyverno** to ensure all namespaced resources are in [dev/prod/monitoring/istio-system]. |
| 27 | + |
| 28 | +## Prerequisites locally |
| 29 | +- Docker |
| 30 | +- Docker Compose |
| 31 | +- go 1.24 |
| 32 | + |
| 33 | +## Setup |
| 34 | + |
| 35 | +1. Copy `.env.example` to `.env`: |
| 36 | + ```sh |
| 37 | + cp .env.example .env |
| 38 | + go mod download |
| 39 | + ``` |
| 40 | + |
| 41 | +2. Start the application: |
| 42 | + ```sh |
| 43 | + make start |
| 44 | + ``` |
| 45 | + |
| 46 | +3. To run tests: |
| 47 | + ```sh |
| 48 | + make test |
| 49 | + ``` |
| 50 | + |
| 51 | +## Swagger |
| 52 | + |
| 53 | +The REST API documentation is available at: http://localhost:5007/swagger/index.html |
| 54 | + |
| 55 | +## Project Structure |
| 56 | + |
| 57 | +#### Internal Structure (DDD Approach) |
| 58 | + |
| 59 | +The internal structure follows Domain-Driven Design (DDD) principles: |
| 60 | + |
| 61 | +```sh |
| 62 | +/internal |
| 63 | + ├── api |
| 64 | + │ ├── constants |
| 65 | + │ ├── dto |
| 66 | + │ ├── handlers |
| 67 | + │ ├── middlewares |
| 68 | + │ ├── server.go |
| 69 | + │ └── utils |
| 70 | + ├── delivery |
| 71 | + │ ├── aggregate |
| 72 | + │ ├── commands |
| 73 | + │ ├── events |
| 74 | + │ ├── models |
| 75 | + │ ├── projections |
| 76 | + │ ├── queries |
| 77 | + │ ├── repository |
| 78 | + │ └── services |
| 79 | + └── infrastructure |
| 80 | + ├── elasticsearch |
| 81 | + ├── es |
| 82 | + ├── eventstore |
| 83 | + ├── mongodb |
| 84 | + └── tracing |
| 85 | +``` |
| 86 | + |
| 87 | +The structure separates concerns according to DDD layers: |
| 88 | +- `api`: Presentation layer handling HTTP requests/responses |
| 89 | +- `delivery`: Core domain logic and business rules |
| 90 | +- `infrastructure`: Technical implementation details and external integrations |
| 91 | +--- |
| 92 | + |
| 93 | +#### Cluster Diagram |
| 94 | + |
| 95 | + |
| 96 | +#### Cluster Structure |
| 97 | +```sh |
| 98 | +deployments |
| 99 | +├── base |
| 100 | +│ ├── api |
| 101 | +│ ├── configs |
| 102 | +│ │ ├── clusterroles.yaml |
| 103 | +│ │ ├── configmaps.yaml |
| 104 | +│ │ ├── github-registry-secret.yaml |
| 105 | +│ │ ├── kustomization.yaml |
| 106 | +│ │ ├── mongodb-secret.yaml |
| 107 | +│ │ └── policy.yaml |
| 108 | +│ ├── elasticsearch |
| 109 | +│ ├── eventstore |
| 110 | +│ ├── kustomization.yaml |
| 111 | +│ └── mongodb |
| 112 | +├── components |
| 113 | +│ ├── istio |
| 114 | +│ │ ├── charts |
| 115 | +│ │ ├── generator.yaml |
| 116 | +│ │ └── kustomization.yaml |
| 117 | +│ ├── kustomization.yaml |
| 118 | +│ ├── kustomizeconfig.yaml |
| 119 | +│ └── monitoring |
| 120 | +│ ├── charts |
| 121 | +│ ├── generator.yaml |
| 122 | +│ ├── jaeger |
| 123 | +│ ├── kustomization.yaml |
| 124 | +│ └── values.yaml |
| 125 | +└── overlays |
| 126 | + └── prod |
| 127 | + ├── kustomization.yaml |
| 128 | + └── patches |
| 129 | + ├── api-svc.yaml |
| 130 | + └── restrict-developer-permissions.yaml |
| 131 | +``` |
| 132 | + |
| 133 | +#### Screenshots |
| 134 | + |
| 135 | + |
| 136 | + |
| 137 | + |
| 138 | + |
0 commit comments