-
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.
Merge pull request #10268 from a-robinson/initcon
k8s: Fix potential edge case where a second cluster could get started
- Loading branch information
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 |