Investigations

Kubernetes Weather + Redis

Go November 2024

A Go weather microservice with Redis caching deployed on Kubernetes, demonstrating multi-container orchestration and horizontal scaling.

The second Kubernetes investigation adds a caching layer — because real-world services almost always have multiple moving parts, and orchestrating them is where Kubernetes earns its keep.

The Go API fetches weather data for any location, caches it in Redis with a configurable TTL, and serves subsequent requests from cache. There are health-check and cache-stats endpoints so you can monitor what's happening. The architecture is a classic pattern: stateless API pods that scale horizontally, all connecting to a single Redis instance.

What I found most instructive was the service discovery piece. The Go app finds Redis by its Kubernetes service name — no hardcoded IPs, no service registry. Kubernetes DNS handles it. Scale the API pods to 10 and they all discover Redis the same way.

The caching strategy is straightforward but effective: first request for a location hits the external weather API, stores the response in Redis, and subsequent requests get the cached version until TTL expires. The stats endpoint shows hit/miss ratios so you can see the cache warming up in real time.

What this project demonstrates

RESTful weather API with Redis caching and TTL
Multi-container Kubernetes deployment: Go API + Redis
Horizontal scaling of stateless API pods
Health check and cache statistics endpoints
Kubernetes DNS service discovery
Second in a three-part Kubernetes learning series

Technologies

KubernetesRedisDockerCachingWeather API

© 2026 Jonathan Leahy · v0.8.9-2-g8ebe561