// Module included in the following assemblies:
//
// managing/assembly-management-tasks.adoc

[id='proc-add-service-discovery-{context}']
= Discovering services using labels and annotations

Service discovery makes it easier for client applications running in the same Kubernetes cluster as {ProductName} to interact with a Kafka cluster.

A _service discovery_ label and annotation is generated for services used to access the Kafka cluster:

* Internal Kafka bootstrap service
* HTTP Bridge service

The label helps to make the service discoverable, and the annotation provides connection details that a client application can use to make the connection.

The service discovery label, `strimzi.io/discovery`, is set as `true` for the `Service` resources.
The service discovery annotation has the same key, providing connection details in JSON format for each service.

[discrete]
== Example internal Kafka bootstrap service

[source,yaml,subs="attributes+"]
----
apiVersion: v1
kind: Service
metadata:
  annotations:
    strimzi.io/discovery: |-
      [ {
        "port" : 9092,
        "tls" : false,
        "protocol" : "kafka",
        "auth" : "scram-sha-512"
      }, {
        "port" : 9093,
        "tls" : true,
        "protocol" : "kafka",
        "auth" : "tls"
      } ]
  labels:
    strimzi.io/cluster: my-cluster
    strimzi.io/discovery: "true"
    strimzi.io/kind: Kafka
    strimzi.io/name: my-cluster-kafka-bootstrap
  name: my-cluster-kafka-bootstrap
spec:
  #...
----

[discrete]
== Example HTTP Bridge service

[source,yaml,subs="attributes+"]
----
apiVersion: v1
kind: Service
metadata:
  annotations:
    strimzi.io/discovery: |-
      [ {
        "port" : 8080,
        "tls" : false,
        "auth" : "none",
        "protocol" : "http"
      } ]
  labels:
    strimzi.io/cluster: my-bridge
    strimzi.io/discovery: "true"
    strimzi.io/kind: KafkaBridge
    strimzi.io/name: my-bridge-bridge-service
----

== Returning connection details on services

You can find the services by specifying the discovery label when fetching services from the command line or a corresponding API call.

[source,yaml]
----
kubectl get service -l strimzi.io/discovery=true
----

The connection details are returned when retrieving the service discovery label.
