Skip to content

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:

  1. 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
  2. Kubernetes Cluster - Production deployment target

    • Kubernetes 1.19+ recommended
    • Helm 3.x for chart installation
  3. 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_connections for one pool (10) plus one LISTEN connection per replica
  4. 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:

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.com

Helm 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-secret

Important: 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:

  1. 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
  2. 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_jwt
  3. Generate Service Token:

    kubectl -n appsuite exec deployments/switchboard -- \
      /usr/bin/node /app/bin/create-service-token.js teams.example.com 365d

    Save the output as your service token.

Environment Variables:

SERVICE_TOKEN=<generated-service-token>
ISSUER_ALLOWLIST=switchboard.example.com
SWITCHBOARD_API_PATH=/api

Helm Configuration:

serviceToken: <generated-service-token>

oidc:
  issuer: switchboard.example.com

switchboardApiPath: /api

Important: 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:

  1. Certificate Authority — A cert-manager ClusterIssuer (e.g., postgres-ca-issuer) acts as the root CA for all PostgreSQL certificates
  2. Server certificate — Issued to the PostgreSQL cluster for TLS termination
  3. Client certificates — Issued per namespace/application, with the Common Name matching the PostgreSQL role

The CloudNativePG operator simplifies database provisioning in Kubernetes environments.

Prerequisites:

  • CloudNativePG operator installed in cluster
  • cert-manager installed with a ClusterIssuer for PostgreSQL certificates

Steps:

  1. 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 days
  2. Create 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: teams
  3. Issue 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 days
  4. Configure 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 secret

    The Helm chart mounts the secret at /etc/ssl/db/ and sets DATABASE_SSL_CA_PATH, DATABASE_SSL_CERT_PATH, and DATABASE_SSL_KEY_PATH automatically. No password is needed.

Option 2: External PostgreSQL with Client Certificates

For environments using external database services that support mTLS.

Steps:

  1. Obtain client certificate from your database provider or internal CA

  2. 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)\"}}"
  3. 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

  1. Create Values File:

    Create teams-values.yaml with 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: secure

    Note: Network routing to the Teams service should be configured externally (e.g., Istio VirtualService).

  2. Install Chart:

    helm install teams \
      oci://registry.open-xchange.com/appsuite-core-internal/charts/teams \
      -f teams-values.yaml \
      --namespace production \
      --create-namespace

    Note: Helm 3.8.0+ is required for OCI registry support.

  3. 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-migrate

The 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 production

Under Argo CD a manual Sync re-fires the PreSync hook regardless of whether anything is OutOfSync.

Upgrading

  1. Update Values File (if needed)

  2. Upgrade Release:

    helm upgrade teams \
      oci://registry.open-xchange.com/appsuite-core-internal/charts/teams \
      -f teams-values.yaml \
      --namespace production
  3. Monitor 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 production

Network 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: 80

Integration 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: 80

Important Notes

  • Gateway Reference: Adjust gateways to reference your actual Istio Gateway (e.g., istio-system/default-gateway)
  • Hostnames: Configure hosts to match your domain
  • Service Name: The service name teams matches the Helm release name
  • Port: Teams service listens on port 80 internally (container port 8080)
  • Path Rewriting: The /teams prefix 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/events is a long-lived text/event-stream response. Istio applies no request timeout by default; do not set timeout on the route carrying it (Istio rejects 0s, and any positive value cuts the stream). With nginx ingress instead of Istio, disable proxy buffering and raise proxy-read-timeout for 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/ws

Configuration Reference

Complete Helm chart configuration options:

Image Configuration

ParameterDescriptionDefault
image.repositoryContainer image repositoryregistry.open-xchange.com/appsuite-core/teams
image.pullPolicyImage pull policyIfNotPresent
image.tagImage tag (defaults to chart appVersion)""

Service Configuration

ParameterDescriptionDefault
bindAddrIP address to bind (IPv6 :: or IPv4 0.0.0.0)"::"
hostnameService hostname""
originsAllowed CORS origins (comma-separated or *)"*"
logLevelLog level (trace, debug, info, warn, error, fatal)"info"
logJsonEnable JSON loggingfalse
exposeApiDocsExpose Swagger UI at /api-docsfalse

Authentication Configuration (Token Exchange)

ParameterDescriptionDefault
tokenExchange.enabledEnable Keycloak token exchangefalse
tokenExchange.issuerUrlKeycloak realm URL""
tokenExchange.clientIdKeycloak client ID""
tokenExchange.clientSecretKeycloak client secret (not recommended, use existingSecret)""
tokenExchange.existingSecretUse existing secret for client credentials (recommended)""
tokenExchange.clientSecretKeyKey in existing secret containing client secret"client-secret"

Authentication Configuration (Switchboard Legacy)

ParameterDescriptionDefault
serviceTokenSwitchboard service token (mutually exclusive with oidc)""
switchboardApiPathSwitchboard API path"/api"

