Dependencies
Before setting up the Email Gateway, ensure you have the following dependencies in place:- PostgreSQL database for storing email gateway data
- MongoDB connection to the app-runtime database for runtime data access
- Kafka for event-driven communication with other FlowX.AI services
- Redis for caching
- Keycloak (or compatible OAuth2 provider) for authentication and authorization
The Email Gateway does not require an ingress configuration as it operates as an internal service communicating via Kafka.
Infrastructure prerequisites
Configuration
Authorization configuration
The Email Gateway validates incoming tokens with the JWT public key mechanism and authenticates to other FlowX services with a dedicated service account (themainIdentity client registration) in the service-accounts realm:
PostgreSQL configuration
The Email Gateway uses its own dedicated PostgreSQL database for storing email-related data.MongoDB configuration (app-runtime)
The Email Gateway connects to the sharedapp-runtime MongoDB database for accessing runtime data.
The
retryWrites=false parameter is required for compatibility with MongoDB replica set configurations that include arbiters.Redis configuration
Email Gateway uses Redis for caching. Configure Redis connection using the standard Redis environment variables. Quick reference:Both
SPRING_DATA_REDIS_* and SPRING_REDIS_* variable prefixes are supported. The SPRING_DATA_REDIS_* prefix is the modern Spring Boot standard and is recommended for new deployments.For advanced Redis deployment modes (Sentinel, Cluster) and SSL/TLS setup, see the Redis Configuration guide. Note that Sentinel and Cluster modes are only supported by the Events Gateway service.
Kafka configuration
Core Kafka settings
OAuth authentication (when using SASL_PLAINTEXT)
When using the
kafka-auth profile, the security protocol will automatically be set to SASL_PLAINTEXT and the SASL mechanism will be set to OAUTHBEARER.Topic naming configuration
IMAP configuration
Configure the Email Gatewayโs IMAP polling behavior for inbound email processing:Microsoft Graph configuration
Master election configuration
The Email Gateway uses a master election mechanism to coordinate work across multiple replicas:Rebalancing configuration
Configure how email accounts are distributed across service instances:Kafka topics
The Email Gateway publishes to the following Kafka topics:Logging configuration
Control logging levels for different components:Secrets management
The Email Gateway requires several secrets to be configured. These should be stored securely and referenced via Kubernetes secrets or a secrets management solution.Deployment
Helm values example
Below is an example Helm values configuration for deploying the Email Gateway:Network policies
The Email Gateway requires network access to the following services:Monitoring
The Email Gateway exposes Prometheus metrics for monitoring. Enable scraping by setting the pod label:Health endpoints
Troubleshooting
Common issues
Database connection failures
Database connection failures
Symptoms: Service fails to start with database connection errors.Solutions:
- Verify the
email_gatewaydatabase exists in PostgreSQL - Check that the database user has appropriate permissions
- Ensure network connectivity between the pod and PostgreSQL service
- Verify the JDBC URL format is correct
MongoDB connection issues
MongoDB connection issues
Symptoms: Errors accessing app-runtime data.Solutions:
- Verify MongoDB replica set is healthy
- Check that
retryWrites=falseis set in the connection URI - Ensure the MongoDB user has read access to the
app-runtimedatabase - Verify network policies allow MongoDB traffic
Kafka authentication failures
Kafka authentication failures
Symptoms: Kafka consumer/producer fails to connect.Solutions:
- Verify OAuth token endpoint is accessible
- Check Kafka OAuth client credentials
- Ensure the
kafka-authzrealm exists in Keycloak - Verify network connectivity to both Kafka and Keycloak
Service account authentication errors
Service account authentication errors
Symptoms: 401/403 errors when calling other FlowX services.Solutions:
- Verify the Keycloak service account is properly configured
- Check that client secrets match between configuration and Keycloak
- Ensure the service account has required roles assigned
Related resources
Email Trigger
Configure IMAP connections to trigger processes from incoming emails
Email Sender
Configure SMTP connections to send emails from processes
Microsoft Outlook
Connect to Outlook via MS Graph API for reading and sending emails
Redis Configuration
Complete Redis setup including Sentinel and Cluster modes
Kafka Authentication
Configure Kafka security and authentication
IAM Configuration
Identity and access management setup

