Multi-site High-availability Manual Failover (PoC)
[oom.git] / kubernetes / common / mysql / templates / statefulset.yaml
index 7b55bf2..e3f3428 100644 (file)
@@ -45,10 +45,11 @@ spec:
           # Generate mysql server-id from pod ordinal index.
           [[ `hostname` =~ -([0-9]+)$ ]] || exit 1
           ordinal=${BASH_REMATCH[1]}
+          siteId={{ .Values.geoSiteId }}
           echo BASH_REMATCH=${BASH_REMATCH}
           echo [mysqld] > /mnt/conf.d/server-id.cnf
           # Add an offset to avoid reserved server-id=0 value.
-          echo server-id=$((100 + $ordinal)) >> /mnt/conf.d/server-id.cnf
+          echo server-id=$(($siteId*100 + $ordinal)) >> /mnt/conf.d/server-id.cnf
           # Copy appropriate conf.d files from config-map to emptyDir.
           if [[ $ordinal -eq 0 ]]; then
             cp /mnt/config-map/master.cnf /mnt/conf.d/
@@ -93,7 +94,7 @@ spec:
           subPath: mysql
         - name: conf
           mountPath: /etc/mysql/conf.d
-          
+
       containers:
         #sdnc-db-container
         - name: {{ include "common.name" . }}
@@ -236,3 +237,4 @@ spec:
 #{{ else }}
         emptyDir: {}
 #{{ end }}
+