Authentication Configuration (Shared)

ParameterDescriptionDefault
oidc.issuerOIDC issuer domain for JWT validation (required)""

Database Configuration

ParameterDescriptionDefault
database.hostPostgreSQL hostname""
database.portPostgreSQL port"5432"
database.nameDatabase name""
database.auth.userDatabase username (deprecated, use existingSecret)""
database.auth.passwordDatabase password (deprecated, use existingSecret)""
database.existingSecretUse existing secret for all database credentials (recommended)""
database.existingSecretKeys.hostKey in existing secret for database host"host"
database.existingSecretKeys.databaseKey in existing secret for database name"database"
database.existingSecretKeys.usernameKey in existing secret for username"username"
database.existingSecretKeys.passwordKey in existing secret for password"password"
database.sslSSL mode (secure, insecure, false)"secure"

Database Migration Configuration

ParameterDescriptionDefault
migrate.triggerValuePer-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

ParameterDescriptionDefault
sentry.enabledEnable Sentry error trackingfalse
sentry.dsnBackend Sentry DSN""
sentry.dsnFrontendFrontend DSN (optional, defaults to backend DSN)""
sentry.existingSecretUse existing secret for Sentry DSN values (recommended for GitOps)""
sentry.dsnKeyKey in existing secret containing the backend DSN"sentry-dsn"
sentry.dsnFrontendKeyKey in existing secret containing the frontend DSN (falls back to dsnKey)""
sentry.environmentEnvironment tag"production"
sentry.releaseRelease version (defaults to chart appVersion)""
sentry.sampleRateError sample rate (0.0-1.0)1.0
sentry.debugEnable Sentry debug loggingfalse

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: 3

Graceful Shutdown

The SDK handles graceful shutdown for:

  • SIGTERM signals (Kubernetes pod termination)
  • SIGINT signals (Ctrl+C in development)
  • Uncaught exceptions
  • Unhandled promise rejections

Shutdown Sequence:

  1. Signal received or fatal error occurs
  2. /ready endpoint returns 500 (traffic removed from load balancer)
  3. Kubernetes waits for terminationGracePeriodSeconds (default: 30s)
  4. Open event streams receive event: shutdown and are ended; clients reconnect to another replica and re-fetch
  5. Existing connections complete (or timeout)
  6. Process exits

Configure Termination Grace Period:

spec:
  template:
    spec:
      terminationGracePeriodSeconds: 60  # Allow 60s for graceful shutdown

Troubleshooting

Database Connection Failures

Symptoms:

  • Service fails to start
  • Logs show Database connection failed

Solutions:

  1. Verify database credentials:

    kubectl -n production get secret teams-db-credentials -o yaml
    echo "<base64-encoded-password>" | base64 -d
  2. Test database connectivity:

    kubectl -n production run -it --rm psql \
      --image=postgres:16-alpine \
      --restart=Never \
      -- psql -h postgres-host -U teams -d teams
  3. Check SSL configuration:

    • ssl: secure requires valid certificates
    • Use ssl: insecure for self-signed certificates
    • Use ssl: false to disable SSL (not recommended for production)

Authentication Failures

Symptoms:

  • Users cannot access Teams
  • Logs show Invalid token or Token exchange failed

Solutions:

  1. 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_TOKEN
  2. Test Keycloak token exchange: See Keycloak Token Exchange - Verification

  3. 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.json
  4. Check 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
  • /ready endpoint returns 500

Solutions:

  1. Check service logs:

    kubectl -n production logs -l app.kubernetes.io/name=teams --tail=100
  2. Verify 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-migrate
  3. Increase 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:

  1. Right-size the pod. See Sizing and Capacity Planning. The chart default is a 256Mi limit / 192Mi request.

  2. 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.

  3. 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-secret

Then reference these secrets in your Helm values:

database:
  existingSecret: teams-db-credentials

tokenExchange:
  existingSecret: keycloak-client-secret

sentry:
  enabled: true
  existingSecret: teams-sentry-dsn

Network 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 MW

CORS 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 development

SSL/TLS

Database SSL:

  • Use ssl: secure for production
  • Ensure database certificates are valid
  • Never use ssl: false in 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:
ComponentIdleVisible in metrics
V8 heap (used)~35 MiBnodejs_heap_size_used_bytes
External (off-heap ArrayBuffers / Buffers)~8 MiBnodejs_external_memory_bytes
Native — Node binary, native code, allocator arenas~110 MiBnone (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 sessionsteams pod RSSthread-list p95
idle~150 MiB—
50~160 MiBtens of ms
150~165 MiBtens of ms
300~175 MiBtens 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 0 OOMKills / restarts across the whole ramp and 0.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.
resources:
  requests:
    cpu: 300m
    memory: 192Mi
  limits:
    cpu: 1
    memory: 256Mi

192Mi 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: 80

Shared 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, cluster

Without 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.