-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 #9972 from smarterclayton/petset
Merged by openshift-bot
- Loading branch information
Showing
73 changed files
with
2,868 additions
and
135 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
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
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,10 @@ | ||
# PetSet examples | ||
|
||
These examples are tracked from the [Kubernetes contrib project @d6e4be](https://github.com/kubernetes/contrib/tree/d6e4be066cc076fbb91ff69691819e117711b30b/pets) | ||
|
||
Note that some of these examples require the ability to run root containers which may not be possible for all users in all environments. To grant | ||
access to run containers as root to a service account in your project, run: | ||
|
||
oadm policy add-scc-to-user anyuid -z default | ||
|
||
which allows the `default` service account to run root containers. |
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,33 @@ | ||
# Mysql Galera | ||
|
||
This example runs mysql galera through a petset. | ||
|
||
## Bootstrap | ||
|
||
Create the petset in this directory | ||
``` | ||
$ kubectl create -f galera.yaml | ||
``` | ||
|
||
Once you have all 3 nodes in Running, you can run the "test.sh" script in this directory. | ||
This example requires manual intervention. | ||
Once you have all 3 nodes in Running, you can run the "test.sh" script in this directory. | ||
|
||
## Caveats | ||
|
||
Starting up all galera nodes at once leads to an issue where all the mysqls | ||
belive they're in the primary component because they don't see the others in | ||
the DNS. For the bootstrapping to work: mysql-0 needs to see itself, mysql-1 | ||
needs to see itself and mysql-0, and so on, because the first node that sees | ||
a peer list of 1 will assume it's the leader. | ||
|
||
## TODO | ||
|
||
Expect better solutions for the following as petset matures. | ||
|
||
* Failover | ||
* Scaling Up | ||
* Scaling Down | ||
* Image Upgrade | ||
* Maintenance | ||
|
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,29 @@ | ||
# Copyright 2016 The Kubernetes Authors All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# TODO: get rid of bash dependency and switch to plain busybox. | ||
# The tar in busybox also doesn't seem to understand compression. | ||
FROM debian:jessie | ||
MAINTAINER Prashanth.B <[email protected]> | ||
|
||
RUN apt-get update && apt-get install -y wget | ||
|
||
ADD on-start.sh / | ||
ADD my-galera.cnf / | ||
# See contrib/pets/peer-finder for details | ||
RUN wget -qO /peer-finder https://storage.googleapis.com/kubernetes-release/pets/peer-finder | ||
|
||
ADD install.sh / | ||
RUN chmod -c 755 /install.sh /on-start.sh /peer-finder | ||
Entrypoint ["/install.sh"] |
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,27 @@ | ||
# Copyright 2016 The Kubernetes Authors All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
all: push | ||
|
||
TAG = 0.1 | ||
PREFIX = gcr.io/google_containers/galera-install | ||
|
||
container: | ||
docker build -t $(PREFIX):$(TAG) . | ||
|
||
push: container | ||
gcloud docker push $(PREFIX):$(TAG) | ||
|
||
clean: | ||
docker rmi $(PREFIX):$(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,50 @@ | ||
#! /bin/bash | ||
|
||
# Copyright 2016 The Kubernetes Authors All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# This volume is assumed to exist and is shared with parent of the init | ||
# container. It contains the mysq config. | ||
CONFIG_VOLUME="/etc/mysql" | ||
|
||
# This volume is assumed to exist and is shared with the peer-finder | ||
# init container. It contains on-start/change configuration scripts. | ||
WORKDIR_VOLUME="/work-dir" | ||
|
||
for i in "$@" | ||
do | ||
case $i in | ||
-c=*|--config=*) | ||
CONFIG_VOLUME="${i#*=}" | ||
shift | ||
;; | ||
-w=*|--work-dir=*) | ||
WORKDIR_VOLUME="${i#*=}" | ||
shift | ||
;; | ||
*) | ||
# unknown option | ||
;; | ||
esac | ||
done | ||
|
||
echo installing config scripts into "${WORKDIR_VOLUME}" | ||
mkdir -p "${WORKDIR_VOLUME}" | ||
cp /on-start.sh "${WORKDIR_VOLUME}"/ | ||
cp /peer-finder "${WORKDIR_VOLUME}"/ | ||
|
||
echo installing my-galera.cnf into "${CONFIG_VOLUME}" | ||
mkdir -p "${CONFIG_VOLUME}" | ||
chown -R mysql:mysql "${CONFIG_VOLUME}" | ||
cp /my-galera.cnf "${CONFIG_VOLUME}"/ |
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,22 @@ | ||
[mysqld] | ||
user = mysql | ||
bind-address = 0.0.0.0 | ||
wsrep_provider = /usr/lib/galera/libgalera_smm.so | ||
# TODO: is rsync the best option? | ||
wsrep_sst_method = rsync | ||
default_storage_engine = innodb | ||
binlog_format = row | ||
innodb_autoinc_lock_mode = 2 | ||
innodb_flush_log_at_trx_commit = 0 | ||
query_cache_size = 0 | ||
query_cache_type = 0 | ||
|
||
# By default every node is standalone | ||
wsrep_cluster_address=gcomm:// | ||
wsrep_cluster_name=galera | ||
wsrep_node_address=127.0.0.1 | ||
|
||
# TODO: Enable use privileges. This doesn't work | ||
# on mysql restart, for some reason after the SST | ||
# permissions are not setup correctly. | ||
skip-grant-tables |
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,52 @@ | ||
#! /bin/bash | ||
|
||
# Copyright 2016 The Kubernetes Authors All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# This script writes out a mysql galera config using a list of newline seperated | ||
# peer DNS names it accepts through stdin. | ||
|
||
# /etc/mysql is assumed to be a shared volume so we can modify my.cnf as required | ||
# to keep the config up to date, without wrapping mysqld in a custom pid1. | ||
# The config location is intentionally not /etc/mysql/my.cnf because the | ||
# standard base image clobbers that location. | ||
CFG=/etc/mysql/my-galera.cnf | ||
|
||
function join { | ||
local IFS="$1"; shift; echo "$*"; | ||
} | ||
|
||
HOSTNAME=$(hostname) | ||
# Parse out cluster name, formatted as: petset_name-index | ||
IFS='-' read -ra ADDR <<< "$(hostname)" | ||
CLUSTER_NAME="${ADDR[0]}" | ||
|
||
while read -ra LINE; do | ||
if [[ "${LINE}" == *"${HOSTNAME}"* ]]; then | ||
MY_NAME=$LINE | ||
fi | ||
PEERS=("${PEERS[@]}" $LINE) | ||
done | ||
|
||
if [ "${#PEERS[@]}" = 1 ]; then | ||
WSREP_CLUSTER_ADDRESS="" | ||
else | ||
WSREP_CLUSTER_ADDRESS=$(join , "${PEERS[@]}") | ||
fi | ||
sed -i -e "s|^wsrep_node_address=.*$|wsrep_node_address=${MY_NAME}|" ${CFG} | ||
sed -i -e "s|^wsrep_cluster_name=.*$|wsrep_cluster_name=${CLUSTER_NAME}|" ${CFG} | ||
sed -i -e "s|^wsrep_cluster_address=.*$|wsrep_cluster_address=gcomm://${WSREP_CLUSTER_ADDRESS}|" ${CFG} | ||
|
||
# don't need a restart, we're just writing the conf in case there's an | ||
# unexpected restart on the node. |
Oops, something went wrong.