// Module included in the following assemblies:
//
// assembly-iot-guide.adoc
// assembly-IoT.adoc

[id='iot-installing-services-{context}']
= Installing IoT services

To get started using the IoT feature on {ProductName}, you must first install the IoT services.

.Procedure

. (Optional) If you want to deploy to a project other than `{ProductNamespace}` you must run the following command and substitute `{ProductNamespace}` in subsequent steps:
+
[options="nowrap",subs="+quotes,attributes"]
----
sed -i 's/{ProductNamespace}/_my-project_/' install/preview-bundles/iot/*.yaml
----
. Deploy the IoT bundles:
+
[options="nowrap",subs="attributes"]
----
{cmdcli} apply -f install/preview-bundles/iot
----
ifeval::["{cmdcli}" == "kubectl"]
. Create certificates for IoT services. For testing purposes, you can create a self-signed certificate:
+
[options="nowrap",subs="attributes"]
----
./install/components/iot/examples/k8s-tls/create
./install/components/iot/examples/k8s-tls/deploy
----
endif::[]

ifeval::["{cmdcli}" == "oc"]
. Create certificates for the MQTT protocol adapter. For testing purposes, you can create a self-signed certificate:
+
[options="nowrap",subs="attributes"]
----
./install/components/iot/examples/k8s-tls/create
{cmdcli} create secret tls iot-mqtt-adapter-tls --key=install/components/iot/examples/k8s-tls/build/iot-mqtt-adapter-key.pem --cert=install/components/iot/examples/k8s-tls/build/iot-mqtt-adapter-fullchain.pem
----
endif::[]

+
[NOTE]
====
If your cluster is not running on `localhost`, you need to specify the cluster host name when creating certificates to allow external clients (like MQTT) to properly connect to the appropriate services. For example:
[options="nowrap",subs="attributes"]
----
CLUSTER=x.x.x.x.nip.io install/components/iot/examples/k8s-tls/create
----
====

. Install the {DataGridProductName} server:
+
[options="nowrap",subs="attributes"]
----
{cmdcli} apply -f install/components/iot/examples/infinispan/common
{cmdcli} apply -f install/components/iot/examples/infinispan/manual
----

. Install an example IoT infrastructure configuration:
+
[options="nowrap",subs="attributes"]
----
ifeval::["{cmdcli}" == "kubectl"]
{cmdcli} apply -f install/components/iot/examples/iot-config-k8s.yaml
endif::[]
ifeval::["{cmdcli}" == "oc"]
{cmdcli} apply -f install/components/iot/examples/iot-config.yaml
endif::[]
----

