mssql

by HelmForge

Helm chartv1.1.0App 17.0.4085.5Apache-2.0Verified publisher

Microsoft SQL Server with explicit editions, encrypted connections, persistent singleton operation and native S3 backups.

About this chart

Microsoft SQL Server

Run Microsoft's official Linux SQL Server image as a persistent, encrypted single instance. The chart separates engine version from edition, requires explicit EULA acceptance, provisions declared application databases and supplies native backups uploaded to S3 without excluding Express users.

Features

  • One StatefulSet Pod and one database writer, including system databases and keys.
  • Official MCR image pinned by release and digest, Linux amd64 only.
  • Express by default; Developer variants and licensed editions explicitly selectable.
  • TLS encryption enforced, with retained generated CA/certificate or an existing TLS Secret.
  • Native SQL authentication, retained generated credentials or existing/ESO Secrets.
  • Non-root UID/GID 10001, read-only image, only NET_BIND_SERVICE capability, no API token.
  • Authenticated readiness and independent TCP liveness; explicit SQL network peers.
  • Native full COPY_ONLY backups, CHECKSUM, SHA-256 manifest and HTTPS S3 upload.
  • Optional original-maintainer SQL exporter, ServiceMonitor and PrometheusRule.

This is a singleton deployment. Pod recovery and StatefulSet upgrades involve downtime. It does not configure Always On, replication, automatic database failover, horizontal autoscaling, log backups or point-in-time recovery.

Architecture

The chart deploys one SQL Server StatefulSet behind a TCP Service. By default, a retained data PVC stores system and user databases. When persistence.enabled is false, the chart uses ephemeral emptyDir storage that does not retain databases across Pod recreation or rescheduling. Optional backup and metrics workloads use dedicated identities, selectors and least-privilege SQL logins. See DESIGN.md for the topology, trust boundaries and intentional gaps.

Install and select an edition

Read Microsoft's container licensing guidance. Without license.acceptEULA: true, the chart creates only a consent ConfigMap: no SQL process, credentials, Service or PVC. This prevents implicit license acceptance.

license:
  acceptEULA: true
sql:
  edition: Express
helm repo add helmforge https://repo.helmforge.dev
helm repo update
helm upgrade --install database helmforge/mssql -n database --create-namespace -f values.yaml

OCI installation uses oci://ghcr.io/helmforgedev/helm/mssql. image.tag selects the SQL Server engine; sql.edition selects its licensed feature set. Developer maps to EnterpriseDeveloper on 2025 and Developer on 2022. Developer/StandardDeveloper/EnterpriseDeveloper are for development and testing. Express can serve production workloads within its limits. Standard/Enterprise require appropriate licenses; the chart does not grant one.

See editions and version compatibility, 2022, development, staging and production. Product keys are accepted only through a Secret reference with sql.edition: ProductKey.

Configuration

The complete contract is documented in values.yaml, with field-level validation in values.schema.json and cross-field guardrails in the chart templates. These settings define the most common installation choices:

ValueDefaultPurpose
commonAnnotations{}Add annotations to every chart-owned resource; resource-specific values take precedence
license.acceptEULAfalseExplicitly accept Microsoft's EULA and render SQL resources
sql.editionExpressSelect the licensed SQL Server edition independently of the image
sql.memoryLimitMB3072Cap native SQL Server memory while leaving container headroom
auth.existingSecret""Reuse credentials instead of generating retained passwords
tls.existingSecret""Reuse a TLS Secret instead of generating retained certificates
persistence.enabledtruePersist system and user databases
persistence.size20GiSet the generated data PVC capacity
persistence.retaintrueRetain generated data and recovery material on uninstall
service.typeClusterIPSelect SQL TCP Service exposure
service.port1433Set the client-facing SQL Service port
networkPolicy.enabledtrueRestrict SQL, monitoring and backup network paths
backup.enabledfalseEnable native full backup and S3 upload
backup.s3.credentialsFromPodIdentityfalseUse ambient S3 credentials instead of a static Secret
backup.serviceAccount.createtrueCreate the dedicated ServiceAccount used by backup Jobs
metrics.enabledfalseEnable the authenticated SQL exporter
externalSecrets.enabledfalseRender ExternalSecret resources for supplied item definitions

Schema validation rejects invalid field types, enums, patterns and identifiers. Chart guardrails reject incompatible editions, insufficient memory headroom and incomplete backup, metrics or External Secrets contracts before resources reach the cluster.

Connect securely

The Service exposes SQL TCP 1433 by default. This is not an HTTP endpoint; HTTP Ingress and HTTPRoute are deliberately absent. Keep ClusterIP and authorize only application peers through networkPolicy.ingressFrom. External LoadBalancer exposure requires routing, firewall and certificate planning.

The TLS Secret contains tls.crt, tls.key, ca.crt. With generated certificates, trust the supplied CA and use the Service DNS name. Add external DNS names through tls.extraDnsNames before the first installation, or supply your own certificate. Generated certificates are retained on Helm upgrades; editing SANs/duration does not silently replace an existing certificate. See operations.

Use an application login for normal traffic. To perform administrator operations, retrieve the sa-password entry from the Secret identified in Helm NOTES and pass it through SQLCMDPASSWORD or a secure credential provider, never CLI -P. The chart probes use loopback with explicit certificate trust bypass restricted to that in-Pod connection; remote backup and monitoring connections verify CA and name.

Credentials and database initialization

The authentication Secret has four entries: sa-password, probe-password, metrics-password, backup-password. The managed mode generates strong random values and retains them through live Helm lookup. Existing Secret mode is preferred for GitOps/render-only controllers. External Secrets uses the canonical items[] contract and the actual external-secrets.io/v1 CRD.

Changing a Kubernetes Secret does not alter an existing SQL login. The bootstrap verifies configured credentials and does not silently reset passwords in persisted master. Rotate SQL credentials deliberately, then update the corresponding Secret and restart dependent clients as described in operations.

initdb:
  databases:
    - name: application
      username: application
      existingSecret: application-db
      passwordKey: password
      recoveryModel: SIMPLE
      roles: [db_datareader, db_datawriter, db_ddladmin]

Database and login names use a restricted ASCII identifier contract. Existing databases/logins are preserved. Recovery mode is applied only when creating a new database. The supplied application password must match a pre-existing login. Default roles permit common reads/writes/schema migrations, not server administration; choose narrower roles where applicable. Role changes add grants and do not revoke earlier grants automatically. Removing a values entry never drops a database/login.

Reviewed .sql files may be mounted through initdb.scriptsConfigMaps. These are trusted administrator scripts, executed in a transaction on one sqlcmd connection. A durable ledger records names and SHA-256 hashes after success. Applied scripts must be immutable: use a new filename for a new migration. Avoid scripts that manage their own transactions or require nontransactional SQL operations.

Storage and memory

The default 20Gi data claim retains /var/opt/mssql, including master, user databases, logs and the SQL encryption hierarchy. When persistence.enabled and persistence.retain are true, Helm keeps the generated data PVC and the generated authentication and TLS Secrets on uninstall. Reinstallation can then recover the persisted SQL logins with their matching credentials and trust material. Keep the same release identity, or explicitly reference retained resources through persistence.existingClaim, auth.existingSecret and tls.existingSecret.

Retained Secrets remain sensitive resources under your management after uninstall. Protect and back them up with the recovery configuration; delete them deliberately only when the corresponding retained database is retired or its credentials and trust have been migrated. Existing Secrets remain owned by their external manager; ESO installations need stable provider values and appropriate target-Secret lifecycle settings. Retention does not copy externally managed credentials. Do not initialize a second SQL writer against the same data claim. persistence.enabled: false is a disposable test mode and does not retain generated authentication or TLS Secrets through this setting.

The default Pod requests and limits are both 2 CPU/4Gi. Native server memory is capped at 3072Mi to leave process overhead. Schema/helper checks reject insufficient memory headroom. Budget actual workload growth, storage latency and backup staging separately. Both supported engine pins honor cgroup v2. Microsoft supports Linux x86-64 container hosts, not ARM emulation.

S3 backup and recovery

Enable the backup example with explicit databases, destination bucket, HTTPS endpoint/region and either a static AWS credentials Secret or ambient credentials through backup.s3.credentialsFromPodIdentity. Backup Jobs always use a dedicated ServiceAccount. Configure its name and identity annotations under backup.serviceAccount, or reference an existing dedicated account by setting create: false. The legacy explicit web-identity fields remain supported for upgrades. The chart does not create buckets or change retention.

The SQL server writes consistent native backups into a dedicated staging PVC. A scheduled Job is placed on the SQL node so both containers can mount RWO storage. The SQL client uses a dedicated login with db_backupoperator only on selected databases. The AWS CLI uploads verified files and publishes a manifest last. Successful runs and graceful failures remove only their own local archive files, so repeated upload failures do not accumulate full database backups in staging. A bounded /backup/.last-failure JSON record preserves failure diagnostics. Abrupt SIGKILL or node loss can leave orphaned files; inspect and remove those specific files manually after confirming no active run owns them. No S3 object is deleted by the chart; bucket lifecycle rules handle incomplete remote prefixes.

Express/Web reject compression; Express needs neither SQL Agent nor native S3 URL support for this pipeline. Use S3 encryption/lifecycle controls and a recovery drill appropriate to your data. Copy-only full backups do not truncate FULL recovery logs or offer PITR. See backup, retention, permissions and restore.

Monitoring

The optional SQL exporter has a separate Pod/Service, a dedicated SQL login and a CA-validated connection. Explicitly authorize Prometheus peers. The exporter mounts Secret key ca.crt as /tls/ca.pem; external DSNs must use certificate=/tls/ca.pem with encryption enabled and certificate verification. The Go SQL driver requires a .pem or .der filename extension. With externally managed SQL credentials, provide metrics.existingSecret with a matching DSN instead of requiring Helm to read credentials before ESO synchronizes.

Alerts cover unavailable/missing scrape targets and databases outside ONLINE. Exporter SQL metrics do not prove a successful S3 upload. Monitor the backup CronJob, remote completion manifests, staging capacity and .last-success as distinct signals. See metrics values.

Examples

  • Simple Express deployment
  • SQL Server 2022
  • Developer edition
  • Staging
  • Production
  • S3 backup
  • Prometheus metrics
  • External Secrets

Troubleshooting

If only the consent ConfigMap is rendered, set license.acceptEULA=true after reviewing Microsoft's license. For a Pod that never becomes Ready, inspect the bootstrap container logs and confirm that retained SQL credentials still match the persisted master database:

kubectl logs statefulset/<statefulset-name> -n <namespace> -c mssql
kubectl describe pod -n <namespace> -l 'app.kubernetes.io/instance=<release>,app.kubernetes.io/component=server'

For TLS failures, verify that clients trust ca.crt and connect through a DNS name present in the server certificate. For backup failures, inspect the CronJob, its latest Job and /backup/.last-failure before removing any orphaned staging files. The detailed recovery and credential procedures are in operations and backup and restore.

Validation and security scan

Release acceptance requires the complete make validate-chart CHART=mssql gate, real SQL operations, TLS rejection tests, data retention, S3 upload/restore and Prometheus query checks. Paid editions are contract/render tested unless a licensed runtime environment is supplied; Developer pr

Deploy mssql with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has mssql on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartmssql is pinned at v1.1.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply