Skip to content

Nasus20202/cloudnative-babelfish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CloudNativePG Babelfish

CloudNativePG-compatible Docker images for Babelfish for PostgreSQL.

Babelfish is an open-source project that adds Microsoft SQL Server compatibility to PostgreSQL, enabling applications written for SQL Server to work with PostgreSQL with minimal code changes.

Why Babelfish?

  • ARM support - Microsoft SQL Server doesn't run on ARM architecture. Babelfish enables SQL Server workloads on ARM-based infrastructure (Apple Silicon, AWS Graviton, etc.)
  • Kubernetes-native - Fully compatible with CloudNativePG for cloud-native deployments

Example

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: babelfish-cluster
spec:
  instances: 3
  imageName: ghcr.io/nasus20202/cloudnative-babelfish:17.6-5.3.0

  postgresql:
    shared_preload_libraries:
      - babelfishpg_tds

    # pg_hba rules for TDS authentication
    pg_hba:
      - host babelfish_db babelfish_user 0.0.0.0/0 md5

    parameters:
      babelfishpg_tds.listen_addresses: "*"
      babelfishpg_tds.port: "1433"
      babelfishpg_tsql.database_name: "babelfish_db"
      babelfishpg_tsql.migration_mode: "single-db"
      babelfishpg_tsql.isolation_level_serializable: "pg_isolation"

  bootstrap:
    initdb:
      database: babelfish_db
      owner: babelfish_user
      postInitTemplateSQL:
        - CREATE EXTENSION IF NOT EXISTS babelfishpg_tds CASCADE
      postInitApplicationSQL:
        - GRANT ALL ON SCHEMA sys TO babelfish_user
        - ALTER USER babelfish_user CREATEDB
        - CALL sys.initialize_babelfish('babelfish_user')

  storage:
    size: 10Gi

  # TDS services for SQL Server clients
  managed:
    services:
      additional:
        - selectorType: rw
          serviceTemplate:
            metadata:
              name: babelfish-cluster-tds-rw
            spec:
              type: ClusterIP
              ports:
                - name: tds
                  port: 1433
                  targetPort: 1433

See examples/cluster-basic.yaml for a full example with resource limits, affinity rules, and additional TDS services.

Connecting via SQL Server Protocol

After deploying the cluster, connect using any SQL Server client (e.g., sqlcmd, SSMS, Azure Data Studio):

# Get the password from the Kubernetes secret
kubectl get secret babelfish-cluster-app -o jsonpath='{.data.password}' | base64 -d

# Connect via sqlcmd
sqlcmd -S babelfish-cluster-tds-rw -U babelfish_user -P '<password>'

Babelfish initializes with the standard SQL Server system databases (master, tempdb, msdb). User databases must be created separately via TDS:

CREATE DATABASE myapp;
GO
USE myapp;
GO

About

Cloudnative PG compatible image for Babelfish MSSQL compatibility layer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors