vendor files

This commit is contained in:
Serguei Bezverkhi
2018-01-09 13:57:14 -05:00
parent 558bc6c02a
commit 7b24313bd6
16547 changed files with 4527373 additions and 0 deletions

View File

@ -0,0 +1 @@
This file has moved to [https://github.com/kubernetes/examples/blob/master/staging/storage/vitess/README.md](https://github.com/kubernetes/examples/blob/master/staging/storage/vitess/README.md)

View File

@ -0,0 +1,73 @@
#!/bin/bash
# Copyright 2015 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.
# This script generates config.sh, which is a site-local config file that is not
# checked into source control.
# Select and configure Backup Storage Implementation.
storage=gcs
read -p "Backup Storage (file, gcs) [gcs]: "
if [ -n "$REPLY" ]; then storage="$REPLY"; fi
case "$storage" in
gcs)
# Google Cloud Storage
project=$(gcloud config list project | grep 'project\s*=' | sed -r 's/^.*=\s*(.*)$/\1/')
read -p "Google Developers Console Project [$project]: "
if [ -n "$REPLY" ]; then project="$REPLY"; fi
if [ -z "$project" ]; then
echo "ERROR: Project name must not be empty."
exit 1
fi
read -p "Google Cloud Storage bucket for Vitess backups: " bucket
if [ -z "$bucket" ]; then
echo "ERROR: Bucket name must not be empty."
exit 1
fi
echo
echo "NOTE: If you haven't already created this bucket, you can do so by running:"
echo " gsutil mb gs://$bucket"
echo
backup_flags=$(echo -backup_storage_implementation gcs \
-gcs_backup_storage_project "'$project'" \
-gcs_backup_storage_bucket "'$bucket'")
;;
file)
# Mounted volume (e.g. NFS)
read -p "Root directory for backups (usually an NFS mount): " file_root
if [ -z "$file_root" ]; then
echo "ERROR: Root directory must not be empty."
exit 1
fi
echo
echo "NOTE: You must add your NFS mount to the vtctld-controller-template"
echo " and vttablet-pod-template as described in the Kubernetes docs:"
echo " http://kubernetes.io/v1.0/docs/user-guide/volumes.html#nfs"
echo
backup_flags=$(echo -backup_storage_implementation file \
-file_backup_storage_root "'$file_root'")
;;
*)
echo "ERROR: Unsupported backup storage implementation: $storage"
exit 1
esac
echo "Saving config.sh..."
echo "backup_flags=\"$backup_flags\"" > config.sh

View File

@ -0,0 +1,8 @@
CREATE TABLE messages (
page BIGINT(20) UNSIGNED,
time_created_ns BIGINT(20) UNSIGNED,
keyspace_id BIGINT(20) UNSIGNED,
message VARCHAR(10000),
PRIMARY KEY (page, time_created_ns)
) ENGINE=InnoDB

View File

@ -0,0 +1,63 @@
# Copyright 2015 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.
# This is an include file used by the other scripts in this directory.
# Most clusters will just be accessed with 'kubectl' on $PATH.
# However, some might require a different command. For example, GKE required
# KUBECTL='gcloud beta container kubectl' for a while. Now that most of our
# use cases just need KUBECTL=kubectl, we'll make that the default.
KUBECTL=${KUBECTL:-kubectl}
# This should match the nodePort in vtctld-service.yaml
VTCTLD_PORT=${VTCTLD_PORT:-30001}
# Customizable parameters
SHARDS=${SHARDS:-'-80,80-'}
TABLETS_PER_SHARD=${TABLETS_PER_SHARD:-2}
RDONLY_COUNT=${RDONLY_COUNT:-0}
MAX_TASK_WAIT_RETRIES=${MAX_TASK_WAIT_RETRIES:-300}
MAX_VTTABLET_TOPO_WAIT_RETRIES=${MAX_VTTABLET_TOPO_WAIT_RETRIES:-180}
VTTABLET_TEMPLATE=${VTTABLET_TEMPLATE:-'vttablet-pod-template.yaml'}
VTGATE_TEMPLATE=${VTGATE_TEMPLATE:-'vtgate-controller-template.yaml'}
VTGATE_COUNT=${VTGATE_COUNT:-1}
CELLS=${CELLS:-'test'}
ETCD_REPLICAS=3
VTGATE_REPLICAS=$VTGATE_COUNT
# Get the ExternalIP of any node.
get_node_ip() {
$KUBECTL get -o template -t '{{range (index .items 0).status.addresses}}{{if eq .type "ExternalIP"}}{{.address}}{{end}}{{end}}' nodes
}
# Try to find vtctld address if not provided.
get_vtctld_addr() {
if [ -z "$VTCTLD_ADDR" ]; then
node_ip=$(get_node_ip)
if [ -n "$node_ip" ]; then
VTCTLD_ADDR="$node_ip:$VTCTLD_PORT"
fi
fi
echo "$VTCTLD_ADDR"
}
config_file=`dirname "${BASH_SOURCE}"`/config.sh
if [ ! -f $config_file ]; then
echo "Please run ./configure.sh first to generate config.sh file."
exit 1
fi
source $config_file

View File

@ -0,0 +1,54 @@
apiVersion: v1
kind: ReplicationController
metadata:
name: etcd-{{cell}}
spec:
replicas: {{replicas}}
template:
metadata:
labels:
component: etcd
cell: {{cell}}
app: vitess
spec:
volumes:
- name: certs
hostPath: {path: /etc/ssl/certs}
containers:
- name: etcd
image: vitess/etcd:v2.0.13-lite
volumeMounts:
- name: certs
readOnly: true
mountPath: /etc/ssl/certs
resources:
limits:
memory: "128Mi"
cpu: "100m"
command:
- bash
- "-c"
- >-
ipaddr=$(hostname -i)
global_etcd=$ETCD_GLOBAL_SERVICE_HOST:$ETCD_GLOBAL_SERVICE_PORT
cell="{{cell}}" &&
local_etcd_host_var="ETCD_${cell^^}_SERVICE_HOST" &&
local_etcd_port_var="ETCD_${cell^^}_SERVICE_PORT" &&
local_etcd=${!local_etcd_host_var}:${!local_etcd_port_var}
if [ "{{cell}}" != "global" ]; then
until etcdctl -C "http://$global_etcd"
set "/vt/cells/{{cell}}" "http://$local_etcd"; do
echo "[$(date)] waiting for global etcd to register cell '{{cell}}'";
sleep 1;
done;
fi
etcd -name $HOSTNAME -discovery {{discovery}}
-advertise-client-urls http://$ipaddr:4001
-initial-advertise-peer-urls http://$ipaddr:7001
-listen-client-urls http://$ipaddr:4001
-listen-peer-urls http://$ipaddr:7001

View File

@ -0,0 +1,36 @@
#!/bin/bash
# Copyright 2015 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.
# This is an example script that tears down the etcd servers started by
# etcd-up.sh.
set -e
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
CELLS=${CELLS:-'test'}
cells=`echo $CELLS | tr ',' ' '`
# Delete replication controllers
for cell in 'global' $cells; do
echo "Deleting etcd replicationcontroller for $cell cell..."
$KUBECTL delete replicationcontroller etcd-$cell
echo "Deleting etcd service for $cell cell..."
$KUBECTL delete service etcd-$cell
done

View File

@ -0,0 +1,16 @@
kind: Service
apiVersion: v1
metadata:
name: etcd-{{cell}}
labels:
component: etcd
cell: {{cell}}
app: vitess
spec:
ports:
- port: 4001
selector:
component: etcd
cell: {{cell}}
app: vitess

60
vendor/k8s.io/kubernetes/examples/storage/vitess/etcd-up.sh generated vendored Executable file
View File

