Backend Router Service
Exposes the backend router deployment for internal cluster access. Location:backend/deployment.yml
- Type:
ClusterIP- Internal cluster access only - Selector: Routes to pods with label
app: exchange-router - Port Mapping: Service port 80 → Container port 8080
- Protocol: TCP
- Access: Available at
exchange-router-service.default.svc.cluster.local:80
WebSocket Stream Service
Provides internal access to the WebSocket streaming service. Location:websocket/deployment.yml
- Type:
ClusterIP- Internal cluster access only - Selector: Routes to pods with label
app: exchange-ws-stream - Port Mapping: Service port 80 → Container port 4000
- Protocol: TCP (WebSocket over HTTP)
- Access: Available at
exchange-ws-stream-service.default.svc.cluster.local:80
PostgreSQL Database Service
Provides internal database connectivity for all services. Location:postgres-db/deployment.yml
- Type:
ClusterIP- Internal cluster access only - Selector: Routes to pods with label
app: exchange-postgres - Port Mapping: Service port 80 → Container port 5432 (PostgreSQL)
- Protocol: TCP
- Access: Available at
exchange-postgres-service.default.svc.cluster.local:80 - Note: Port 80 is mapped to PostgreSQL’s standard 5432 port
Redis Service
Provides internal access to Redis for caching and pub/sub. Location:redis/deployment.yml
- Type:
ClusterIP- Internal cluster access only - Selector: Routes to pods with label
app: exchange-redis - Port Mapping: Service port 80 → Container port 6379 (Redis)
- Protocol: TCP
- Access: Available at
exchange-redis-service.default.svc.cluster.local:80 - Note: Port 80 is mapped to Redis’s standard 6379 port
Service Types
The exchange platform uses two Kubernetes service types:ClusterIP (Current Architecture)
All services currently useClusterIP:
- Internal cluster access only
- Default service type
- Not accessible from outside the cluster
- Assigned a cluster-internal IP address
- Most secure option for internal services
- Backend services that don’t need external access
- Database and cache services
- Internal APIs and microservices
- Services accessed only through Ingress
LoadBalancer (Alternative)
For external access without Ingress:- Creates a cloud provider load balancer
- Assigns external IP address
- Routes external traffic to service
- Higher cost (per service)
- Services needing direct external access
- Non-HTTP protocols
- When Ingress is not suitable
- Development/testing environments
Service Discovery
DNS-Based Discovery
Kubernetes automatically creates DNS records for all services: Service DNS Format:Connection Strings
Services use DNS names in connection strings: Database Connection:Environment Variables
Kubernetes also injects service information as environment variables:Service Networking
Port Mapping Strategy
All services use a consistent port mapping:- Backend Router: 8080
- WebSocket Stream: 4000
- PostgreSQL: 5432
- Redis: 6379
- Standardized service port (80) for all services
- Ingress can route to all services on port 80
- Target ports match application defaults
- Clear separation between service and pod networking
Load Balancing
Services provide automatic load balancing:- Service selects all pods matching the label
- Traffic is distributed across healthy pods
- Round-robin load balancing by default
- Unhealthy pods are automatically removed
Service Access Patterns
Internal Service Communication
Services communicate using DNS names: Backend → Database:External Access via Ingress
External traffic flows through Ingress:Service Operations
View Services
Test Service Connectivity
Monitor Service Traffic
Service Configuration Examples
Multi-Port Service
Expose multiple ports from the same service:Headless Service
Direct pod access without load balancing:Session Affinity
Sticky sessions for stateful applications:Best Practices
- Use ClusterIP by Default: Only expose services externally when necessary
- Consistent Port Mapping: Standardize service ports across your platform
- Named Ports: Use port names for multi-port services
- DNS Names: Use service DNS names instead of IP addresses
- Health Checks: Configure readinessProbes on pods for automatic health-based routing
- Labels: Use consistent label selectors matching your deployments
- Namespaces: Use service DNS with namespace for cross-namespace communication
Troubleshooting
Service Not Routing Traffic
DNS Resolution Issues
Connection Timeouts
Related Resources
- Deployments - Pod definitions these services route to
- Ingress - External routing to these services
- Kubernetes Services Documentation

