PAM DB

Privileged Access Management for just-in-time database access via Slack

PAM DB (Privileged Access Management for Database) is a just-in-time (JIT) database access system that grants engineers temporary read-only access to production databases via Slack commands.

ArgoCD Resource

PropertyValue
KindApplication
Namepamdb
Namespaceargocd
Destination Namespacepam-system
Projectinfra-services
Source TypeKustomize
File Pathk8s/infra-services/argocd/overlays/infra-platform-cluster/apps/pamdb.yaml

Application Definition

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: pamdb
  labels:
    cluster: 'infra-platform-mgmt'
    environment: 'prod'
  finalizers:
    - resources-finalizer.argocd.argoproj.io
  annotations:
    notifications.argoproj.io/subscribe.on-app-synced.slack: platform-infra-notifications
    notifications.argoproj.io/subscribe.on-app-outofsync.slack: platform-infra-notifications
    notifications.argoproj.io/subscribe.on-app-sync-failed.slack: platform-infra-notifications
    notifications.argoproj.io/subscribe.on-app-degraded.slack: platform-infra-notifications
spec:
  syncPolicy:
    automated:
      prune: true
  destination:
    namespace: pam-system
    server: https://kubernetes.default.svc
  project: infra-services
  source:
    path: k8s/infra-services/pamdb/deployments/k8s
    repoURL: https://github.com/Titanbay/infra-services
    targetRevision: 'chore/slack-db-pam'

Manifest Organisation

The PAM DB manifests are located in the service’s deployment directory:

k8s/infra-services/pamdb/
├── cmd/                            # Go source code
│   ├── webhook/main.go             # HTTP server & Slack handler
│   └── cleanup/main.go             # Cleanup job for expired roles
├── pkg/                            # Shared Go packages
├── deployments/
│   ├── docker/Dockerfile           # Container image
│   └── k8s/                        # Kubernetes manifests (ArgoCD source)
│       ├── kustomization.yaml      # Kustomization with labels
│       ├── namespace.yaml          # pam-system namespace
│       ├── serviceaccount.yaml     # Service account
│       ├── secretstore.yaml        # GCP Secret Manager store
│       ├── configmap.yaml          # Whitelist configuration
│       ├── secret.yaml             # ExternalSecret for credentials
│       ├── deployment.yaml         # Webhook server deployment
│       ├── service.yaml            # ClusterIP service
│       └── cronjob.yaml            # Cleanup job for expired access
└── configs/whitelist.txt           # Authorised email addresses

Key Components

ResourcePurpose
DeploymentGo webhook server handling Slack /pamdb commands
CronJobRevokes expired database roles automatically
ConfigMapWhitelist of authorised email addresses
ExternalSecretDatabase and Slack credentials
SecretStoreGCP Secret Manager integration

Features

  • Slack Integration: Request access via /pamdb slash command
  • Whitelist Control: Only pre-approved emails can request access
  • Time-Limited Access: Automatically expires after 4 hours (configurable)
  • Read-Only Grants: SELECT-only permissions on all tables
  • Automatic Cleanup: CronJob revokes expired access
  • Cloud SQL Connector: Native Go library for secure Cloud SQL connections

How to Update

Modifying Configuration

  1. Edit the appropriate file in k8s/infra-services/pamdb/deployments/k8s/
  2. Commit and push to the tracked branch
  3. ArgoCD auto-syncs the changes

Updating the Whitelist

  1. Edit deployments/k8s/configmap.yaml to add/remove authorised emails
  2. Commit and push
  3. The service can reload the whitelist without restart via POST /reload

Updating the Application

  1. Modify Go source code in cmd/ or pkg/
  2. Build and push a new container image
  3. Update the image tag in deployments/k8s/deployment.yaml
  4. Commit and push

Secrets Management

PAM DB credentials are managed via External Secrets:

SecretPurpose
SLACK_SIGNING_SECRETSlack request verification
SLACK_BOT_TOKENSlack API access
DB_ADMIN_USERDatabase admin username
DB_ADMIN_PASSWORDDatabase admin password

Notifications

The Application sends Slack notifications to #platform-infra-notifications for:

  • Sync success
  • Out of sync detection
  • Sync failures
  • Degraded health