-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
k8s: Fix potential edge case where a second cluster could get started
* Add an init container that checks for whether any other peers exist * Re-enable the tolerate-unready-endpoints option. It's bprashanth's recommendation, and makes the init container less likely to miss anything. * Switch from joining `cockroachdb` to joining `cockroachdb-public`. This is needed due to re-enabling `tolerate-undready-endpoints`. I wish we could just directly re-use the peer-finder container without having to wrap it, but I already burned too much time trying to get it to accepts non-trivial commands in its `--on-start` parameter. Almost everything I tried would just get treated to a "No such file or directory" error.
- Loading branch information
1 parent
27a643c
commit 064401e
Showing
5 changed files
with
121 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM gcr.io/google_containers/peer-finder:0.1 | ||
|
||
ADD on-start.sh / | ||
RUN chmod -c 755 /on-start.sh | ||
|
||
ENTRYPOINT ["/peer-finder"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Overview | ||
|
||
The Dockerfile in this directory defines a lightweight wrapper around the | ||
[Kubernetes-maintained "peer-finder" | ||
image](https://github.com/kubernetes/contrib/tree/master/pets/peer-finder), | ||
which finds whether any other instances from the same PetSet currently exist in | ||
the cluster. | ||
|
||
The `on-start.sh` script in this directory is invoked by the peer-finder binary | ||
with a newline separated list of the DNS results matching the provided | ||
Kubernetes service name and namespace. | ||
|
||
We use this to try to help the first CockroachDB instance decide whether it | ||
should try to join an existing cluster or initialize a new one. We have to be | ||
very careful about initializing a new one, since doing so when one alread | ||
exists can cause some real problems. | ||
|
||
# Pushing a new version | ||
|
||
Assuming you're logged in to a Docker Hub account that can push to the | ||
cockroachdb organization, [check the latest tag of the | ||
cockroachdb/cockroach-k8s-init | ||
container](https://hub.docker.com/r/cockroachdb/cockroach-k8s-init/tags/) so | ||
that you know what tag number to use next, then cd to this directory and run: | ||
|
||
```shell | ||
NEW_TAG=0.0 # replace 0.0 with the next appropriate tag number | ||
docker build -t "cockroachdb/cockroach-k8s-init:${NEW_TAG}" . | ||
docker push "cockroachdb/cockroach-k8s-init:${NEW_TAG}" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# Simply determine if any instances exist other than this one. If there are any | ||
# others, then assume that a cluster already exists and create a marker to | ||
# signal that we shouldn't create a new one. | ||
if grep -v `hostname -f`; then | ||
mkdir -p cockroach/cockroach-data && touch cockroach/cockroach-data/cluster_exists_marker | ||
fi |