|
| 1 | +// Module is included in the following assemblies: |
| 2 | +// |
| 3 | +// * serverless/admin_guide/serverless-kafka-admin.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="serverless-kafka-sink-security-config_{context}"] |
| 7 | += Configuring security for Kafka sinks |
| 8 | + |
| 9 | +_Transport Layer Security_ (TLS) is used by Apache Kafka clients and servers to encrypt traffic between Knative and Kafka, as well as for authentication. TLS is the only supported method of traffic encryption for Knative Kafka. |
| 10 | + |
| 11 | +_Simple Authentication and Security Layer_ (SASL) is used by Apache Kafka for authentication. If you use SASL authentication on your cluster, users must provide credentials to Knative for communicating with the Kafka cluster; otherwise events cannot be produced or consumed. |
| 12 | + |
| 13 | +.Prerequisites |
| 14 | + |
| 15 | +* The {ServerlessOperatorName}, Knative Eventing, and the `KnativeKafka` custom resources (CRs) are installed on your {product-title} cluster. |
| 16 | +* Kafka sink is enabled in the `KnativeKafka` CR. |
| 17 | +* You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in {product-title}. |
| 18 | +* You have a Kafka cluster CA certificate stored as a `.pem` file. |
| 19 | +* You have a Kafka cluster client certificate and a key stored as `.pem` files. |
| 20 | +* You have installed the OpenShift (`oc`) CLI. |
| 21 | +* You have chosen the SASL mechanism to use, for example, `PLAIN`, `SCRAM-SHA-256`, or `SCRAM-SHA-512`. |
| 22 | +
|
| 23 | +.Procedure |
| 24 | + |
| 25 | +. Create the certificate files as a secret in the same namespace as your `KafkaSink` object: |
| 26 | ++ |
| 27 | +[IMPORTANT] |
| 28 | +==== |
| 29 | +Certificates and keys must be in PEM format. |
| 30 | +==== |
| 31 | + |
| 32 | +** For authentication using SASL without encryption: |
| 33 | ++ |
| 34 | +[source,terminal] |
| 35 | +---- |
| 36 | +$ oc create secret -n <namespace> generic <secret_name> \ |
| 37 | + --from-literal=protocol=SASL_PLAINTEXT \ |
| 38 | + --from-literal=sasl.mechanism=<sasl_mechanism> \ |
| 39 | + --from-literal=user=<username> \ |
| 40 | + --from-literal=password=<password> |
| 41 | +---- |
| 42 | + |
| 43 | +** For authentication using SASL and encryption using TLS: |
| 44 | ++ |
| 45 | +[source,terminal] |
| 46 | +---- |
| 47 | +$ oc create secret -n <namespace> generic <secret_name> \ |
| 48 | + --from-literal=protocol=SASL_SSL \ |
| 49 | + --from-literal=sasl.mechanism=<sasl_mechanism> \ |
| 50 | + --from-file=ca.crt=<my_caroot.pem_file_path> \ <1> |
| 51 | + --from-literal=user=<username> \ |
| 52 | + --from-literal=password=<password> |
| 53 | +---- |
| 54 | +<1> The `ca.crt` can be omitted to use the system's root CA set if you are using a public cloud managed Kafka service, such as Red Hat OpenShift Streams for Apache Kafka. |
| 55 | + |
| 56 | +** For authentication and encryption using TLS: |
| 57 | ++ |
| 58 | +[source,terminal] |
| 59 | +---- |
| 60 | +$ oc create secret -n <namespace> generic <secret_name> \ |
| 61 | + --from-literal=protocol=SSL \ |
| 62 | + --from-file=ca.crt=<my_caroot.pem_file_path> \ <1> |
| 63 | + --from-file=user.crt=<my_cert.pem_file_path> \ |
| 64 | + --from-file=user.key=<my_key.pem_file_path> |
| 65 | +---- |
| 66 | +<1> The `ca.crt` can be omitted to use the system's root CA set if you are using a public cloud managed Kafka service, such as Red Hat OpenShift Streams for Apache Kafka. |
| 67 | + |
| 68 | +. Create or modify a `KafkaSink` object and add a reference to your secret in the `auth` spec: |
| 69 | ++ |
| 70 | +[source,yaml] |
| 71 | +---- |
| 72 | +apiVersion: eventing.knative.dev/v1alpha1 |
| 73 | +kind: KafkaSink |
| 74 | +metadata: |
| 75 | + name: <sink_name> |
| 76 | + namespace: <namespace> |
| 77 | +spec: |
| 78 | +... |
| 79 | + auth: |
| 80 | + secret: |
| 81 | + ref: |
| 82 | + name: <secret_name> |
| 83 | +... |
| 84 | +---- |
| 85 | + |
| 86 | +. Apply the `KafkaSink` object: |
| 87 | ++ |
| 88 | +[source,terminal] |
| 89 | +---- |
| 90 | +$ oc apply -f <filename> |
| 91 | +---- |
0 commit comments