Skip to content

Commit

Permalink
Fixes the most apparent flaw that triggers #31 split brain
Browse files Browse the repository at this point in the history
  • Loading branch information
solsson committed Jun 4, 2020
1 parent fabc7e8 commit c3353a9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 10conf-d.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ data:
set -x
fi
}
else
getent hosts mariadb-ready
[ $? -eq 2 ] && {
echo "This is NOT the 1st statefulset pod. Must not go up as primary."
echo "Found no ready pods. Will exit to trigger a crash loop back off."
exit 1
}
fi
# https://github.com/docker-library/mariadb/blob/master/10.2/docker-entrypoint.sh#L62
Expand Down
14 changes: 14 additions & 0 deletions 21mariadb-ready-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Used with `getent hosts` to check how many pods that are ready
---
apiVersion: v1
kind: Service
metadata:
name: mariadb-ready
namespace: mysql
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "false"
spec:
publishNotReadyAddresses: false
clusterIP: None
selector:
app: mariadb
1 change: 1 addition & 0 deletions kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
resources:
- 10conf-d.yml
- 20mariadb-service.yml
- 21mariadb-ready-service.yml
- 30mysql-service.yml
- 50mariadb.yml

0 comments on commit c3353a9

Please sign in to comment.