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:
@@ -122,12 +122,12 @@ spec:
|
||||
DUMP_FILE="/tmp/${DB_NAME}_backup.sql"
|
||||
echo "Dumping ${DB_NAME} from master ${MASTER_SERVICE_HOST}" | tee -a "$LOG"
|
||||
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
|
||||
echo "Dump FAILED; aborting this cycle" | tee -a "$LOG"; sleep 120; continue
|
||||
fi
|
||||
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
|
||||
echo "Dump FAILED; aborting this cycle" | tee -a "$LOG"; sleep 120; continue
|
||||
fi
|
||||
|
||||
@@ -240,4 +240,12 @@ data:
|
||||
table_open_cache=4000
|
||||
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
|
||||
|
||||
@@ -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"
|
||||
@@ -122,25 +122,27 @@ spec:
|
||||
initialDelaySeconds: 180
|
||||
periodSeconds: 20
|
||||
timeoutSeconds: 10
|
||||
# ---
|
||||
# apiVersion: autoscaling/v2beta1
|
||||
# kind: HorizontalPodAutoscaler
|
||||
# metadata:
|
||||
# name: wrestlingdev-app-deployment-autoscale
|
||||
# spec:
|
||||
# scaleTargetRef:
|
||||
# apiVersion: apps/v1
|
||||
# kind: Deployment
|
||||
# name: wrestlingdev-app-deployment
|
||||
# minReplicas: 2
|
||||
# maxReplicas: 5
|
||||
# metrics:
|
||||
# - type: Resource
|
||||
# resource:
|
||||
# name: cpu
|
||||
# targetAverageUtilization: 75
|
||||
# - type: Resource
|
||||
# resource:
|
||||
# name: memory
|
||||
# targetAverageValue: 100Mi
|
||||
---
|
||||
apiVersion: autoscaling/v2beta1
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: wrestlingdev-app-autoscale
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
name: wrestlingdev-app
|
||||
minReplicas: 2
|
||||
maxReplicas: 5
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
targetAverageUtilization: 75
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
|
||||
|
||||
Reference in New Issue
Block a user