Deployment Guide
This guide covers deploying App Suite for Teams in production Kubernetes environments.
Overview
App Suite for Teams is an add-on service for Open-Xchange App Suite. It extends an existing App Suite installation with team collaboration features for email-based workflows. Teams is deployed as a containerized microservice that integrates into the App Suite Core UI as a microfrontend.
Architecture
The Teams service consists of:
- Fastify Backend - Node.js API server with WebSocket support for real-time collaboration
- Vue 3 Frontend - Microfrontend plugin that loads into App Suite Core UI via Shadow DOM
- PostgreSQL Database - State persistence for threads, status, and collaborative editing (Yjs CRDTs)
Deployment Model
- Primary Target: Kubernetes with Helm charts (production-ready)
- Scaling: Teams scales independently of App Suite Middleware (horizontal pod autoscaling supported)
- Integration: Requires existing App Suite installation - Teams extends but does not replace App Suite
Prerequisites
Required Infrastructure
Before deploying Teams, ensure the following infrastructure is in place:
Open-Xchange App Suite - Teams is an add-on and requires a working App Suite installation
- App Suite Middleware (Java MW) must be deployed and accessible
- App Suite Core UI must be deployed (Teams integrates as a microfrontend)
- Users must be configured in App Suite
Kubernetes Cluster - Production deployment target
- Kubernetes 1.19+ recommended
- Helm 3.x for chart installation
PostgreSQL 12+ - Dedicated database for Teams state persistence
- Can use CloudNativePG operator (recommended) or external PostgreSQL
- Separate from App Suite database (Teams requires its own database)
- Must be reachable without a transaction-mode connection pooler (or via a dedicated direct endpoint): real-time updates use
LISTEN/NOTIFY, which PgBouncer in transaction mode silently drops. See Real-time Events. - Budget
max_connectionsfor one pool (10) plus one LISTEN connection per replica
Authentication Infrastructure - One of:
- Keycloak 4.x+ - Recommended for modern deployments with centralized identity management
- Switchboard (JWKS mode) - For existing deployments without Keycloak
Required Access
- Container registry credentials for
registry.open-xchange.com/appsuite-core/teams - Admin access to authentication infrastructure (Switchboard or Keycloak)
- Database admin access for initial setup
- Kubernetes cluster access with permissions to create deployments and services
Note: Network routing (Istio VirtualServices, etc.) is expected to be configured externally by your platform team.
Authentication Setup
Teams supports two authentication modes for accessing App Suite Middleware. Choose the mode that matches your infrastructure:
Mode 1: Keycloak Token Exchange (Recommended)
Modern approach using RFC 8693 token exchange with impersonation. Recommended for new deployments and environments with centralized identity management.
Flow:
Benefits:
- Standards-based (RFC 8693)
- Centralized identity management
- Works with Keycloak 4.x+ (tested with Keycloak 26.2)
- Better audit trail and security controls
Configuration Steps:
See Keycloak Token Exchange Setup for detailed configuration.
Environment Variables:
TOKEN_EXCHANGE_ISSUER_URL=https://keycloak.example.com/realms/ox
TOKEN_EXCHANGE_CLIENT_ID=teams
TOKEN_EXCHANGE_CLIENT_SECRET=<client-secret>
ISSUER_ALLOWLIST=switchboard.example.comHelm Configuration:
oidc:
issuer: switchboard.example.com
tokenExchange:
enabled: true
issuerUrl: https://keycloak.example.com/realms/ox
clientId: teams
# Option 1: Direct secret (not recommended for production)
clientSecret: <client-secret>
# Option 2: Existing secret (recommended)
existingSecret: keycloak-client-secret
clientSecretKey: client-secretImportant: Do NOT set serviceToken when using Keycloak mode.
Mode 2: Switchboard Legacy
Proprietary approach using Switchboard's impersonation API. Suitable for existing deployments without Keycloak.
Flow:
Configuration Steps:
Configure Switchboard in JWKS Mode:
- Switchboard must run with certificate matching domain (CN matches issuer)
- Use cert-manager for certificate management (recommended)
- Users in App Suite must authenticate against this Switchboard instance
Configure Java MW to Trust Switchboard:
/opt/open-xchange/etc/oauth-provider.properties: com.openexchange.oauth.provider.enabled: "true" com.openexchange.oauth.provider.userLookupClaim: login com.openexchange.oauth.provider.contextLookupClaim: login com.openexchange.oauth.provider.jwt.jwksUri: https://switchboard.example.com/.well-known/jwks.json com.openexchange.oauth.provider.mode: expect_jwtGenerate Service Token:
kubectl -n appsuite exec deployments/switchboard -- \ /usr/bin/node /app/bin/create-service-token.js teams.example.com 365dSave the output as your service token.
Environment Variables:
SERVICE_TOKEN=<generated-service-token>
ISSUER_ALLOWLIST=switchboard.example.com
SWITCHBOARD_API_PATH=/apiHelm Configuration:
serviceToken: <generated-service-token>
oidc:
issuer: switchboard.example.com
switchboardApiPath: /apiImportant: Do NOT set tokenExchange.enabled when using Switchboard mode.
Database Setup
Teams requires PostgreSQL with client certificate authentication (mTLS). Password-based authentication is not supported — all connections must present a valid client certificate signed by the cluster's CA.
Certificate Infrastructure
The setup uses three layers managed by cert-manager:
- Certificate Authority — A cert-manager
ClusterIssuer(e.g.,postgres-ca-issuer) acts as the root CA for all PostgreSQL certificates - Server certificate — Issued to the PostgreSQL cluster for TLS termination
- Client certificates — Issued per namespace/application, with the Common Name matching the PostgreSQL role
Option 1: CloudNativePG Operator (Recommended)
The CloudNativePG operator simplifies database provisioning in Kubernetes environments.
Prerequisites:
- CloudNativePG operator installed in cluster
- cert-manager installed with a
ClusterIssuerfor PostgreSQL certificates
Steps:
Create server and replication certificates:
apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: teams-cluster-server-cert namespace: database spec: secretName: teams-cluster-server-cert issuerRef: name: postgres-ca-issuer kind: ClusterIssuer commonName: teams-cluster dnsNames: - teams-cluster-rw - teams-cluster-r - teams-cluster-ro - teams-cluster-rw.database.svc.cluster.local - teams-cluster-r.database.svc.cluster.local - teams-cluster-ro.database.svc.cluster.local usages: - server auth duration: 8760h # 1 year renewBefore: 720h # 30 daysCreate Cluster Resource with certificate-only authentication:
apiVersion: postgresql.cnpg.io/v1 kind: Cluster metadata: name: teams-cluster namespace: database spec: instances: 2 storage: size: 10Gi postgresql: parameters: max_connections: "100" ssl_min_protocol_version: TLSv1.3 ssl_max_protocol_version: TLSv1.3 pg_hba: - hostssl all all all cert - hostssl replication all all cert certificates: serverTLSSecret: teams-cluster-server-cert serverCASecret: teams-cluster-server-cert clientCASecret: teams-cluster-server-cert replicationTLSSecret: teams-cluster-replication-cert bootstrap: initdb: database: teams-production owner: teamsIssue a client certificate for the Teams application:
apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: teams-db-client namespace: production spec: secretName: teams-db-client issuerRef: name: postgres-ca-issuer kind: ClusterIssuer commonName: teams # Must match the PostgreSQL role usages: - client auth privateKey: algorithm: ECDSA size: 256 duration: 2160h # 90 days renewBefore: 1440h # 60 daysConfigure Helm Chart:
database: host: teams-cluster-rw.database.svc.cluster.local port: 5432 name: teams-production user: teams ssl: secure sslSecret: name: teams-db-client # cert-manager managed secretThe Helm chart mounts the secret at
/etc/ssl/db/and setsDATABASE_SSL_CA_PATH,DATABASE_SSL_CERT_PATH, andDATABASE_SSL_KEY_PATHautomatically. No password is needed.
Option 2: External PostgreSQL with Client Certificates
For environments using external database services that support mTLS.
Steps:
Obtain client certificate from your database provider or internal CA
Create Kubernetes Secret:
kubectl create secret tls teams-db-client \ --cert=client.crt \ --key=client.key # Add CA cert to the secret kubectl patch secret teams-db-client -p "{\"data\":{\"ca.crt\":\"$(base64 -w0 ca.crt)\"}}"Configure Helm Chart:
database: host: postgres.example.com port: 5432 name: teams user: teams ssl: secure sslSecret: name: teams-db-client
Helm Chart Deployment
This is the production deployment method. All production deployments of Teams must use Kubernetes with the official Helm chart.
Installation
Create Values File:
Create
teams-values.yamlwith your configuration. See Configuration Reference below for all available options.Minimal Example (Keycloak mode):
image: repository: registry.open-xchange.com/appsuite-core/teams tag: "1.0.0" hostname: teams.example.com origins: "https://appsuite.example.com" oidc: issuer: switchboard.example.com tokenExchange: enabled: true issuerUrl: https://keycloak.example.com/realms/ox clientId: teams # Use existing secret for client credentials (recommended) existingSecret: keycloak-client-secret clientSecretKey: client-secret database: host: postgres-cluster.database.svc.cluster.local port: 5432 name: teams-production # Use existing secret for database credentials existingSecret: production.teams.postgres-cluster.credentials ssl: secureNote: Network routing to the Teams service should be configured externally (e.g., Istio VirtualService).
Install Chart:
helm install teams \ oci://registry.open-xchange.com/appsuite-core-internal/charts/teams \ -f teams-values.yaml \ --namespace production \ --create-namespaceNote: Helm 3.8.0+ is required for OCI registry support.
Verify Deployment:
# Check pod status kubectl -n production get pods -l app.kubernetes.io/name=teams # Check logs kubectl -n production logs -l app.kubernetes.io/name=teams --tail=50 # Check health endpoints kubectl -n production port-forward svc/teams 9090:9090 curl http://localhost:9090/health curl http://localhost:9090/ready
Database Migrations
Schema migrations run as a pre-install,pre-upgrade Helm hook (Job <release>-teams-migrate), so they execute strictly before the Deployment is updated. A failed migration fails the helm release; old Pods stay on the previous schema.
To inspect a migration run:
kubectl -n production get jobs -l app.kubernetes.io/name=teams
kubectl -n production logs job/<release>-teams-migrateThe hook re-fires whenever the chart, image, or values change. To force a rerun without changing any of those — for example, after restoring a freshly-provisioned database — set migrate.triggerValue to a value that differs from the previous render. Any unique-per-deploy identifier or a timestamp works:
helm upgrade teams \
oci://registry.open-xchange.com/appsuite-core-internal/charts/teams \
-f teams-values.yaml \
--set migrate.triggerValue=$(date +%s) \
--namespace productionUnder Argo CD a manual Sync re-fires the PreSync hook regardless of whether anything is OutOfSync.
Upgrading
Update Values File (if needed)
Upgrade Release:
helm upgrade teams \ oci://registry.open-xchange.com/appsuite-core-internal/charts/teams \ -f teams-values.yaml \ --namespace productionMonitor Rollout:
kubectl -n production rollout status deployment/teams
Rollback
# View release history
helm history teams -n production
# Rollback to previous version
helm rollback teams -n production
# Rollback to specific revision
helm rollback teams 3 -n productionNetwork Routing (Istio VirtualService)
Network routing to the Teams service is configured externally using Istio VirtualService. This section provides example configurations based on the project's helmfile deployment.
Example VirtualService
The Teams service exposes two main endpoints that need to be routed:
- API endpoints -
/teams/api/*→/api/*(includes the long-lived Server-Sent Events stream at/teams/api/events) - WebSocket endpoint -
/teams/ws→/ws
Basic VirtualService:
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: teams
namespace: production
spec:
gateways:
- istio-system/default-gateway # Reference your Istio Gateway
hosts:
- teams.example.com
http:
# Teams API routes (also carries the long-lived /teams/api/events stream: no `timeout` here)
- match:
- uri:
prefix: /teams/api
name: teams-api
rewrite:
uri: /api
route:
- destination:
host: teams.production.svc.cluster.local
port:
number: 80
# Teams WebSocket route
- match:
- uri:
prefix: /teams/ws
name: teams-ws
rewrite:
uri: /ws
route:
- destination:
host: teams.production.svc.cluster.local
port:
number: 80Integration with App Suite
If integrating Teams into an existing App Suite VirtualService, add the Teams routes alongside your existing routes:
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: appsuite
namespace: production
spec:
gateways:
- istio-system/default-gateway
hosts:
- appsuite.example.com
http:
# Teams API routes
- match:
- uri:
prefix: /teams/api
name: teams-api
rewrite:
uri: /api
route:
- destination:
host: teams.production.svc.cluster.local
port:
number: 80
# Teams WebSocket routes
- match:
- uri:
prefix: /teams/ws
name: teams-ws
rewrite:
uri: /ws
route:
- destination:
host: teams.production.svc.cluster.local
port:
number: 80
# App Suite Middleware API routes
- match:
- uri:
prefix: /api
- uri:
prefix: /ajax
name: appsuite-api
route:
- destination:
host: appsuite-middleware.production.svc.cluster.local
port:
number: 80
# App Suite Core UI
- match:
- uri:
prefix: /
name: appsuite-ui
route:
- destination:
host: appsuite-ui.production.svc.cluster.local
port:
number: 80Important Notes
- Gateway Reference: Adjust
gatewaysto reference your actual Istio Gateway (e.g.,istio-system/default-gateway) - Hostnames: Configure
hoststo match your domain - Service Name: The service name
teamsmatches the Helm release name - Port: Teams service listens on port 80 internally (container port 8080)
- Path Rewriting: The
/teamsprefix is rewritten to match the service's expected paths - WebSocket Support: Ensure your Istio Gateway is configured to support WebSocket connections
- Event Stream:
/teams/api/eventsis a long-livedtext/event-streamresponse. Istio applies no request timeout by default; do not settimeouton the route carrying it (Istio rejects0s, and any positive value cuts the stream). With nginx ingress instead of Istio, disable proxy buffering and raiseproxy-read-timeoutfor this path. - Single VirtualService: Use only one VirtualService per hostname to avoid ambiguous routing
Verification
After configuring the VirtualService, verify routing:
# Check VirtualService is created
kubectl -n production get virtualservice teams
# Describe VirtualService
kubectl -n production describe virtualservice teams
# Test API endpoint
curl -H "Host: teams.example.com" http://teams.example.com/teams/api/health
# Test WebSocket (requires wscat)
wscat -c wss://teams.example.com/teams/wsConfiguration Reference
Complete Helm chart configuration options:
Image Configuration
| Parameter | Description | Default |
|---|---|---|
image.repository | Container image repository | registry.open-xchange.com/appsuite-core/teams |
image.pullPolicy | Image pull policy | IfNotPresent |
image.tag | Image tag (defaults to chart appVersion) | "" |
Service Configuration
| Parameter | Description | Default |
|---|---|---|
bindAddr | IP address to bind (IPv6 :: or IPv4 0.0.0.0) | "::" |
hostname | Service hostname | "" |
origins | Allowed CORS origins (comma-separated or *) | "*" |
logLevel | Log level (trace, debug, info, warn, error, fatal) | "info" |
logJson | Enable JSON logging | false |
exposeApiDocs | Expose Swagger UI at /api-docs | false |
Authentication Configuration (Token Exchange)
| Parameter | Description | Default |
|---|---|---|
tokenExchange.enabled | Enable Keycloak token exchange | false |
tokenExchange.issuerUrl | Keycloak realm URL | "" |
tokenExchange.clientId | Keycloak client ID | "" |
tokenExchange.clientSecret | Keycloak client secret (not recommended, use existingSecret) | "" |
tokenExchange.existingSecret | Use existing secret for client credentials (recommended) | "" |
tokenExchange.clientSecretKey | Key in existing secret containing client secret | "client-secret" |
Authentication Configuration (Switchboard Legacy)
| Parameter | Description | Default |
|---|---|---|
serviceToken | Switchboard service token (mutually exclusive with oidc) | "" |
switchboardApiPath | Switchboard API path | "/api" |
Authentication Configuration (Shared)
| Parameter | Description | Default |
|---|---|---|
oidc.issuer | OIDC issuer domain for JWT validation (required) | "" |
Database Configuration
| Parameter | Description | Default |
|---|---|---|
database.host | PostgreSQL hostname | "" |
database.port | PostgreSQL port | "5432" |
database.name | Database name | "" |
database.auth.user | Database username (deprecated, use existingSecret) | "" |
database.auth.password | Database password (deprecated, use existingSecret) | "" |
database.existingSecret | Use existing secret for all database credentials (recommended) | "" |
database.existingSecretKeys.host | Key in existing secret for database host | "host" |
database.existingSecretKeys.database | Key in existing secret for database name | "database" |
database.existingSecretKeys.username | Key in existing secret for username | "username" |
database.existingSecretKeys.password | Key in existing secret for password | "password" |
database.ssl | SSL mode (secure, insecure, false) | "secure" |
Database Migration Configuration
| Parameter | Description | Default |
|---|---|---|
migrate.triggerValue | Per-deploy trigger annotation on the migrate Job. Set to a value that varies per deploy (e.g. a unique identifier or timestamp) to force the pre-upgrade hook to re-fire; leave empty otherwise. | "" |
Error Tracking Configuration
| Parameter | Description | Default |
|---|---|---|
sentry.enabled | Enable Sentry error tracking | false |
sentry.dsn | Backend Sentry DSN | "" |
sentry.dsnFrontend | Frontend DSN (optional, defaults to backend DSN) | "" |
sentry.existingSecret | Use existing secret for Sentry DSN values (recommended for GitOps) | "" |
sentry.dsnKey | Key in existing secret containing the backend DSN | "sentry-dsn" |
sentry.dsnFrontendKey | Key in existing secret containing the frontend DSN (falls back to dsnKey) | "" |
sentry.environment | Environment tag | "production" |
sentry.release | Release version (defaults to chart appVersion) | "" |
sentry.sampleRate | Error sample rate (0.0-1.0) | 1.0 |
sentry.debug | Enable Sentry debug logging | false |
See Sentry Deployment Guide for detailed error tracking setup.
Note: Network routing configuration (Istio VirtualServices, etc.) is handled externally and not part of the Teams Helm chart.
Health Checks and Graceful Shutdown
Teams uses @open-xchange/fastify-sdk for health checks and graceful shutdown in containerized environments. The SDK runs a dedicated metrics server on a separate port.
Health Check Endpoints
Live Endpoint (/live):
- Returns 200 when service is running
- Used for Kubernetes
livenessProbe - Service restarts if this fails
Ready Endpoint (/ready):
- Returns 200 when service is ready to accept traffic
- Returns 500 during startup or shutdown
- Used for Kubernetes
readinessProbe - Traffic is removed from load balancer if this fails
Kubernetes Probe Configuration:
livenessProbe:
httpGet:
path: /live
port: 9090
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /ready
port: 9090
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3Graceful Shutdown
The SDK handles graceful shutdown for:
SIGTERMsignals (Kubernetes pod termination)SIGINTsignals (Ctrl+C in development)- Uncaught exceptions
- Unhandled promise rejections
Shutdown Sequence:
- Signal received or fatal error occurs
/readyendpoint returns 500 (traffic removed from load balancer)- Kubernetes waits for
terminationGracePeriodSeconds(default: 30s) - Open event streams receive
event: shutdownand are ended; clients reconnect to another replica and re-fetch - Existing connections complete (or timeout)
- Process exits
Configure Termination Grace Period:
spec:
template:
spec:
terminationGracePeriodSeconds: 60 # Allow 60s for graceful shutdownTroubleshooting
Database Connection Failures
Symptoms:
- Service fails to start
- Logs show
Database connection failed
Solutions:
Verify database credentials:
kubectl -n production get secret teams-db-credentials -o yaml echo "<base64-encoded-password>" | base64 -dTest database connectivity:
kubectl -n production run -it --rm psql \ --image=postgres:16-alpine \ --restart=Never \ -- psql -h postgres-host -U teams -d teamsCheck SSL configuration:
ssl: securerequires valid certificates- Use
ssl: insecurefor self-signed certificates - Use
ssl: falseto disable SSL (not recommended for production)
Authentication Failures
Symptoms:
- Users cannot access Teams
- Logs show
Invalid tokenorToken exchange failed
Solutions:
Verify authentication mode configuration:
# Check if ISSUER_URL is set (Keycloak mode) kubectl -n production get deployment teams -o yaml | grep ISSUER_URL # OR check if SERVICE_TOKEN is set (Switchboard mode) kubectl -n production get deployment teams -o yaml | grep SERVICE_TOKENTest Keycloak token exchange: See Keycloak Token Exchange - Verification
Verify JWKS endpoint accessibility:
kubectl -n production run -it --rm curl \ --image=curlimages/curl:latest \ --restart=Never \ -- curl -v https://switchboard.example.com/.well-known/jwks.jsonCheck App Suite MW configuration: Verify MW trusts tokens from your authentication provider (Keycloak or Switchboard)
Service Not Ready
Symptoms:
- Pods running but readiness probe failing
/readyendpoint returns 500
Solutions:
Check service logs:
kubectl -n production logs -l app.kubernetes.io/name=teams --tail=100Verify database migrations: Migrations run as a pre-install/pre-upgrade Helm hook (see Database Migrations), before the Deployment is updated. If Pods are running, the migration already succeeded. Inspect the Job's pod logs if a release failed at the hook stage:
kubectl -n production logs job/<release>-teams-migrateIncrease startup timeout:
readinessProbe: initialDelaySeconds: 30 # Increase if app initialization is slow
High Memory Usage
Symptoms:
- Pods restarted with
OOMKilled(container exit code 137) - Memory usage climbing toward the container limit
Diagnose:
# Confirm OOMKills and how long the container ran before being killed
kubectl get pod <pod> -n <namespace> \
-o jsonpath='{.status.containerStatuses[0].lastState.terminated}'
# Live memory breakdown (RSS vs V8 heap vs external) from the metrics endpoint
kubectl port-forward -n <namespace> pod/<pod> 9090:9090
curl -s localhost:9090/metrics \
| grep -E 'process_resident_memory_bytes|nodejs_heap_size_used_bytes|nodejs_external_memory_bytes'A container OOMKilled within a minute or two of starting points to a sizing problem — the limit is too low for the startup peak plus load — not a gradual leak. A slow climb over hours points to a leak instead; check WebSocket/Yjs cleanup and the in-memory caches.
Solutions:
Right-size the pod. See Sizing and Capacity Planning. The chart default is a
256Milimit /192Mirequest.Cap the V8 heap. Node sizes its heap from the cgroup limit and does not account for native or external (Yjs/undici buffer) memory, so the heap can grow past the limit before a garbage collection runs. The chart sets
nodeOptions: "--max-old-space-size=128"— keep it well below the memory limit.Check for leaks if memory grows gradually rather than spiking:
- WebSocket connections not cleaned up on disconnect
- Unbounded in-memory caches (App Suite sessions, impersonation tokens, sync state)
- Enable Sentry error tracking for detailed error context
Security Considerations
Secrets Management
Recommended Approach:
Use external secret management systems:
- Sealed Secrets - For GitOps workflows
- External Secrets Operator - Integrate with Vault, AWS Secrets Manager, etc.
- SOPS - For encrypted secrets in Git
Example with External Secrets Operator:
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: teams-db-secret
namespace: production
spec:
refreshInterval: 1h
secretStoreRef:
name: vault-backend
kind: SecretStore
target:
name: teams-db-credentials
data:
- secretKey: host
remoteRef:
key: database/teams/credentials
property: host
- secretKey: database
remoteRef:
key: database/teams/credentials
property: database
- secretKey: username
remoteRef:
key: database/teams/credentials
property: username
- secretKey: password
remoteRef:
key: database/teams/credentials
property: password
---
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: teams-keycloak-secret
namespace: production
spec:
refreshInterval: 1h
secretStoreRef:
name: vault-backend
kind: SecretStore
target:
name: keycloak-client-secret
data:
- secretKey: client-secret
remoteRef:
key: keycloak/teams/credentials
property: client-secretThen reference these secrets in your Helm values:
database:
existingSecret: teams-db-credentials
tokenExchange:
existingSecret: keycloak-client-secret
sentry:
enabled: true
existingSecret: teams-sentry-dsnNetwork Policies
Restrict network traffic to required connections:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: teams-network-policy
namespace: production
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: teams
policyTypes:
- Ingress
- Egress
ingress:
- from:
- namespaceSelector:
matchLabels:
name: istio-system # Or your gateway namespace
ports:
- protocol: TCP
port: 8080
egress:
- to:
- namespaceSelector:
matchLabels:
name: database
ports:
- protocol: TCP
port: 5432
- to:
- namespaceSelector: {}
ports:
- protocol: TCP
port: 443 # Keycloak, App Suite MWCORS Configuration
Configure origins to restrict cross-origin access:
# Production - Specific origins only
origins: "https://appsuite.example.com,https://teams.example.com"
# Avoid wildcard in production
origins: "*" # Only for developmentSSL/TLS
Database SSL:
- Use
ssl: securefor production - Ensure database certificates are valid
- Never use
ssl: falsein production
Service TLS:
- TLS termination is handled externally (e.g., at Istio Gateway)
- Teams service communicates internally via HTTP
Performance Tuning
Sizing and Capacity Planning
The Teams service is a single Node.js process (Fastify + Yjs + PostgreSQL client
- undici HTTP client). The container memory limit is enforced against resident memory (RSS), which has three parts:
| Component | Idle | Visible in metrics |
|---|---|---|
| V8 heap (used) | ~35 MiB | nodejs_heap_size_used_bytes |
External (off-heap ArrayBuffers / Buffers) | ~8 MiB | nodejs_external_memory_bytes |
| Native — Node binary, native code, allocator arenas | ~110 MiB | none (RSS minus the above) |
Idle baseline: roughly 150 MiB RSS per pod, stable over time. The V8 heap and external gauges together are only ~45 MiB of that — most of RSS is native memory no heap gauge reports. Always size against process_resident_memory_bytes, never the heap gauges alone.
Measured behaviour under load
Load-tested with k6 (load-test/ in the repo) against a stub Middleware serving a controlled 200-thread mailbox; virtual users cycle through thread-list → thread-open → collaborative WebSocket session:
| Concurrent sessions | teams pod RSS | thread-list p95 |
|---|---|---|
| idle | ~150 MiB | — |
| 50 | ~160 MiB | tens of ms |
| 150 | ~165 MiB | tens of ms |
| 300 | ~175 MiB | tens of ms |
| 500 | ~185 MiB peak | ~30 ms |
Findings:
- No memory leak. RSS plateaus at each load level and falls back to baseline once load stops. Peak RSS under a heavy 500-session load was ~185 MiB, with
0OOMKills / restarts across the whole ramp and0.00%HTTP failures. - Latency stays low across the ramp. Aggregate p95 of thread-list requests across all stages: ~30 ms.
- The pod is CPU-bound, not memory-bound. Capacity scales with replicas/CPU rather than memory; raising the memory limit buys no additional throughput.
- The load-test "session" is deliberately aggressive (a ~6 s cycle of real work). Real users idle far more, so real-world users-per-pod is considerably higher than the synthetic numbers above.
Recommended resources (chart defaults)
resources:
requests:
cpu: 300m
memory: 192Mi
limits:
cpu: 1
memory: 256Mi192Mi request sits above the ~150 MiB idle RSS; the 256Mi limit is ~38 % above the measured heavy-load peak (~185 MiB) — headroom for the load spike plus the startup transient. Pair it with nodeOptions: "--max-old-space-size=128" so V8 garbage-collects well before the cgroup limit (--max-old-space-size bounds the V8 heap only — keep it well under the limit since native/external memory is uncounted).
Scaling out
The pod is CPU-bound, so scale on replicas/CPU, not memory — raising the memory limit buys no capacity. Budget roughly one 1-CPU pod per ~150 concurrent heavy users (more for typical mixed usage), with replica headroom for spikes. To re-measure for your own workload, run the harness in load-test/ (see its README).
Horizontal Scaling
Teams supports horizontal scaling for increased throughput:
replicaCount: 3
autoscaling:
enabled: true
minReplicas: 3
maxReplicas: 10
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 80Shared drafts are Yjs documents. Editors of one draft can connect to different pods, and the pods that have the draft open sync it over Redis pub/sub (ADR-0028). Set redis.* the same way as for Switchboard; replica sync is on when redis.hosts is set:
redis:
hosts:
- redis.example.com:6379
mode: standalone # or sentinel, clusterWithout Redis, every pod keeps its open drafts to itself, and editors on different pods don't see each other's changes until they reopen the draft. Run a single replica in that case.
Thread events (comments, assignments, status changes, imported mail) are published via PostgreSQL NOTIFY and received by every replica through its own LISTEN connection, so a user's event stream can be served by any pod regardless of where the change was written (ADR-0023). Each replica therefore holds one extra database connection.
Prefer CPU-based autoscaling for this service. Resident memory sits high and fairly flat regardless of request load (see Sizing and Capacity Planning), so targetMemoryUtilizationPercentage is a weak scaling signal and can trigger premature scale-out. If you do enable a memory target, set it relative to the limit with the idle baseline in mind.
Database Connection Pooling
Connection pooling is handled automatically by Drizzle ORM. Monitor connection usage:
# PostgreSQL connection count
psql -h postgres-host -U teams -d teams \
-c "SELECT count(*) FROM pg_stat_activity WHERE datname='teams';"Each replica holds its pool (up to 10 connections) plus one LISTEN connection for thread events.
If connection limits are reached, increase PostgreSQL max_connections. If you add a connection pooler such as PgBouncer, keep the thread-events LISTEN connection on a direct or session-mode endpoint (THREAD_EVENTS_DATABASE_HOST): transaction-mode pooling silently drops NOTIFY and the startup self-test will report thread_events_listener_healthy = 0. See Real-time Events.
Related Documentation
- Configuration Reference - Environment variables and settings
- Keycloak Token Exchange - Authentication setup
- Sentry Deployment - Error tracking configuration

