我使用helm和Vitess示例中的文件101_initial_cluster.yaml来设置我的初始集群。该示例使用SQL字符串进行模式初始化,如下所示:
schema:
initial: |-
create table product(
sku varbinary(128),
description varbinary(128),
price bigint,
primary key(sku)
);
create table customer(
customer_id bigint not null auto_increment,
email varbinary(128),
primary key(customer_id)
);
create table corder(
order_id bigint not null auto_increment,
customer_id bigint,
sku varbinary(128),
price bigint,
primary key(order_id)
);
我想用文件initial: my_initial_keyspace_schema.sql
替换它。从Vitess文档中我可以看到Vitess允许使用ApplySchema -sql_file=user_table.sql user
,但我想使用helm文件进行初始化。
这将非常有用,因为将模式组织和粘贴为string
非常繁琐。必须首先粘贴依赖于其他表的表,然后依次粘贴其他表。忘记让Vitess抛出错误。
欢迎来到StackOverflow。
我担心没有开箱即用的功能可以在Vitess Helm图表的当前状态下直接从SQL文件初始化DbSchema。您可以通过helm inspect <chart_name>
命令识别其任何可配置参数。
但是,您可以尝试通过以下方式自定义它以满足您的需求:
{{ if .Values.initialSchemaSqlFile.enabled }}
{{- $files := .Files }}
{{- range tuple "static/initial_schema.sql" }}
{{ $schema := $files.Get . }}
{{- end }}
{{ else }}
# Default inline schema from Values.topology.cells.keyspaces[0].schema
{{ end }}
有关使用Helm内置对象(如文件here)的更多信息