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

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

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

.Procedure

. 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 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::[]
----

