Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace vitess:base with vitess:lite images for docker-compose services #7004

Merged
merged 6 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions examples/compose/config/init_db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# This file is executed immediately after mysql_install_db,
# to initialize a fresh data directory.
###############################################################################
# Equivalent of mysql_secure_installation
###############################################################################
# Changes during the init db should not make it to the binlog.
# They could potentially create errant transactions on replicas.
SET sql_log_bin = 0;
# Remove anonymous users.
DELETE FROM mysql.user WHERE User = '';
# Disable remote root access (only allow UNIX socket).
DELETE FROM mysql.user WHERE User = 'root' AND Host != 'localhost';
# Remove test database.
DROP DATABASE IF EXISTS test;
###############################################################################
# Vitess defaults
###############################################################################
# Vitess-internal database.
CREATE DATABASE IF NOT EXISTS _vt;
# Note that definitions of local_metadata and shard_metadata should be the same
# as in production which is defined in go/vt/mysqlctl/metadata_tables.go.
CREATE TABLE IF NOT EXISTS _vt.local_metadata (
name VARCHAR(255) NOT NULL,
value VARCHAR(255) NOT NULL,
db_name VARBINARY(255) NOT NULL,
PRIMARY KEY (db_name, name)
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS _vt.shard_metadata (
name VARCHAR(255) NOT NULL,
value MEDIUMBLOB NOT NULL,
db_name VARBINARY(255) NOT NULL,
PRIMARY KEY (db_name, name)
) ENGINE=InnoDB;
jawabuu marked this conversation as resolved.
Show resolved Hide resolved
# Admin user with all privileges.
CREATE USER 'vt_dba'@'localhost';
GRANT ALL ON *.* TO 'vt_dba'@'localhost';
GRANT GRANT OPTION ON *.* TO 'vt_dba'@'localhost';
# User for app traffic, with global read-write access.
CREATE USER 'vt_app'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE,
REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES,
LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW,
SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER
ON *.* TO 'vt_app'@'localhost';
# User for app debug traffic, with global read access.
CREATE USER 'vt_appdebug'@'localhost';
GRANT SELECT, SHOW DATABASES, PROCESS ON *.* TO 'vt_appdebug'@'localhost';
# User for administrative operations that need to be executed as non-SUPER.
# Same permissions as vt_app here.
CREATE USER 'vt_allprivs'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE,
REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES,
LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW,
SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER
ON *.* TO 'vt_allprivs'@'localhost';
# User for slave replication connections.
# TODO: Should we set a password on this since it allows remote connections?
CREATE USER 'vt_repl'@'%';
GRANT REPLICATION SLAVE ON *.* TO 'vt_repl'@'%';
# User for Vitess filtered replication (binlog player).
# Same permissions as vt_app.
CREATE USER 'vt_filtered'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE,
REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES,
LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW,
SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER
ON *.* TO 'vt_filtered'@'localhost';
# User for Orchestrator (https://github.com/openark/orchestrator).
# TODO: Reenable when the password is randomly generated.
CREATE USER 'orc_client_user'@'%' IDENTIFIED BY 'orc_client_user_password';
GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD
ON *.* TO 'orc_client_user'@'%';
GRANT SELECT
ON _vt.* TO 'orc_client_user'@'%';
FLUSH PRIVILEGES;
RESET SLAVE ALL;
RESET MASTER;
jawabuu marked this conversation as resolved.
Show resolved Hide resolved
32 changes: 15 additions & 17 deletions examples/compose/docker-compose.beginners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,34 @@ services:
- consul1

vtctld:
image: vitess/base
image: vitess/lite
ports:
- "15000:$WEB_PORT"
- "$GRPC_PORT"
command: ["sh", "-c", " $$VTROOT/bin/vtctld \
command: ["sh", "-c", " /vt/bin/vtctld \
$TOPOLOGY_FLAGS \
-cell $CELL \
-workflow_manager_init \
-workflow_manager_use_election \
-service_map 'grpc-vtctl' \
-backup_storage_implementation file \
-file_backup_storage_root $$VTDATAROOT/backups \
-file_backup_storage_root /vt/vtdataroot/backups \
-logtostderr=true \
-port $WEB_PORT \
-grpc_port $GRPC_PORT \
-pid_file $$VTDATAROOT/tmp/vtctld.pid
-grpc_port $GRPC_PORT
"]
depends_on:
- consul1
- consul2
- consul3

vtgate:
image: vitess/base
image: vitess/lite
ports:
- "15099:$WEB_PORT"
- "$GRPC_PORT"
- "15306:$MYSQL_PORT"
command: ["sh", "-c", "$$VTROOT/bin/vtgate \
command: ["sh", "-c", "/vt/bin/vtgate \
$TOPOLOGY_FLAGS \
-logtostderr=true \
-port $WEB_PORT \
Expand All @@ -68,9 +67,8 @@ services:
-cell $CELL \
-cells_to_watch $CELL \
-tablet_types_to_wait MASTER,REPLICA \
-gateway_implementation discoverygateway \
-service_map 'grpc-vtgateservice' \
-pid_file $$VTDATAROOT/tmp/vtgate.pid \
-enable_system_settings=true \
"]
volumes:
- ".:/script"
Expand All @@ -84,7 +82,7 @@ services:
condition: service_healthy

schemaload:
image: vitess/base
image: vitess/lite
command:
- sh
- -c
Expand All @@ -108,7 +106,7 @@ services:
condition: service_healthy

vttablet101:
image: vitess/base
image: vitess/lite
ports:
- "15101:$WEB_PORT"
- "$GRPC_PORT"
Expand All @@ -134,13 +132,13 @@ services:
depends_on:
- vtctld
healthcheck:
test: ["CMD-SHELL","curl localhost:$$WEB_PORT/debug/health"]
test: ["CMD-SHELL","curl -s --fail --show-error localhost:$$WEB_PORT/debug/health"]
interval: 30s
timeout: 10s
retries: 15

vttablet102:
image: vitess/base
image: vitess/lite
ports:
- "15102:$WEB_PORT"
- "$GRPC_PORT"
Expand All @@ -164,13 +162,13 @@ services:
- vtctld
- vttablet101
healthcheck:
test: ["CMD-SHELL","curl localhost:$$WEB_PORT/debug/health"]
test: ["CMD-SHELL","curl -s --fail --show-error localhost:$$WEB_PORT/debug/health"]
interval: 30s
timeout: 10s
retries: 15

vttablet103:
image: vitess/base
image: vitess/lite
ports:
- "15103:$WEB_PORT"
- "$GRPC_PORT"
Expand All @@ -194,7 +192,7 @@ services:
- vtctld
- vttablet101
healthcheck:
test: ["CMD-SHELL","curl localhost:$$WEB_PORT/debug/health"]
test: ["CMD-SHELL","curl -s --fail --show-error localhost:$$WEB_PORT/debug/health"]
interval: 30s
timeout: 10s
retries: 15
retries: 15
9 changes: 6 additions & 3 deletions examples/compose/schemaload.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

# Copyright 2019 The Vitess Authors.
# Copyright 2020 The Vitess Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@ schema_files=${SCHEMA_FILES:-'create_messages.sql create_tokens.sql'}
vschema_file=${VSCHEMA_FILE:-'default_vschema.json'}
load_file=${POST_LOAD_FILE:-''}
external_db=${EXTERNAL_DB:-'0'}
export PATH=/vt/bin:$PATH

sleep $sleeptime

Expand All @@ -40,6 +41,8 @@ if [ ! -f schema_run ]; then
vtctlclient -server vtctld:$GRPC_PORT ApplyVSchema -vschema_file /script/${vschema_file} $KEYSPACE || \
vtctlclient -server vtctld:$GRPC_PORT ApplyVSchema -vschema "$(cat /script/${vschema_file})" $KEYSPACE

echo "List All Tablets"
vtctlclient -server vtctld:$GRPC_PORT ListAllTablets
jawabuu marked this conversation as resolved.
Show resolved Hide resolved
echo "Get Master Tablets"
master_tablets=$(vtctlclient -server vtctld:$GRPC_PORT ListAllTablets | awk '$4 == "master" { print $1 }')
for master_tablet in $master_tablets; do
Expand All @@ -53,7 +56,7 @@ if [ ! -f schema_run ]; then
mysql --port=15306 --host=vtgate < /script/$load_file
fi

touch schema_run
echo "Time: $(date). SchemaLoad completed at $(date "+%FT%T") " >> schema_run
touch /vt/schema_run
echo "Time: $(date). SchemaLoad completed at $(date "+%FT%T") " >> /vt/schema_run
echo "Done Loading Schema at $(date "+%FT%T")"
fi
30 changes: 13 additions & 17 deletions examples/compose/vtcompose/vtcompose.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 The Vitess Authors.
* Copyright 2020 The Vitess Authors.

* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -504,8 +504,8 @@ func generateDefaultShard(tabAlias int, shard string, keyspaceData keyspaceInfo,
- op: add
path: /services/init_shard_master%[2]d
value:
image: vitess/base
command: ["sh", "-c", "$$VTROOT/bin/vtctl %[5]s InitShardMaster -force %[4]s/%[3]s %[6]s-%[2]d "]
image: vitess/lite
command: ["sh", "-c", "/vt/bin/vtctlclient %[5]s InitShardMaster -force %[4]s/%[3]s %[6]s-%[2]d "]
%[1]s
`, dependsOn, aliases[0], shard, keyspaceData.keyspace, opts.topologyFlags, opts.cell)
}
Expand Down Expand Up @@ -539,7 +539,7 @@ func generateDefaultTablet(tabAlias int, shard, role, keyspace string, dbInfo ex
- op: add
path: /services/vttablet%[1]d
value:
image: vitess/base
image: vitess/lite
ports:
- "15%[1]d:%[4]d"
- "%[5]d"
Expand All @@ -565,7 +565,7 @@ func generateDefaultTablet(tabAlias int, shard, role, keyspace string, dbInfo ex
depends_on:
- vtctld
healthcheck:
test: ["CMD-SHELL","curl localhost:%[4]d/debug/health"]
test: ["CMD-SHELL","curl -s --fail --show-error localhost:%[4]d/debug/health"]
interval: 30s
timeout: 10s
retries: 15
Expand All @@ -577,22 +577,21 @@ func generateVtctld(opts vtOptions) string {
- op: add
path: /services/vtctld
value:
image: vitess/base
image: vitess/lite
ports:
- "15000:%[1]d"
- "%[2]d"
command: ["sh", "-c", " $$VTROOT/bin/vtctld \
command: ["sh", "-c", " /vt/bin/vtctld \
%[3]s \
-cell %[4]s \
-workflow_manager_init \
-workflow_manager_use_election \
-service_map 'grpc-vtctl' \
-backup_storage_implementation file \
-file_backup_storage_root $$VTDATAROOT/backups \
-file_backup_storage_root /vt/vtdataroot/backups \
-logtostderr=true \
-port %[1]d \
-grpc_port %[2]d \
-pid_file $$VTDATAROOT/tmp/vtctld.pid
"]
volumes:
- .:/script
Expand All @@ -608,12 +607,12 @@ func generateVtgate(opts vtOptions) string {
- op: add
path: /services/vtgate
value:
image: vitess/base
image: vitess/lite
ports:
- "15099:%[1]d"
- "%[2]d"
- "15306:%[3]d"
command: ["sh", "-c", "/script/run-forever.sh $$VTROOT/bin/vtgate \
command: ["sh", "-c", "/script/run-forever.sh /vt/bin/vtgate \
%[4]s \
-logtostderr=true \
-port %[1]d \
Expand All @@ -623,9 +622,7 @@ func generateVtgate(opts vtOptions) string {
-cell %[5]s \
-cells_to_watch %[5]s \
-tablet_types_to_wait MASTER,REPLICA,RDONLY \
-gateway_implementation discoverygateway \
-service_map 'grpc-vtgateservice' \
-pid_file $$VTDATAROOT/tmp/vtgate.pid \
-normalize_queries=true \
"]
volumes:
Expand All @@ -640,19 +637,18 @@ func generateVtwork(opts vtOptions) string {
- op: add
path: /services/vtwork
value:
image: vitess/base
image: vitess/lite
ports:
- "15100:%[1]d"
- "%[2]d"
command: ["sh", "-c", "$$VTROOT/bin/vtworker \
command: ["sh", "-c", "/vt/bin/vtworker \
%[3]s \
-cell %[4]s \
-logtostderr=true \
-service_map 'grpc-vtworker' \
-port %[1]d \
-grpc_port %[2]d \
-use_v3_resharding_mode=true \
-pid_file $$VTDATAROOT/tmp/vtwork.pid \
"]
depends_on:
- vtctld
Expand Down Expand Up @@ -685,7 +681,7 @@ func generateSchemaload(
- op: add
path: /services/schemaload_%[7]s
value:
image: vitess/base
image: vitess/lite
volumes:
- ".:/script"
environment:
Expand Down
Loading