Add example ConfigMap and Secret for MSSQL backup configuration

- Introduced `k8s-mssql-configmap-example.yaml` and `k8s-mssql-secret-example.yaml` to provide templates for non-sensitive and sensitive configurations, respectively.
- Updated `README.md` and `k8s-statefulset-test.yaml` to reference the new example files.
- Created `k8s-statefulset-with-sidecar.yaml` for deploying MSSQL with a backup sidecar, enhancing the backup functionality.

Signed-off-by: Shakar Bakr <5h4k4r.b4kr@gmail.com>
This commit is contained in:
Shakar Bakr 2025-10-27 13:22:19 +03:00
parent a9c7cc4be3
commit 90c114c647
No known key found for this signature in database
GPG Key ID: DA55A26823AE3C28
7 changed files with 26 additions and 21 deletions

View File

@ -232,7 +232,7 @@ For MSSQL StatefulSets with `ReadWriteOnce` volumes, use the **sidecar pattern**
**Example: StatefulSet with Backup Sidecar**
See [`k8s-statefulset-with-sidecar.yaml`](./k8s-statefulset-with-sidecar.yaml) for a complete example.
See [`tests/k8s-statefulset-with-sidecar.yaml`](./tests/k8s-statefulset-with-sidecar.yaml) for a complete example.
```yaml
apiVersion: apps/v1

View File

@ -11,7 +11,12 @@ This directory contains automated test scripts for validating the backup and res
- **`test-mssql-k8s.sh`**: Tests MSSQL StatefulSet with backup sidecar (requires existing S3/MinIO)
- **`test-mssql-k8s-with-minio.sh`**: Complete automated test that deploys MinIO alongside MSSQL
- **`setup-minio-k8s.sh`**: Helper script to deploy MinIO in Kubernetes
- **`k8s-statefulset-test.yaml`**: Test StatefulSet configuration used by the test scripts
### Kubernetes Configuration Examples
- **`k8s-statefulset-with-sidecar.yaml`**: Production-ready MSSQL StatefulSet with backup sidecar
- **`k8s-statefulset-test.yaml`**: Test StatefulSet configuration used by automated test scripts
- **`k8s-mssql-configmap-example.yaml`**: Example ConfigMap for non-sensitive configuration
- **`k8s-mssql-secret-example.yaml`**: Example Secret for sensitive credentials
## Usage

View File

@ -3,9 +3,9 @@
#
# Usage:
# 1. Copy this file and update with your actual values
# 2. Apply: kubectl apply -f k8s-mssql-configmap.yaml
# 3. Create secret: kubectl apply -f k8s-mssql-secret.yaml
# 4. Deploy: kubectl apply -f k8s-statefulset-with-sidecar.yaml
# 2. Apply: kubectl apply -f tests/k8s-mssql-configmap.yaml
# 3. Create secret: kubectl apply -f tests/k8s-mssql-secret.yaml
# 4. Deploy: kubectl apply -f tests/k8s-statefulset-with-sidecar.yaml
apiVersion: v1
kind: ConfigMap

View File

@ -1,12 +1,12 @@
# Example mssql-general Secret
# This secret contains ONLY sensitive credentials (passwords, keys)
# Non-sensitive configuration is in the ConfigMap (k8s-mssql-configmap-example.yaml)
# Non-sensitive configuration is in the ConfigMap (tests/k8s-mssql-configmap-example.yaml)
#
# Usage:
# 1. Copy this file and update with your actual values
# 2. Apply ConfigMap: kubectl apply -f k8s-mssql-configmap.yaml
# 3. Apply Secret: kubectl apply -f k8s-mssql-secret.yaml
# 4. Deploy: kubectl apply -f k8s-statefulset-with-sidecar.yaml
# 2. Apply ConfigMap: kubectl apply -f tests/k8s-mssql-configmap.yaml
# 3. Apply Secret: kubectl apply -f tests/k8s-mssql-secret.yaml
# 4. Deploy: kubectl apply -f tests/k8s-statefulset-with-sidecar.yaml
apiVersion: v1
kind: Secret
@ -53,7 +53,7 @@ stringData:
# - AWS Secrets Manager, Azure Key Vault, or HashiCorp Vault
#
# 3. Non-sensitive configuration (bucket, endpoints, schedule):
# These are now in the ConfigMap (k8s-mssql-configmap-example.yaml)
# These are now in the ConfigMap (tests/k8s-mssql-configmap-example.yaml)
# This keeps secrets clean and allows easier configuration changes
#
# 4. Alternative: Create secret from command line:

View File

@ -5,9 +5,9 @@
# MSSQL's native backup files.
#
# Prerequisites:
# 1. Create the ConfigMap: kubectl apply -f k8s-mssql-configmap-example.yaml
# 2. Create the Secret: kubectl apply -f k8s-mssql-secret-example.yaml
# 3. Apply this StatefulSet: kubectl apply -f k8s-statefulset-with-sidecar.yaml
# 1. Create the ConfigMap: kubectl apply -f tests/k8s-mssql-configmap-example.yaml
# 2. Create the Secret: kubectl apply -f tests/k8s-mssql-secret-example.yaml
# 3. Apply this StatefulSet: kubectl apply -f tests/k8s-statefulset-test.yaml
#
# The backup container will automatically run backups according to the SCHEDULE.
#
@ -117,14 +117,14 @@ spec:
#
# This StatefulSet uses a ConfigMap for non-sensitive config and a Secret for credentials:
#
# ConfigMap (mssql-config) - See k8s-mssql-configmap-example.yaml
# ConfigMap (mssql-config) - See tests/k8s-mssql-configmap-example.yaml
# - DATABASE_SERVER, DATABASE_HOST, DATABASE_NAME, DATABASE_PORT
# - MSSQL_DATA_DIR, MSSQL_EXTRA_OPTS
# - SCHEDULE, BACKUP_KEEP_DAYS
# - S3_BUCKET, S3_PREFIX, S3_REGION, S3_ENDPOINT, S3_S3V4
# Note: DATABASE_HOST is overridden to "localhost" in the StatefulSet for sidecar pattern
#
# Secret (mssql-general) - See k8s-mssql-secret-example.yaml
# Secret (mssql-general) - See tests/k8s-mssql-secret-example.yaml
# - MSSQL_SA_PASSWORD
# - DATABASE_USER, DATABASE_PASSWORD
# - S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY

View File

@ -5,9 +5,9 @@
# MSSQL's native backup files.
#
# Prerequisites:
# 1. Create the ConfigMap: kubectl apply -f k8s-mssql-configmap-example.yaml
# 2. Create the Secret: kubectl apply -f k8s-mssql-secret-example.yaml
# 3. Apply this StatefulSet: kubectl apply -f k8s-statefulset-with-sidecar.yaml
# 1. Create the ConfigMap: kubectl apply -f tests/k8s-mssql-configmap-example.yaml
# 2. Create the Secret: kubectl apply -f tests/k8s-mssql-secret-example.yaml
# 3. Apply this StatefulSet: kubectl apply -f tests/k8s-statefulset-with-sidecar.yaml
#
# The backup container will automatically run backups according to the SCHEDULE.
#
@ -116,14 +116,14 @@ spec:
#
# This StatefulSet uses a ConfigMap for non-sensitive config and a Secret for credentials:
#
# ConfigMap (mssql-config) - See k8s-mssql-configmap-example.yaml
# ConfigMap (mssql-config) - See tests/k8s-mssql-configmap-example.yaml
# - DATABASE_SERVER, DATABASE_HOST, DATABASE_NAME, DATABASE_PORT
# - MSSQL_DATA_DIR, MSSQL_EXTRA_OPTS
# - SCHEDULE, BACKUP_KEEP_DAYS
# - S3_BUCKET, S3_PREFIX, S3_REGION, S3_ENDPOINT, S3_S3V4
# Note: DATABASE_HOST is overridden to "localhost" in the StatefulSet for sidecar pattern
#
# Secret (mssql-general) - See k8s-mssql-secret-example.yaml
# Secret (mssql-general) - See tests/k8s-mssql-secret-example.yaml
# - MSSQL_SA_PASSWORD
# - DATABASE_USER, DATABASE_PASSWORD
# - S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY

View File

@ -19,7 +19,7 @@ DATABASE_NAME="TestDB"
MSSQL_DATA_DIR="${MSSQL_DATA_DIR:-/var/opt/mssql/data}"
S3_BUCKET="${S3_BUCKET:-test-backups}"
S3_ENDPOINT="${S3_ENDPOINT:-}" # Set this if using MinIO or other S3-compatible storage
STATEFULSET_FILE="${STATEFULSET_FILE:-$(dirname "$0")/../k8s-statefulset-with-sidecar.yaml}"
STATEFULSET_FILE="${STATEFULSET_FILE:-$(dirname "$0")/k8s-statefulset-with-sidecar.yaml}"
# Cleanup function
cleanup() {