8000 create: add template for non-vshard cluster by elhimov · Pull Request #1183 · tarantool/tt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

create: add template for non-vshard cluster #1183

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
8000
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
< 10000 /div>
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

- `tt create`: add template for Tarantool Config Storage.
- `tt create`: add template for non-vshard Cluster.

### Changed

### Fixed
Expand Down
10 changes: 8 additions & 2 deletions cli/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ func NewCreateCmd() *cobra.Command {
Built-in templates:
cartridge: a simple Cartridge application.
single_instance: Tarantool 3 application with a single instance configuration.
vshard_cluster: Tarantool 3 vshard cluster application.`,
cluster: Tarantool 3 cluster application.
vshard_cluster: Tarantool 3 vshard cluster application.
config_storage: Tarantool 3 cluster configuration storage.`,
Example: `
# Create an application app1 from a template.

Expand All @@ -62,7 +64,11 @@ Built-in templates:

# Create Tarantool 3 vshard cluster.

$ tt create vshard_cluster --name cluster_app`,
$ tt create vshard_cluster --name cluster_app

# Create Tarantool 3 cluster configuration storage.

$ tt create config_storage --name cs_app`,
}

createCmd.Flags().StringVarP(&appName, "name", "n", "", "Application name")
Expand Down
1 change: 1 addition & 0 deletions cli/cmd/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestCreateValidArgsFunction(t *testing.T) {
"cartridge",
"vshard_cluster",
"single_instance",
"config_storage",
"archive",
"template2",
tdir1Name,
Expand Down
16 changes: 16 additions & 0 deletions cli/codegen/generate_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,22 @@ func main() {
if err != nil {
log.Errorf("error while generating file modes: %s", err)
}
err = generateFileModeFile(
"cli/create/builtin_templates/templates/config_storage",
"cli/create/builtin_templates/static/config_storage_template_filemodes_gen.go",
"ConfigStorage",
)
if err != nil {
log.Errorf("error while generating file modes: %s", err)
}
err = generateFileModeFile(
"cli/create/builtin_templates/templates/cluster",
"cli/create/builtin_templates/static/cluster_template_filemodes_gen.go",
"Cluster",
)
if err != nil {
log.Errorf("error while generating file modes: %s", err)
}

if err = generateLuaCodeVar(); err != nil {
log.Errorf("error while generating lua code string variables: %s", err)
Expand Down
10 changes: 9 additions & 1 deletion cli/create/builtin_templates/builtin_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ var FileModes = map[string]map[string]int{
"cartridge": static.CartridgeFileModes,
"vshard_cluster": static.VshardClusterFileModes,
"single_instance": static.SingleInstanceFileModes,
"config_storage": static.ConfigStorageFileModes,
"cluster": static.ClusterFileModes,
}

// Names contains built-in template names.
var Names = [...]string{"cartridge", "vshard_cluster", "single_instance"}
var Names = [...]string{
"cartridge",
"vshard_cluster",
"single_instance",
"config_storage",
"cluster",
}
28 changes: 28 additions & 0 deletions cli/create/builtin_templates/templates/cluster/MANIFEST.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
description: Cluster template
follow-up-message: |
What's next?
Build and start '{{ .name }}' application:
$ tt build {{ .name }}
$ tt start {{ .name }}

Pay attention that default passwords were generated,
you can change it in the config.yaml.

vars:
- prompt: Number of replication sets
name: num_replicasets
default: '2'
re: ^[1-9]\d*$

- prompt: Number of replicas per replication set (>=2)
name: num_replicas
default: '2'
re: ^[2-9]|[1-9]\d+$

- prompt: User name
name: username
default: 'client'

- prompt: Password
name: password
default: 'secret'
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
credentials:
users:
{{.username}}:
password: '{{.password}}'
roles: [super]
replicator:
password: 'topsecret'
roles: [replication]

iproto:
advertise:
peer:
login: replicator

groups:
group-001:
replicasets:
{{- $num_replicasets := atoi .num_replicasets}}
{{- $num_replicas := atoi .num_replicas}}
{{- range replicasets "replicaset" $num_replicasets $num_replicas}}
{{.Name}}:
instances:
{{- range .InstNames}}
{{.}}:
iproto:
listen:
- uri: 127.0.0.1:{{port}}
{{- end}}
{{- end}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
{{- $num_replicasets := atoi .num_replicasets}}
{{- $num_replicas := atoi .num_replicas}}
{{- range replicasets "replicaset" $num_replicasets $num_replicas}}
{{- range .InstNames}}
{{.}}:
{{- end}}
{{- end}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
description: Config storage template
follow-up-message: |
What's next?
Start '{{ .name }}' application:
$ tt start {{ .name }}

Pay attention that default user and password were generated
for the 'replication' role, you can change it in the config.yaml.

vars:
- prompt: Storages replicas (odd, >=3)
name: replicas_count
default: '3'
re: ^([3579]|[1-9]\d*[13579])$

- prompt: Status check interval
name: status_check_interval
default: '5'
re: ^[1-9]\d*$

- prompt: User name
name: username
default: 'client'

- prompt: Password
name: password
default: 'secret'
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
credentials:
users:
replicator:
password: 'topsecret'
roles: [replication]
{{.username}}:
password: '{{.password}}'
privileges:
- permissions: [execute]
lua_call:
- config.storage.get
- config.storage.put
- config.storage.delete
- config.storage.keepalive
- config.storage.txn
- config.storage.info
# Not necessary since tarantool 3.5.0, 3.4.1, 3.3.3, 3.2.2.
- permissions: [read, write]
spaces: [config_storage, config_storage_meta]

iproto:
advertise:
peer:
login: replicator

replication:
failover: election

database:
use_mvcc_engine: true

groups:
group-001:
replicasets:
{{- $status_check_interval := atoi .status_check_interval}}
{{- $replicas := atoi .replicas_count}}
{{- range replicasets "replicaset" 1 $replicas}}
{{.Name}}:
roles: [config.storage]
roles_cfg:
config.storage:
status_check_interval: {{$status_check_interval}}
instances:
{{- range .InstNames}}
{{.}}:
iproto:
listen:
- uri: 127.0.0.1:{{port}}
{{- end}}
{{- end}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
{{- $replicas := atoi .replicas_count}}
{{- range replicasets "replicaset" 1 $replicas}}
{{- range .InstNames}}
{{.}}:
{{- end}}
{{- end}}
Loading
Loading
0