rpk registry schema create

Create a schema for the given subject.

This uploads a schema to the registry, creating the schema if it does not exist. The schema type is detected by the filename extension: ".avro" or ".avsc" for Avro, ".json" for JSON, and ".proto" for Protobuf. You can manually specify the type with the --type flag.

You may pass the references using the --reference flag, which accepts either a comma separated list of <name>:<subject>:<version> or a path to a file. The file must contain lines of name, subject, and version separated by a tab or space, or the equivalent in json / yaml format.

In import mode, you can specify a schema ID and version using the --id and --schema-version flags to assign specific values when creating the schema.

Usage

rpk registry schema create SUBJECT --schema {filename} [flags]

Examples

This section provides examples of how to use rpk registry schema create.

Create a Protobuf schema with subject foo.

rpk registry schema create foo --schema path/to/file.proto

Create an Avro schema, passing the type via flags.

rpk registry schema create foo --schema /path/to/file --type avro

Create a Protobuf schema that references the schema in subject my_subject, version 1.

rpk registry schema create foo --schema /path/to/file.proto --references my_name:my_subject:1

Create a schema with a specific ID and version in import mode.

rpk registry schema create foo --schema /path/to/file.proto --id 42 --schema-version 3

Create a schema with metadata properties as key=value pairs.

rpk registry schema create foo --schema /path/to/file.proto \
  --metadata-properties owner=team-a \
  --metadata-properties env=prod

Create a schema with metadata properties using JSON format.

rpk registry schema create foo --schema /path/to/file.proto \
  --metadata-properties '{"owner":"team-a","env":"prod"}'

Flags

Value Type Description

--id

int

Optional schema ID to use when creating the schema in import mode.

-p, --metadata-properties

stringArray

Schema metadata properties as key=value pairs or JSON (for example, {"key":"value"}).

--references

string

Comma-separated list of references (name:subject:version) or path to reference file.

--schema

string

Schema filepath to upload, must be .avro, .avsc, or .proto.

--schema-version

int

Optional schema version to use when creating the schema in import mode (requires --id).

--type

string

Schema type (avro,protobuf,json); overrides schema file extension.

Global flags

Value Type Description

--config

string

Redpanda or rpk config file; default search paths are ~/.config/rpk/rpk.yaml, $PWD/redpanda.yaml, and /etc/redpanda/redpanda.yaml.

-X, --config-opt

stringArray

Override rpk configuration settings; -X help for detail or -X list for terser detail.

--ignore-profile

bool

Ignore rpk.yaml and redpanda.yaml; use default settings.

--profile

string

rpk profile to use.

-v, --verbose

bool

Enable verbose logging.