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

[id="installing-registry-kafka-kubernetes-storage"]

ifdef::apicurio-registry[]
= Installing {registry} with Apache Kafka Streams storage on Kubernetes

This topic explains how to install and run {registry} with storage in Apache Kafka Streams with Strimzi using an OpenShift template. This storage option is suitable for production environments. 

The following versions are supported:

* Apache Kafka 2.3.x
* Apache Kafka 2.2.x
endif::[]

ifdef::rh-service-registry[]
=  Installing {registry} with AMQ Streams storage on OpenShift

This topic explains how to install and run {registry} with storage in Red Hat AMQ Streams using an OpenShift template. 

The following versions are supported:

* AMQ Streams 1.4 
* OpenShift 4.4 or 4.3    
endif::[]

.Prerequisites

ifdef::apicurio-registry[]
//Use OpenShift template until Kubernetes Helm chart is available
* You must have an OpenShift cluster with cluster administrator access.
* You must have already installed Strimzi and configured your Kafka cluster on OpenShift. See xref:setting-up-kafka-kubernetes-storage[].
* Ensure that you can connect to the {registry} container image in GitHub: link:https://hub.docker.com/r/apicurio/apicurio-registry-kafka[].

endif::[] 

ifdef::rh-service-registry[]
* You must have an OpenShift cluster with cluster administrator access.
* You must have already installed AMQ Streams and configured your Kafka cluster on OpenShift. See xref:setting-up-kafka-kubernetes-storage[].
* Ensure that you can access the {registry} image in the 
link:https://access.redhat.com/containers/#/registry.access.redhat.com/fuse7-tech-preview/fuse-service-registry-rhel7[Red Hat Container Catalog]:
** Create a service account and pull secret for the image. For details, see link:https://access.redhat.com/terms-based-registry/[Container Service Accounts].
** Download the pull secret and submit it to your OpenShift cluster. For example: 
+
[source,bash]
----
$ oc create -f 11223344_service-registry-secret.yaml --namespace=myproject
----
endif::[]

.Procedure
ifdef::apicurio-registry[]
. Get the link:https://github.com/Apicurio/apicurio-registry/blob/1.1.x/distro/openshift-template/apicurio-registry-template-streams.yml[{registry} OpenShift template].

. Enter the following command to get the name of the Kafka bootstrap service running in Strimzi on your OpenShift cluster:
+
[source,bash]
----
$ oc get services | grep .*kafka-bootstrap
----

. Create a new OpenShift application using the `oc new-app` command. For example:
+
[source,bash]
----
$ oc new-app apicurio-registry-template-streams.yml \ 
   -p KAFKA_BOOTSTRAP_SERVERS=my-cluster-kafka-bootstrap:9092 \
   -p REGISTRY_ROUTE=my-cluster-service-registry-myproject.example.com \ 
   -p APPLICATION_ID=my-kafka-streams-app
----
+
You must specify the following arguments: 

** `apicurio-registry-template-streams`: The OpenShift template file for {registry}.
** `KAFKA_BOOTSTRAP_SERVERS`: The name of the Kafka bootstrap service on your OpenShift cluster, followed by the Kafka broker port. For example: `my-cluster-kafka-bootstrap:9092`.  
** `REGISTRY_ROUTE`: The name of the OpenShift route to expose {registry}, which is based on your OpenShift cluster environment, For example: `my-cluster-service-registry-myproject.example.com`.
** `APPLICATION_ID`: The name of your Kafka Streams application. For example: `my-kafka-streams-app`. 
+
You can also specify the following environment variables using the `-e` option:

** `APPLICATION_SERVER_HOST`: The IP address of your Kafka Streams application server host, which is required in a multi-node Kafka configuration. Defaults to `$(POD_IP)`.
** `APPLICATION_SERVER_PORT`: The port number of your Kafka Streams application server, which is required in a multi-node Kafka configuration. Defaults to `9000`.

endif::[]

ifdef::rh-service-registry[]
. Get the 
link:https://github.com/Apicurio/apicurio-registry/blob/1.1.x-redhat/distro/openshift-template/service-registry-template.yml[{registry} OpenShift template].

. Enter the following command to get the name of the Kafka bootstrap service running in AMQ Streams on your OpenShift cluster:
+
[source,bash]
----
$ oc get services | grep .*kafka-bootstrap
----
. Create a new OpenShift application using the `oc new-app` command. For example:
+
[source,bash]
----
$ oc new-app service-registry-template.yml \
   -p KAFKA_BOOTSTRAP_SERVERS=my-cluster-kafka-bootstrap:9092 \ 
   -p REGISTRY_ROUTE=my-cluster-service-registry-myproject.example.com \ 
   -p APPLICATION_ID=my-kafka-streams-app
----
+
You must specify the following arguments: 

** `service-registry-template.yml`: The OpenShift template file for {registry}.
** `KAFKA_BOOTSTRAP_SERVERS`: The name of the Kafka bootstrap service on your OpenShift cluster, followed by the Kafka broker port. For example: `my-cluster-kafka-bootstrap:9092`.  
** `REGISTRY_ROUTE`: The name of the OpenShift route to expose {registry}, which is based on your OpenShift cluster environment. For example: `my-cluster-service-registry-myproject.example.com`.
** `APPLICATION_ID`: The name of your AMQ Streams application. For example: `my-kafka-streams-app`. 
+
You can also specify the following environment variables using the `-e` option:

** `APPLICATION_SERVER_HOST`: The IP address of your Kafka Streams application server host, which is required in a multi-node Kafka configuration. Defaults to `$(POD_IP)`.
** `APPLICATION_SERVER_PORT`: The port number of your Kafka Streams application server, which is required in a multi-node Kafka configuration. Defaults to `9000`.

. Verify the command output when complete. For example: 
+
----
Deploying template "myproject/service-registry" for "service-registry-template.yml" to project myproject

 service-registry
 ---------
 Congratulations on deploying Service Registry into OpenShift!
    
 All components have been deployed and configured.

  * With parameters:
    * Registry Route Name=my-cluster-service-registry-myproject.example.com
    * Registry Max Memory Limit=1300Mi
    * Registry Memory Requests=600Mi
    * Registry Max CPU Limit=1
    * Registry CPU Requests=100m
    * Kafka Bootstrap Servers=my-cluster-kafka-bootstrap:9092
    * Kafka Application ID=my-kafka-streams-app

--> Creating resources ...
    imagestream.image.openshift.io "registry" created
    service "service-registry" created
    deploymentconfig.apps.openshift.io "service-registry" created
    route.route.openshift.io "service-registry" created
--> Success
    Access your application via route 'my-cluster-service-registry-myproject.example.com' 
----
endif::[]

. Enter `oc status` to view your {registry} installation on OpenShift. 

.Additional resources
* For sample REST API requests, see the link:files/registry-rest-api.htm[Registry REST API documentation].
* For details on example client applications: 
** https://github.com/Apicurio/apicurio-registry-demo
ifdef::rh-service-registry[]
** link:https://developers.redhat.com/blog/2019/12/16/getting-started-with-red-hat-integration-service-registry/[Getting Started with Red Hat Integration Service Registry]
endif::[]
