Created
April 13, 2021 15:53
-
-
Save rdemoraes/8508712bc3fa4e15d02e87ca73a3fbdc to your computer and use it in GitHub Desktop.
Configmap for cassandra
This file contains hidden or 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
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: cassandra-rings | |
namespace: cassandra | |
data: | |
CASSANDRA_0_INITIAL_TOKEN: <token_number>, <token_number>,... | |
CASSANDRA_1_INITIAL_TOKEN: <token_number>, <token_number>,... | |
CASSANDRA_2_INITIAL_TOKEN: <token_number>, <token_number>,... | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: docker-entrypoint-sh | |
namespace: cassandra | |
data: | |
docker-entrypoint.sh: | | |
#!/bin/bash | |
set -e# first arg is `-f` or `--some-option` | |
if [ "${1:0:1}" = '-' ]; then | |
set -- cassandra -f "$@" | |
fi# allow the container to be started with `--user` | |
if [ "$1" = 'cassandra' -a "$(id -u)" = '0' ]; then | |
chown -R cassandra /var/lib/cassandra /var/log/cassandra "$CASSANDRA_CONFIG" | |
exec gosu cassandra "$BASH_SOURCE" "$@" | |
fiif [ "$1" = 'cassandra' ]; then | |
: ${CASSANDRA_RPC_ADDRESS='0.0.0.0'}: ${CASSANDRA_LISTEN_ADDRESS='auto'} | |
if [ "$CASSANDRA_LISTEN_ADDRESS" = 'auto' ]; then | |
CASSANDRA_LISTEN_ADDRESS="$(hostname --ip-address)" | |
fi: ${CASSANDRA_BROADCAST_ADDRESS="$CASSANDRA_LISTEN_ADDRESS"}if [ "$CASSANDRA_BROADCAST_ADDRESS" = 'auto' ]; then | |
CASSANDRA_BROADCAST_ADDRESS="$(hostname --ip-address)" | |
fi | |
: ${CASSANDRA_BROADCAST_RPC_ADDRESS:=$CASSANDRA_BROADCAST_ADDRESS}if [ -n "${CASSANDRA_NAME:+1}" ]; then | |
: ${CASSANDRA_SEEDS:="cassandra"} | |
fi: ${CASSANDRA_SEEDS:="$CASSANDRA_BROADCAST_ADDRESS"} | |
sed -ri 's/(- seeds:).*/\1 "'"$CASSANDRA_SEEDS"'"/' "$CASSANDRA_CONFIG/cassandra.yaml"if [ "${HOSTNAME}" == 'cassandra-0' ];then | |
: ${CASSANDRA_INITIAL_TOKEN="$CASSANDRA_0_INITIAL_TOKEN"} | |
elif [ "${HOSTNAME}" == 'cassandra-1' ];then | |
: ${CASSANDRA_INITIAL_TOKEN="$CASSANDRA_1_INITIAL_TOKEN"} | |
elif [ "${HOSTNAME}" == 'cassandra-2' ];then | |
: ${CASSANDRA_INITIAL_TOKEN="$CASSANDRA_2_INITIAL_TOKEN"} | |
fi | |
sed -ri "s/\# initial_token\:/initial_token\: $CASSANDRA_INITIAL_TOKEN/" "$CASSANDRA_CONFIG/cassandra.yaml"for yaml in \ | |
broadcast_address \ | |
broadcast_rpc_address \ | |
cluster_name \ | |
endpoint_snitch \ | |
listen_address \ | |
num_tokens \ | |
initial_token \ | |
rpc_address \ | |
start_rpc \ | |
; do | |
var="CASSANDRA_${yaml^^}" | |
val="${!var}" | |
if [ "$val" ]; then | |
sed -ri 's/^(# )?('"$yaml"':).*/\2 '"$val"'/' "$CASSANDRA_CONFIG/cassandra.yaml" | |
fi | |
donefor rackdc in dc rack; do | |
var="CASSANDRA_${rackdc^^}" | |
val="${!var}" | |
if [ "$val" ]; then | |
sed -ri 's/^('"$rackdc"'=).*/\1 '"$val"'/' "$CASSANDRA_CONFIG/cassandra-rackdc.properties" | |
fi | |
done | |
fiexec "$@" | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: readiness-probe-sh | |
namespace: cassandra | |
data: | |
ready-probe.sh: | | |
#!/bin/bash | |
# Copyright 2016 The Kubernetes Authors. | |
# | |
# 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. | |
if [[ $(nodetool status | grep $POD_IP) == *"UN"* ]]; then | |
if [[ $DEBUG ]]; then | |
echo "UN"; | |
fi | |
exit 0; | |
else | |
if [[ $DEBUG ]]; then | |
echo "Not Up"; | |
fi | |
exit 1; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment