SchemaRegistryRestore
A SchemaRegistryRestore is used for restoring schemas to a SchemaRegistry, from the data previously backed-up by a SchemaRegistryBackup in a Storage.
It is configured by creating a SchemaRegistryRestore resource in Kubernetes.
The Kannika Armory Operator creates a Job that runs the restore process, based on the configuration in the SchemaRegistryRestore resource.
A SchemaRegistryRestore can be managed using the kubectl command line tool,
and are available by the name schemaregistryrestore or schemaregistryrestores.
$ kubectl get schemaregistryrestoresNAME STATUSconfluent-registry-restore 🌈 ReadyRestore Status
Section titled “Restore Status”A SchemaRegistryRestore can have the following statuses:
- Initializing The Restore process is being created;
- Ready The Restore is configured but it has not been started yet;
- Running The Restore is running and restoring to the registry;
- Error The Restore has failed;
- Done The Restore is complete.
Additionally,
a Restore resource exposes a JobCompleted Condition to report on the state of the underlying Job.
This condition’s status can either be ‘True’ or ‘False’,
and the reason field gives additional context:
- JobInitializing the job is being started;
- JobRunning the job is running;
- JobCompleted the job has completed successfully;
- JobFailed the job has failed.
Configuring a SchemaRegistryRestore
Section titled “Configuring a SchemaRegistryRestore”The following is an example of a SchemaRegistryRestore.
apiVersion: kannika.io/v1alphakind: SchemaRegistryRestoremetadata: name: confluent-registry-restorespec: enabled: true registry: confluent-registry registryCredentialsFrom: credentialsRef: name: "http-basic-creds" storage: s3-storage storageCredentialsFrom: credentialsRef: name: "s3-storage-creds" extraEnvVars: - name: RUST_LOG value: "debug"Full example with SchemaRegistry, Credentials, and Storage
# Secret - holds the registry's HTTP Basic credentialsapiVersion: v1kind: Secrettype: Opaquemetadata: name: http-basic-creds-secretdata: username: bXktdXNlcm5hbWU= # base64 encoded password: bXktcGFzc3dvcmQ= # base64 encoded---# Credentials - defines authentication to the schema registryapiVersion: kannika.io/v1alphakind: Credentialsmetadata: name: http-basic-credsspec: httpBasic: usernameFrom: secretKeyRef: name: http-basic-creds-secret key: username passwordFrom: secretKeyRef: name: http-basic-creds-secret key: password---# SchemaRegistry - defines the connection to the target schema registryapiVersion: kannika.io/v1alphakind: SchemaRegistrymetadata: name: confluent-registryspec: confluent: url: https://registry.example.com---# Secret - holds the S3 access keysapiVersion: v1kind: Secrettype: Opaquemetadata: name: aws-credsdata: accessKeyId: bXktYWNjZXNzLWtleQ== # base64 encoded secretAccessKey: bXktc2VjcmV0LWtleQ== # base64 encoded---# Credentials - defines authentication to the S3 bucketapiVersion: kannika.io/v1alphakind: Credentialsmetadata: name: s3-storage-credsspec: aws: accessKeyIdFrom: secretKeyRef: name: aws-creds key: accessKeyId secretAccessKeyFrom: secretKeyRef: name: aws-creds key: secretAccessKey---# Storage - the source of the restore (where the backed-up schemas are stored)apiVersion: kannika.io/v1alphakind: Storagemetadata: name: s3-storagespec: s3: bucket: my-schemas-bucket region: eu-west-1---# SchemaRegistryRestore - restores schemas from the Storage to the registryapiVersion: kannika.io/v1alphakind: SchemaRegistryRestoremetadata: name: confluent-registry-restorespec: enabled: true registry: confluent-registry registryCredentialsFrom: credentialsRef: name: http-basic-creds storage: s3-storage storageCredentialsFrom: credentialsRef: name: s3-storage-credsIn this example:
-
A SchemaRegistryRestore named
confluent-registry-restoreis created, as indicated by the.metadata.namefield. This name will inherited by the Job running the restore process. -
The
spec.enabledflag is set totrueto allow restore process to start. If it is omitted or set tofalse, the restore process will be created in a paused state until the flag is switched totrue. -
The SchemaRegistryRestore will pull data from the Storage called
s3-storageas defined in thespec.storagefield, and use the Credentials referenced bys3-storage-credsto authenticate to it. -
The SchemaRegistryRestore will connect to the
confluent-registrySchemaRegistry to restore schemas, as indicated by the.spec.registryfield, and use the Credentials referenced byhttp-basic-credsfor authentication. -
The
spec.extraEnvVarsfield is used to pass additional environment variables to the restore process. In this case, theRUST_LOGvariable is set todebugto enable debug logging.
Import mode
Section titled “Import mode”Some registries such as the Confluent Cloud Schema Registry support an ‘import’ mode that will ensure that schemas will be restored with their original schema ID and version.
The restore validates the target registry’s mode before writing anything and never changes it. The target registry must be switched to IMPORT mode beforehand:
$ curl -X PUT \ -H "Content-Type: application/json" \ -d '{"mode":"IMPORT"}' \ https://registry.example.com/modeIf the target registry’s import mode is enabled, a SchemaRegistryRestore may be configured to try and restore the original IDs and versions:
apiVersion: kannika.io/v1alphakind: SchemaRegistryRestoremetadata: name: confluent-registry-restorespec: enabled: true importMode: true registry: confluent-registry registryCredentialsFrom: credentialsRef: name: "http-basic-creds" storage: s3-storage storageCredentialsFrom: credentialsRef: name: "s3-storage-creds"Schema contexts
Section titled “Schema contexts”Backed-up subjects in a named schema context are restored under their fully qualified name,
for example :.production:orders-value,
into that same context on the target registry.
In import mode, the global IMPORT mode covers the default context only. Every named context being restored must be switched to IMPORT mode separately:
$ curl -X PUT \ -H "Content-Type: application/json" \ -d '{"mode":"IMPORT"}' \ https://registry.example.com/mode/:.production:The restore validates this before writing anything.
If a named context is not in IMPORT mode,
the restore fails up front with the JobFailed condition reason and the target registry is left untouched.
The same applies to registries without IMPORT mode support.
Reinstating the original mode
Section titled “Reinstating the original mode”A registry in IMPORT mode accepts writes that bypass the usual checks, so it should not be left in that state. After the restore completes, switch the registry back to its original mode:
$ curl -X PUT \ -H "Content-Type: application/json" \ -d '{"mode":"READWRITE"}' \ https://registry.example.com/modeRepeat this for every named context that was switched to IMPORT mode:
$ curl -X PUT \ -H "Content-Type: application/json" \ -d '{"mode":"READWRITE"}' \ https://registry.example.com/mode/:.production:Can I choose which schemas are restored?
Section titled “Can I choose which schemas are restored?”Currently, a SchemaRegistryRestore will restore all data present in the Storage. In a future release, it will be possible to configure a subset of the data to restore.

