// Metadata created by nebel
// ParentAssemblies: assemblies/getting-started/as_installing-the-registry.adoc

[id="installing-registry-kafka-streams-storage"]
= Installing {registry} with Apache Kafka Streams storage

This topic explains how to install and run {registry} with Kafka Streams storage from a container image. This storage option is suitable for production environments. 

.Prerequisites
* You must have Docker installed and the Docker daemon running.
* Ensure that you can connect to the container repository: https://hub.docker.com/r/apicurio/apicurio-registry-streams.
* Ensure that `KAFKA_HOME` is set to the location of your Kafka-based system. 
* You must already have a Kafka broker running. For example:
+
[source,bash]
----
$KAFKA_HOME/bin/zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties &
$KAFKA_HOME/bin/kafka-server-start.sh $KAFKA_HOME/config/server.properties &
----
+
* You must have created the following topics for Kafka Streams storage:
+
[source,bash]
----
$KAFKA_HOME/bin/kafka-topics.sh --zookeeper localhost --create --topic storage-topic --partitions 1 --replication-factor 1  --config cleanup.policy=compact
$KAFKA_HOME/bin/kafka-topics.sh --zookeeper localhost --create --topic global-id-topic --partitions 1 --replication-factor 1 --config cleanup.policy=compact
----
+
For more details, see https://kafka.apache.org/quickstart. 

.Procedure
. Get the {registry} container image:
+
[source,bash]
----
$ docker pull apicurio/apicurio-registry-kafka-streams 
----
. Run the container image and specify the following environment variables for your Kafka system: 
+
** `KAFKA_BOOTSTRAP_SERVERS` - The address(es) of your Kafka broker(s).
** `APPLICATION_ID` - The name of your Kafka Streams application.
+
For example:  
+
[source,bash]
----
$ docker run -it -p 8080:8080 -e "KAFKA_BOOTSTRAP_SERVERS=kafka:9092" -e "APPLICATION_ID=my-kafka-streams-app" apicurio/apicurio-registry-kafka-streams:latest
----

. Send a test request using the {registry} REST API. For example, enter the following `curl` command to create a simple Avro schema artifact for a share price application in the registry:
+
[source,bash]
----
$ curl -X POST -H "Content-type: application/json; artifactType=AVRO" -H "X-Registry-ArtifactId: share-price" --data '{"type":"record","name":"price","namespace":"com.example","fields":[{"name":"symbol","type":"string"},{"name":"price","type":"string"}]}' http://localhost:8080/artifacts
----
. Verify that the response includes the expected JSON body to confirm that the Avro schema artifact was created in the registry. For example:
+
[source,bash]
----
{"createdOn":1578310374517,"modifiedOn":1578310374517,"id":"prices-value","version":1,"type":"AVRO","globalId":8}
----

.Additional resources
* For more REST API sample requests, see the link:files/registry-rest-api.htm[Registry REST API documentation].
* For a demo based on Kafka Streams storage, see link:https://github.com/Apicurio/apicurio-registry-demo[].
* For more details on Kafka Streams, see the link:https://kafka.apache.org/documentation/streams//[Apache Kafka Streams documentation].
