mirror of
https://github.com/ditkrg/db-backup-s3.git
synced 2026-01-22 13:56:47 +00:00
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:
parent
a9c7cc4be3
commit
90c114c647
@ -232,7 +232,7 @@ For MSSQL StatefulSets with `ReadWriteOnce` volumes, use the **sidecar pattern**
|
|||||||
|
|
||||||
**Example: StatefulSet with Backup Sidecar**
|
**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
|
```yaml
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
|
|||||||
@ -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.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
|
- **`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
|
- **`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
|
## Usage
|
||||||
|
|
||||||
|
|||||||
@ -3,9 +3,9 @@
|
|||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# 1. Copy this file and update with your actual values
|
# 1. Copy this file and update with your actual values
|
||||||
# 2. Apply: kubectl apply -f k8s-mssql-configmap.yaml
|
# 2. Apply: kubectl apply -f tests/k8s-mssql-configmap.yaml
|
||||||
# 3. Create secret: kubectl apply -f k8s-mssql-secret.yaml
|
# 3. Create secret: kubectl apply -f tests/k8s-mssql-secret.yaml
|
||||||
# 4. Deploy: kubectl apply -f k8s-statefulset-with-sidecar.yaml
|
# 4. Deploy: kubectl apply -f tests/k8s-statefulset-with-sidecar.yaml
|
||||||
|
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: ConfigMap
|
kind: ConfigMap
|
||||||
@ -1,12 +1,12 @@
|
|||||||
# Example mssql-general Secret
|
# Example mssql-general Secret
|
||||||
# This secret contains ONLY sensitive credentials (passwords, keys)
|
# 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:
|
# Usage:
|
||||||
# 1. Copy this file and update with your actual values
|
# 1. Copy this file and update with your actual values
|
||||||
# 2. Apply ConfigMap: kubectl apply -f k8s-mssql-configmap.yaml
|
# 2. Apply ConfigMap: kubectl apply -f tests/k8s-mssql-configmap.yaml
|
||||||
# 3. Apply Secret: kubectl apply -f k8s-mssql-secret.yaml
|
# 3. Apply Secret: kubectl apply -f tests/k8s-mssql-secret.yaml
|
||||||
# 4. Deploy: kubectl apply -f k8s-statefulset-with-sidecar.yaml
|
# 4. Deploy: kubectl apply -f tests/k8s-statefulset-with-sidecar.yaml
|
||||||
|
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
@ -53,7 +53,7 @@ stringData:
|
|||||||
# - AWS Secrets Manager, Azure Key Vault, or HashiCorp Vault
|
# - AWS Secrets Manager, Azure Key Vault, or HashiCorp Vault
|
||||||
#
|
#
|
||||||
# 3. Non-sensitive configuration (bucket, endpoints, schedule):
|
# 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
|
# This keeps secrets clean and allows easier configuration changes
|
||||||
#
|
#
|
||||||
# 4. Alternative: Create secret from command line:
|
# 4. Alternative: Create secret from command line:
|
||||||
@ -5,9 +5,9 @@
|
|||||||
# MSSQL's native backup files.
|
# MSSQL's native backup files.
|
||||||
#
|
#
|
||||||
# Prerequisites:
|
# Prerequisites:
|
||||||
# 1. Create the ConfigMap: kubectl apply -f k8s-mssql-configmap-example.yaml
|
# 1. Create the ConfigMap: kubectl apply -f tests/k8s-mssql-configmap-example.yaml
|
||||||
# 2. Create the Secret: kubectl apply -f k8s-mssql-secret-example.yaml
|
# 2. Create the Secret: kubectl apply -f tests/k8s-mssql-secret-example.yaml
|
||||||
# 3. Apply this StatefulSet: kubectl apply -f k8s-statefulset-with-sidecar.yaml
|
# 3. Apply this StatefulSet: kubectl apply -f tests/k8s-statefulset-test.yaml
|
||||||
#
|
#
|
||||||
# The backup container will automatically run backups according to the SCHEDULE.
|
# 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:
|
# 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
|
# - DATABASE_SERVER, DATABASE_HOST, DATABASE_NAME, DATABASE_PORT
|
||||||
# - MSSQL_DATA_DIR, MSSQL_EXTRA_OPTS
|
# - MSSQL_DATA_DIR, MSSQL_EXTRA_OPTS
|
||||||
# - SCHEDULE, BACKUP_KEEP_DAYS
|
# - SCHEDULE, BACKUP_KEEP_DAYS
|
||||||
# - S3_BUCKET, S3_PREFIX, S3_REGION, S3_ENDPOINT, S3_S3V4
|
# - S3_BUCKET, S3_PREFIX, S3_REGION, S3_ENDPOINT, S3_S3V4
|
||||||
# Note: DATABASE_HOST is overridden to "localhost" in the StatefulSet for sidecar pattern
|
# 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
|
# - MSSQL_SA_PASSWORD
|
||||||
# - DATABASE_USER, DATABASE_PASSWORD
|
# - DATABASE_USER, DATABASE_PASSWORD
|
||||||
# - S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY
|
# - S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY
|
||||||
|
|||||||
@ -5,9 +5,9 @@
|
|||||||
# MSSQL's native backup files.
|
# MSSQL's native backup files.
|
||||||
#
|
#
|
||||||
# Prerequisites:
|
# Prerequisites:
|
||||||
# 1. Create the ConfigMap: kubectl apply -f k8s-mssql-configmap-example.yaml
|
# 1. Create the ConfigMap: kubectl apply -f tests/k8s-mssql-configmap-example.yaml
|
||||||
# 2. Create the Secret: kubectl apply -f k8s-mssql-secret-example.yaml
|
# 2. Create the Secret: kubectl apply -f tests/k8s-mssql-secret-example.yaml
|
||||||
# 3. Apply this StatefulSet: kubectl apply -f k8s-statefulset-with-sidecar.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.
|
# 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:
|
# 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
|
# - DATABASE_SERVER, DATABASE_HOST, DATABASE_NAME, DATABASE_PORT
|
||||||
# - MSSQL_DATA_DIR, MSSQL_EXTRA_OPTS
|
# - MSSQL_DATA_DIR, MSSQL_EXTRA_OPTS
|
||||||
# - SCHEDULE, BACKUP_KEEP_DAYS
|
# - SCHEDULE, BACKUP_KEEP_DAYS
|
||||||
# - S3_BUCKET, S3_PREFIX, S3_REGION, S3_ENDPOINT, S3_S3V4
|
# - S3_BUCKET, S3_PREFIX, S3_REGION, S3_ENDPOINT, S3_S3V4
|
||||||
# Note: DATABASE_HOST is overridden to "localhost" in the StatefulSet for sidecar pattern
|
# 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
|
# - MSSQL_SA_PASSWORD
|
||||||
# - DATABASE_USER, DATABASE_PASSWORD
|
# - DATABASE_USER, DATABASE_PASSWORD
|
||||||
# - S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY
|
# - S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY
|
||||||
@ -19,7 +19,7 @@ DATABASE_NAME="TestDB"
|
|||||||
MSSQL_DATA_DIR="${MSSQL_DATA_DIR:-/var/opt/mssql/data}"
|
MSSQL_DATA_DIR="${MSSQL_DATA_DIR:-/var/opt/mssql/data}"
|
||||||
S3_BUCKET="${S3_BUCKET:-test-backups}"
|
S3_BUCKET="${S3_BUCKET:-test-backups}"
|
||||||
S3_ENDPOINT="${S3_ENDPOINT:-}" # Set this if using MinIO or other S3-compatible storage
|
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 function
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user