@ -0,0 +1,60 @@
#!/bin/bash
# Copyright 2015 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.
# This is an example script that creates etcd clusters.
# Vitess requires a global cluster, as well as one for each cell.
#
# For automatic discovery, an etcd cluster can be bootstrapped from an
# existing cluster. In this example, we use an externally-run discovery
# service, but you can use your own. See the etcd docs for more:
# https://github.com/coreos/etcd/blob/v2.0.13/Documentation/clustering.md
set -e
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
replicas=${ETCD_REPLICAS:-3}
CELLS=${CELLS:-'test'}
cells=`echo $CELLS | tr ',' ' '`
for cell in 'global' $cells; do
# Generate a discovery token.
echo "Generating discovery token for $cell cell..."
discovery=$(curl -sL https://discovery.etcd.io/new?size=$replicas)
if [ -z "$discovery" ]; then
echo "Failed to get etcd discovery token for cell '$cell'."
exit 1
fi
# Create the client service, which will load-balance across all replicas.
echo "Creating etcd service for $cell cell..."
cat etcd-service-template.yaml | \
sed -e "s/{{cell}}/$cell/g" | \
$KUBECTL create -f -
# Expand template variables
sed_script=""
for var in cell discovery replicas; do
sed_script+="s,{{$var}},${!var},g;"
done
# Create the replication controller.
echo "Creating etcd replicationcontroller for $cell cell..."
cat etcd-controller-template.yaml | sed -e "$sed_script" | $KUBECTL create -f -
done

View File

@ -0,0 +1,23 @@
kind: ReplicationController
apiVersion: v1
metadata:
name: guestbook
spec:
replicas: 3
template:
metadata:
labels:
component: guestbook
app: vitess
spec:
containers:
- name: guestbook
image: vitess/guestbook:v2.0.0-alpha5
ports:
- name: http-server
containerPort: 8080
resources:
limits:
memory: "128Mi"
cpu: "100m"

View File

@ -0,0 +1,28 @@
#!/bin/bash
# Copyright 2015 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.
# This is an example script that stops guestbook.
set -e
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
echo "Deleting guestbook replicationcontroller..."
$KUBECTL delete replicationcontroller guestbook
echo "Deleting guestbook service..."
$KUBECTL delete service guestbook

View File

@ -0,0 +1,16 @@
kind: Service
apiVersion: v1
metadata:
name: guestbook
labels:
component: guestbook
app: vitess
spec:
ports:
- port: 80
targetPort: http-server
selector:
component: guestbook
app: vitess
type: LoadBalancer

View File

@ -0,0 +1,28 @@
#!/bin/bash
# Copyright 2015 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.
# This is an example script that starts a guestbook replicationcontroller.
set -e
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
echo "Creating guestbook service..."
$KUBECTL create -f guestbook-service.yaml
echo "Creating guestbook replicationcontroller..."
$KUBECTL create -f guestbook-controller.yaml

View File

@ -0,0 +1,23 @@
#!/bin/bash
# Copyright 2015 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.
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
./vtgate-down.sh
SHARDS=$SHARDS CELLS=$CELLS TABLETS_PER_SHARD=$TABLETS_PER_SHARD ./vttablet-down.sh
./vtctld-down.sh
./etcd-down.sh

165
vendor/k8s.io/kubernetes/examples/storage/vitess/vitess-up.sh generated vendored Executable file
View File

@ -0,0 +1,165 @@
#!/bin/bash
# Copyright 2015 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.
# This is an example script that creates a fully functional vitess cluster.
# It performs the following steps:
# - Create etcd clusters
# - Create vtctld pod
# - Create vttablet pods
# - Perform vtctl initialization:
# SetKeyspaceShardingInfo, Rebuild Keyspace, Reparent Shard, Apply Schema
# - Create vtgate pods
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
cells=`echo $CELLS | tr ',' ' '`
num_cells=`echo $cells | wc -w`
function update_spinner_value () {
spinner='-\|/'
cur_spinner=${spinner:$(($1%${#spinner})):1}
}
function wait_for_running_tasks () {
# This function waits for pods to be in the "Running" state
# 1. task_name: Name that the desired task begins with
# 2. num_tasks: Number of tasks to wait for
# Returns:
# 0 if successful, -1 if timed out
task_name=$1
num_tasks=$2
counter=0
echo "Waiting for ${num_tasks}x $task_name to enter state Running"
while [ $counter -lt $MAX_TASK_WAIT_RETRIES ]; do
# Get status column of pods with name starting with $task_name,
# count how many are in state Running
num_running=`$KUBECTL get pods | grep ^$task_name | grep Running | wc -l`
echo -en "\r$task_name: $num_running out of $num_tasks in state Running..."
if [ $num_running -eq $num_tasks ]
then
echo Complete
return 0
fi
update_spinner_value $counter
echo -n $cur_spinner
let counter=counter+1
sleep 1
done
echo Timed out
return -1
}
if [ -z "$GOPATH" ]; then
echo "ERROR: GOPATH undefined, can't obtain vtctlclient"
exit -1
fi
export KUBECTL='kubectl'
echo "Downloading and installing vtctlclient..."
go get -u github.com/youtube/vitess/go/cmd/vtctlclient
num_shards=`echo $SHARDS | tr "," " " | wc -w`
total_tablet_count=$(($num_shards*$TABLETS_PER_SHARD*$num_cells))
vtgate_count=$VTGATE_COUNT
if [ $vtgate_count -eq 0 ]; then
vtgate_count=$(($total_tablet_count/4>3?$total_tablet_count/4:3))
fi
echo "****************************"
echo "*Creating vitess cluster:"
echo "* Shards: $SHARDS"
echo "* Tablets per shard: $TABLETS_PER_SHARD"
echo "* Rdonly per shard: $RDONLY_COUNT"
echo "* VTGate count: $vtgate_count"
echo "* Cells: $cells"
echo "****************************"
echo 'Running etcd-up.sh' && CELLS=$CELLS ./etcd-up.sh
wait_for_running_tasks etcd-global 3
for cell in $cells; do
wait_for_running_tasks etcd-$cell 3
done
echo 'Running vtctld-up.sh' && ./vtctld-up.sh
echo 'Running vttablet-up.sh' && CELLS=$CELLS ./vttablet-up.sh
echo 'Running vtgate-up.sh' && ./vtgate-up.sh
wait_for_running_tasks vtctld 1
wait_for_running_tasks vttablet $total_tablet_count
wait_for_running_tasks vtgate $vtgate_count
vtctld_port=30001
vtctld_ip=`kubectl get -o yaml nodes | grep 'type: ExternalIP' -B 1 | head -1 | awk '{print $NF}'`
vtctl_server="$vtctld_ip:$vtctld_port"
kvtctl="$GOPATH/bin/vtctlclient -server $vtctl_server"
echo Waiting for tablets to be visible in the topology
counter=0
while [ $counter -lt $MAX_VTTABLET_TOPO_WAIT_RETRIES ]; do
num_tablets=0
for cell in $cells; do
num_tablets=$(($num_tablets+`$kvtctl ListAllTablets $cell | wc -l`))
done
echo -en "\r$num_tablets out of $total_tablet_count in topology..."
if [ $num_tablets -eq $total_tablet_count ]
then
echo Complete
break
fi
update_spinner_value $counter
echo -n $cur_spinner
let counter=counter+1
sleep 1
if [ $counter -eq $MAX_VTTABLET_TOPO_WAIT_RETRIES ]
then
echo Timed out
fi
done
# split_shard_count = num_shards for sharded keyspace, 0 for unsharded
split_shard_count=$num_shards
if [ $split_shard_count -eq 1 ]; then
split_shard_count=0
fi
echo -n Setting Keyspace Sharding Info...
$kvtctl SetKeyspaceShardingInfo -force -split_shard_count $split_shard_count test_keyspace keyspace_id uint64
echo Done
echo -n Rebuilding Keyspace Graph...
$kvtctl RebuildKeyspaceGraph test_keyspace
echo Done
echo -n Reparenting...
shard_num=1
for shard in $(echo $SHARDS | tr "," " "); do
$kvtctl InitShardMaster -force test_keyspace/$shard `echo $cells | awk '{print $1}'`-0000000${shard_num}00
let shard_num=shard_num+1
done
echo Done
echo -n Applying Schema...
$kvtctl ApplySchema -sql "$(cat create_test_table.sql)" test_keyspace
echo Done
echo "****************************"
echo "* Complete!"
echo "* Use the following line to make an alias to kvtctl:"
echo "* alias kvtctl='\$GOPATH/bin/vtctlclient -server $vtctl_server'"
echo "* See the vtctld UI at: http://${vtctld_ip}:30000"
echo "****************************"

View File

@ -0,0 +1,55 @@
kind: ReplicationController
apiVersion: v1
metadata:
name: vtctld
spec:
replicas: 1
template:
metadata:
labels:
component: vtctld
app: vitess
spec:
containers:
- name: vtctld
image: vitess/lite:v2.0.0-alpha5
volumeMounts:
- name: syslog
mountPath: /dev/log
- name: vtdataroot
mountPath: /vt/vtdataroot
- name: certs
readOnly: true
mountPath: /etc/ssl/certs
resources:
limits:
memory: "128Mi"
cpu: "100m"
command:
- sh
- "-c"
- >-
mkdir -p $VTDATAROOT/tmp &&
chown -R vitess /vt &&
su -p -c "/vt/bin/vtctld
-debug
-templates $VTTOP/go/cmd/vtctld/templates
-web_dir $VTTOP/web/vtctld
-log_dir $VTDATAROOT/tmp
-alsologtostderr
-port 15000
-grpc_port 15001
-service_map 'grpc-vtctl'
-topo_implementation etcd
-tablet_protocol grpc
-tablet_manager_protocol grpc
-etcd_global_addrs http://$ETCD_GLOBAL_SERVICE_HOST:$ETCD_GLOBAL_SERVICE_PORT
{{backup_flags}}" vitess
volumes:
- name: syslog
hostPath: {path: /dev/log}
- name: vtdataroot
emptyDir: {}
- name: certs
hostPath: {path: /etc/ssl/certs}

View File

@ -0,0 +1,28 @@
#!/bin/bash
# Copyright 2015 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.
# This is an example script that stops vtctld.
set -e
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
echo "Deleting vtctld replicationcontroller..."
$KUBECTL delete replicationcontroller vtctld
echo "Deleting vtctld service..."
$KUBECTL delete service vtctld

View File

@ -0,0 +1,22 @@
kind: Service
apiVersion: v1
metadata:
name: vtctld
labels:
component: vtctld
app: vitess
spec:
ports:
- port: 15000
name: web
targetPort: 15000
nodePort: 30000
- port: 15001
name: grpc
targetPort: 15001
nodePort: 30001
selector:
component: vtctld
app: vitess
type: NodePort

View File

@ -0,0 +1,40 @@
#!/bin/bash
# Copyright 2015 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.
# This is an example script that starts vtctld.
set -e
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
echo "Creating vtctld service..."
$KUBECTL create -f vtctld-service.yaml
echo "Creating vtctld replicationcontroller..."
# Expand template variables
sed_script=""
for var in backup_flags; do
sed_script+="s,{{$var}},${!var},g;"
done
# Instantiate template and send to kubectl.
cat vtctld-controller-template.yaml | sed -e "$sed_script" | $KUBECTL create -f -
server=$(get_vtctld_addr)
echo
echo "vtctld address: http://$server"

View File

@ -0,0 +1,45 @@
kind: ReplicationController
apiVersion: v1
metadata:
name: vtgate
spec:
replicas: {{replicas}}
template:
metadata:
labels:
component: vtgate
app: vitess
spec:
containers:
- name: vtgate
image: vitess/lite:v2.0.0-alpha5
volumeMounts:
- name: syslog
mountPath: /dev/log
- name: vtdataroot
mountPath: /vt/vtdataroot
resources:
limits:
memory: "512Mi"
cpu: "500m"
command:
- sh
- "-c"
- >-
mkdir -p $VTDATAROOT/tmp &&
chown -R vitess /vt &&
su -p -c "/vt/bin/vtgate
-topo_implementation etcd
-etcd_global_addrs http://$ETCD_GLOBAL_SERVICE_HOST:$ETCD_GLOBAL_SERVICE_PORT
-log_dir $VTDATAROOT/tmp
-alsologtostderr
-port 15001
-tablet_protocol grpc
-service_map 'bsonrpc-vt-vtgateservice'
-cell test" vitess
volumes:
- name: syslog
hostPath: {path: /dev/log}
- name: vtdataroot
emptyDir: {}

View File

@ -0,0 +1,28 @@
#!/bin/bash
# Copyright 2015 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.
# This is an example script that stops vtgate.
set -e
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
echo "Deleting vtgate replicationcontroller..."
$KUBECTL delete replicationcontroller vtgate
echo "Deleting vtgate service..."
$KUBECTL delete service vtgate

View File

@ -0,0 +1,15 @@
kind: Service
apiVersion: v1
metadata:
name: vtgate
labels:
component: vtgate
app: vitess
spec:
ports:
- port: 15001
selector:
component: vtgate
app: vitess
type: LoadBalancer

View File

@ -0,0 +1,38 @@
#!/bin/bash
# Copyright 2015 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.
# This is an example script that starts a vtgate replicationcontroller.
set -e
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
VTGATE_REPLICAS=${VTGATE_REPLICAS:-3}
VTGATE_TEMPLATE=${VTGATE_TEMPLATE:-'vtgate-controller-template.yaml'}
replicas=$VTGATE_REPLICAS
echo "Creating vtgate service..."
$KUBECTL create -f vtgate-service.yaml
sed_script=""
for var in replicas; do
sed_script+="s,{{$var}},${!var},g;"
done
echo "Creating vtgate replicationcontroller..."
cat $VTGATE_TEMPLATE | sed -e "$sed_script" | $KUBECTL create -f -

View File

@ -0,0 +1,51 @@
#!/bin/bash
# Copyright 2015 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.
# This is an example script that tears down the vttablet pods started by
# vttablet-up.sh.
set -e
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
server=$(get_vtctld_addr)
# Delete the pods for all shards
CELLS=${CELLS:-'test'}
keyspace='test_keyspace'
SHARDS=${SHARDS:-'0'}
TABLETS_PER_SHARD=${TABLETS_PER_SHARD:-5}
UID_BASE=${UID_BASE:-100}
num_shards=`echo $SHARDS | tr "," " " | wc -w`
uid_base=$UID_BASE
for shard in `seq 1 $num_shards`; do
cell_index=0
for cell in `echo $CELLS | tr "," " "`; do
for uid_index in `seq 0 $(($TABLETS_PER_SHARD-1))`; do
uid=$[$uid_base + $uid_index + $cell_index]
printf -v alias '%s-%010d' $cell $uid
echo "Deleting pod for tablet $alias..."
$KUBECTL delete pod vttablet-$uid
done
let cell_index=cell_index+100000000
done
let uid_base=uid_base+100
done

View File

@ -0,0 +1,128 @@
kind: Pod
apiVersion: v1
metadata:
name: vttablet-{{uid}}
labels:
component: vttablet
keyspace: "{{keyspace}}"
shard: "{{shard_label}}"
tablet: "{{alias}}"
app: vitess
spec:
containers:
- name: vttablet
image: vitess/lite:v2.0.0-alpha5
volumeMounts:
- name: syslog
mountPath: /dev/log
- name: vtdataroot
mountPath: /vt/vtdataroot
- name: certs
readOnly: true
mountPath: /etc/ssl/certs
resources:
limits:
memory: "1Gi"
cpu: "500m"
command:
- bash
- "-c"
- >-
set -e
mysql_socket="$VTDATAROOT/{{tablet_subdir}}/mysql.sock"
mkdir -p $VTDATAROOT/tmp
chown -R vitess /vt
while [ ! -e $mysql_socket ]; do
echo "[$(date)] waiting for $mysql_socket" ;
sleep 1 ;
done
su -p -s /bin/bash -c "mysql -u vt_dba -S $mysql_socket
-e 'CREATE DATABASE IF NOT EXISTS vt_{{keyspace}}'" vitess
su -p -s /bin/bash -c "/vt/bin/vttablet
-topo_implementation etcd
-etcd_global_addrs http://$ETCD_GLOBAL_SERVICE_HOST:$ETCD_GLOBAL_SERVICE_PORT
-log_dir $VTDATAROOT/tmp
-alsologtostderr
-port {{port}}
-grpc_port {{grpc_port}}
-service_map 'grpc-queryservice,grpc-tabletmanager,grpc-updatestream'
-binlog_player_protocol grpc
-tablet-path {{alias}}
-tablet_hostname $(hostname -i)
-init_keyspace {{keyspace}}
-init_shard {{shard}}
-target_tablet_type {{tablet_type}}
-mysqlctl_socket $VTDATAROOT/mysqlctl.sock
-db-config-app-uname vt_app
-db-config-app-dbname vt_{{keyspace}}
-db-config-app-charset utf8
-db-config-dba-uname vt_dba
-db-config-dba-dbname vt_{{keyspace}}
-db-config-dba-charset utf8
-db-config-repl-uname vt_repl
-db-config-repl-dbname vt_{{keyspace}}
-db-config-repl-charset utf8
-db-config-filtered-uname vt_filtered
-db-config-filtered-dbname vt_{{keyspace}}
-db-config-filtered-charset utf8
-enable-rowcache
-rowcache-bin /usr/bin/memcached
-rowcache-socket $VTDATAROOT/{{tablet_subdir}}/memcache.sock
-health_check_interval 5s
-restore_from_backup {{backup_flags}}" vitess
- name: mysql
image: vitess/lite:v2.0.0-alpha5
volumeMounts:
- name: syslog
mountPath: /dev/log
- name: vtdataroot
mountPath: /vt/vtdataroot
resources:
limits:
memory: "1Gi"
cpu: "500m"
command:
- sh
- "-c"
- >-
mkdir -p $VTDATAROOT/tmp &&
chown -R vitess /vt
su -p -c "/vt/bin/mysqlctld
-log_dir $VTDATAROOT/tmp
-alsologtostderr
-tablet_uid {{uid}}
-socket_file $VTDATAROOT/mysqlctl.sock
-db-config-app-uname vt_app
-db-config-app-dbname vt_{{keyspace}}
-db-config-app-charset utf8
-db-config-dba-uname vt_dba
-db-config-dba-dbname vt_{{keyspace}}
-db-config-dba-charset utf8
-db-config-repl-uname vt_repl
-db-config-repl-dbname vt_{{keyspace}}
-db-config-repl-charset utf8
-db-config-filtered-uname vt_filtered
-db-config-filtered-dbname vt_{{keyspace}}
-db-config-filtered-charset utf8
-bootstrap_archive mysql-db-dir_10.0.13-MariaDB.tbz" vitess
# The bootstrap archive above contains an empty mysql data dir
# with user permissions set up as required by Vitess. The archive is
# included in the Docker image.
env:
- name: EXTRA_MY_CNF
value: /vt/config/mycnf/master_mariadb.cnf
volumes:
- name: syslog
hostPath: {path: /dev/log}
- name: vtdataroot
emptyDir: {}
- name: certs
hostPath: {path: /etc/ssl/certs}

View File

@ -0,0 +1,68 @@
#!/bin/bash
# Copyright 2015 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.
# This is an example script that creates a vttablet deployment.
set -e
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh
# Create the pods for shard-0
CELLS=${CELLS:-'test'}
keyspace='test_keyspace'
SHARDS=${SHARDS:-'0'}
TABLETS_PER_SHARD=${TABLETS_PER_SHARD:-5}
port=15002
grpc_port=16002
UID_BASE=${UID_BASE:-100}
VTTABLET_TEMPLATE=${VTTABLET_TEMPLATE:-'vttablet-pod-template.yaml'}
RDONLY_COUNT=${RDONLY_COUNT:-2}
uid_base=$UID_BASE
for shard in $(echo $SHARDS | tr "," " "); do
cell_index=0
for cell in `echo $CELLS | tr ',' ' '`; do
echo "Creating $keyspace.shard-$shard pods in cell $CELL..."
for uid_index in `seq 0 $(($TABLETS_PER_SHARD-1))`; do
uid=$[$uid_base + $uid_index + $cell_index]
printf -v alias '%s-%010d' $cell $uid
printf -v tablet_subdir 'vt_%010d' $uid
echo "Creating pod for tablet $alias..."
# Add xx to beginning or end if there is a dash. K8s does not allow for
# leading or trailing dashes for labels
shard_label=`echo $shard | sed s'/[-]$/-xx/' | sed s'/^-/xx-/'`
tablet_type=replica
if [ $uid_index -gt $(($TABLETS_PER_SHARD-$RDONLY_COUNT-1)) ]; then
tablet_type=rdonly
fi
# Expand template variables
sed_script=""
for var in alias cell uid keyspace shard shard_label port grpc_port tablet_subdir tablet_type backup_flags; do
sed_script+="s,{{$var}},${!var},g;"
done
# Instantiate template and send to kubectl.
cat $VTTABLET_TEMPLATE | sed -e "$sed_script" | $KUBECTL create -f -
done
let cell_index=cell_index+100000000
done
let uid_base=uid_base+100
done