Belimang adalah aplikasi geospatial e-commerce yang dibangun dengan Go, menggunakan PostgreSQL 18 dengan ekstensi PostGIS dan H3 untuk geospatial operations dan Redis untuk caching. Aplikasi ini menggunakan Helm untuk deployment production.
# Deploy production environment dengan Helm
make helm-install
# Akses aplikasi
kubectl get pods -n machinist-belimang-airmata- Docker & Docker Compose - Untuk containerization
- K3s atau Kubernetes cluster - Untuk deployment
- kubectl - Kubernetes CLI
- Docker Hub account (untuk K8s production) - Registry untuk images
- Go 1.25+ (optional) - Untuk development lokal
βββ cmd/ # Entry point aplikasi
βββ internal/ # Kode aplikasi internal
β βββ app/ # Domain logic (items, merchant, purchase, user)
β βββ config/ # Konfigurasi aplikasi
β βββ infrastructure/ # Database, cache, dan infrastruktur
β βββ middleware/ # HTTP middleware
β βββ pkg/ # Utilities dan packages
βββ deployment/ # Deployment configurations
β βββ helm/ # Helm charts untuk production
β βββ k3s/ # K3s local development
β βββ k8s/ # Kubernetes production
β βββ README.md # Deployment documentation
βββ migrations/ # Database migrations
βββ seeds/ # Database seed data
βββ compose.yaml # Production Docker Compose
βββ compose.dev.yaml # Development Docker Compose
βββ Dockerfile # Production Dockerfile
βββ Makefile # Build automation
Aplikasi menggunakan centralized environment management dengan file .env di root directory:
.env # Current environment (copy from examples below)
.env.example # Base example for local development
.env.example.k3s # K3s specific configuration
.env.example.k8s # K8s production configuration
# Untuk K3s development
cp .env.example.k3s .env
# Untuk K8s production
cp .env.example.k8s .env
# Edit .env dengan nilai yang sesuaiπ Security Note: Pastikan mengganti nilai sensitif:
DB_PASSWORD- Password database yang amanJWT_SECRET_KEY- Secret key untuk JWT (minimum 32 karakter)
Untuk panduan lengkap, lihat Deployment Documentation
# Deploy production environment
make helm-install
# Upgrade deployment
make helm-upgrade
# Uninstall
make helm-uninstall
# Check status
make helm-status# Development
make up-dev-build
make down-dev
# Production
make up-prod-build
make down-prod- PostgreSQL: 1 CPU, 1Gi RAM, 2Gi storage
- Redis: 500m CPU, 512Mi RAM, 1Gi storage
- App: 1 CPU, 1Gi RAM, 1 replica
- PostgreSQL: 4 CPU, 12Gi RAM, 50Gi storage (dengan io_uring)
- Redis: 2 CPU, 6Gi RAM, 20Gi storage
- App: 3 CPU, 4Gi RAM, 2 replicas
- Geospatial Operations: PostGIS dengan H3 indexing untuk location-based queries
- Full-Text Search: pg_trgm untuk optimized ILIKE operations
- Complex Queries: Multi-table JOINs dengan distance calculations
- High Performance: PostgreSQL 18 dengan io_uring untuk production
- Caching Layer: Redis untuk session dan query result caching
- Scalable Architecture: Horizontal scaling dengan Kubernetes
# Cek status deployment
kubectl get all -n machinist-belimang-airmata
# Cek resource usage
kubectl top pods -n machinist-belimang-airmata
# Cek logs aplikasi
kubectl logs -f deployment/belimang -n machinist-belimang-airmata# Test aplikasi health
kubectl get pods -n machinist-belimang-airmata
# Port forward untuk akses lokal
kubectl port-forward service/belimang 8080:80 -n machinist-belimang-airmata# Scale aplikasi
kubectl scale deployment belimang --replicas=4 -n machinist-belimang-airmata
# Update aplikasi
kubectl set image deployment/belimang belimang=arfiansr/belimang-app:v2 -n machinist-belimang-airmata
# Rollback jika diperlukan
kubectl rollout undo deployment/belimang -n machinist-belimang-airmata# Cek tabel database
kubectl exec -n machinist-belimang-airmata belimang-postgresql-xxx -- psql -U postgres -d belimang -c "\dt"
# Cek logs PostgreSQL
kubectl logs -f deployment/belimang-postgresql -n machinist-belimang-airmata
# Cek logs Redis
kubectl logs -f deployment/belimang-redis -n machinist-belimang-airmata- Port sudah digunakan
# Cek port yang digunakan
netstat -tulpn | grep :8080
# Ganti port di .env file
HTTP_PORT=8081- Database connection error
# Cek logs PostgreSQL
docker-compose logs postgres
# Reset database
docker-compose down -v
docker-compose up -d postgres- Pod tidak bisa start
# Cek events
kubectl get events -n belimang --sort-by='.lastTimestamp'
# Cek pod details
kubectl describe pod <pod-name> -n belimang- Image pull error
# Pastikan image sudah di-load
docker images | grep belimang
# Load ulang image
minikube image load belimang-app:latest- PVC tidak bisa mount
# Cek storage class
kubectl get storageclass
# Cek PVC status
kubectl get pvc -n belimang- Ganti ConfigMap Values: Update semua nilai sensitif di
k8s/configmap.yamldengan nilai yang aman - Network Policies: Implementasikan network policies untuk isolasi
- RBAC: Setup Role-Based Access Control
- TLS: Gunakan TLS untuk komunikasi eksternal
- Image Security: Scan images untuk vulnerabilities
- Registry Security: Gunakan private registry untuk production images
Pastikan untuk mengganti nilai-nilai berikut di production:
JWT_SECRET_KEY: Gunakan secret key yang kuatDB_PASSWORD: Gunakan password yang kompleks- Database credentials lainnya
Konfigurasi PostgreSQL sudah dioptimasi untuk performa:
shared_buffers=256MBeffective_cache_size=1GBwork_mem=2MBmax_connections=200
Konfigurasi Redis dengan:
maxmemory=512mbmaxmemory-policy=allkeys-lru- Persistence dengan AOF dan RDB
GOMAXPROCS=4: Sesuaikan dengan CPU coresGOMEMLIMIT=1536MiB: Memory limit untuk GC- CGO enabled untuk performa database
# Docker Compose
docker-compose logs -f [service-name]
# Kubernetes
kubectl logs -f deployment/[deployment-name] -n belimangSemua services memiliki health checks:
- PostgreSQL:
pg_isready - Redis:
redis-cli ping - Aplikasi:
/app/server health
Untuk monitoring production, pertimbangkan untuk menambahkan:
- Prometheus untuk metrics
- Grafana untuk visualization
- Jaeger untuk tracing
- ELK stack untuk centralized logging