1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-24 17:04:43 +00:00

No longer using memcached. Replication settings for standalong mariadb. Use --single-transaction in mariadb replica-watcher so mysqldump does not lock tables. Added horizontal pod autoscaler to the app statefulset

This commit is contained in:
2025-10-30 08:50:31 -04:00
parent 6e9554be55
commit 92bd06fe3c
4 changed files with 33 additions and 65 deletions

View File

@@ -122,12 +122,12 @@ spec:
DUMP_FILE="/tmp/${DB_NAME}_backup.sql" DUMP_FILE="/tmp/${DB_NAME}_backup.sql"
echo "Dumping ${DB_NAME} from master ${MASTER_SERVICE_HOST}" | tee -a "$LOG" echo "Dumping ${DB_NAME} from master ${MASTER_SERVICE_HOST}" | tee -a "$LOG"
if command -v timeout >/dev/null 2>&1; then if command -v timeout >/dev/null 2>&1; then
if ! timeout 300 mysqldump --protocol=TCP -h "$MASTER_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" "$DB_NAME" \ if ! timeout 300 mysqldump --protocol=TCP -h "$MASTER_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" --single-transaction "$DB_NAME" \
| tee "$DUMP_FILE" >/dev/null 2>>"$LOG"; then | tee "$DUMP_FILE" >/dev/null 2>>"$LOG"; then
echo "Dump FAILED; aborting this cycle" | tee -a "$LOG"; sleep 120; continue echo "Dump FAILED; aborting this cycle" | tee -a "$LOG"; sleep 120; continue
fi fi
else else
if ! mysqldump --protocol=TCP -h "$MASTER_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" "$DB_NAME" \ if ! mysqldump --protocol=TCP -h "$MASTER_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" --single-transaction "$DB_NAME" \
| tee "$DUMP_FILE" >/dev/null 2>>"$LOG"; then | tee "$DUMP_FILE" >/dev/null 2>>"$LOG"; then
echo "Dump FAILED; aborting this cycle" | tee -a "$LOG"; sleep 120; continue echo "Dump FAILED; aborting this cycle" | tee -a "$LOG"; sleep 120; continue
fi fi

View File

@@ -239,5 +239,13 @@ data:
innodb_log_file_size=32M innodb_log_file_size=32M
table_open_cache=4000 table_open_cache=4000
expire_logs_days=7 expire_logs_days=7
# master slave
server_id=1 # Unique server ID for the master
log_bin=mysql-bin # Enable binary logging
binlog_format=ROW # Recommended format for replication (ROW, STATEMENT, or MIXED)
log_slave_updates=ON # Ensure any changes replicated to the master are also logged to the binary log (useful for multi-source replication)
sync_binlog=1 # Ensures binary logs are synchronized with disk after each transaction for data safety
expire_logs_days=7 # Optional: Number of days to retain binary logs (helps with cleanup)
# /etc/mysql/mariadb.conf.d/70-mysettings.cnf # /etc/mysql/mariadb.conf.d/70-mysettings.cnf

View File

@@ -1,42 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: wrestlingdev-memcached
labels:
app: wrestlingdev
spec:
ports:
- port: 11211
selector:
app: wrestlingdev
tier: memcached
clusterIP: None
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: wrestlingdev-memcached-deployment
labels:
app: wrestlingdev
spec:
replicas: 1
selector:
matchLabels:
app: wrestlingdev
template:
metadata:
labels:
app: wrestlingdev
tier: memcached
spec:
containers:
- name: wrestlingdev-memcached
image: memcached
ports:
- containerPort: 11211
resources:
limits:
memory: "64Mi"
# requests:
# memory: "64Mi"
# cpu: "0.1"

View File

@@ -122,25 +122,27 @@ spec:
initialDelaySeconds: 180 initialDelaySeconds: 180
periodSeconds: 20 periodSeconds: 20
timeoutSeconds: 10 timeoutSeconds: 10
# --- ---
# apiVersion: autoscaling/v2beta1 apiVersion: autoscaling/v2beta1
# kind: HorizontalPodAutoscaler kind: HorizontalPodAutoscaler
# metadata: metadata:
# name: wrestlingdev-app-deployment-autoscale name: wrestlingdev-app-autoscale
# spec: spec:
# scaleTargetRef: scaleTargetRef:
# apiVersion: apps/v1 apiVersion: apps/v1
# kind: Deployment kind: StatefulSet
# name: wrestlingdev-app-deployment name: wrestlingdev-app
# minReplicas: 2 minReplicas: 2
# maxReplicas: 5 maxReplicas: 5
# metrics: metrics:
# - type: Resource - type: Resource
# resource: resource:
# name: cpu name: cpu
# targetAverageUtilization: 75 targetAverageUtilization: 75
# - type: Resource - type: Resource
# resource: resource:
# name: memory name: memory
# targetAverageValue: 100Mi target:
type: Utilization
averageUtilization: 80