Apache Kafka (cluster)
Deploy Apache Kafka, a robust, scalable, and high-performance system for managing real-time data streams. Kafka provides a reliable foundation for data pipelines, event-driven architectures, and stream processing applications, from log aggregation to real-time analytics.
This app deploys a Kafka cluster using Kafka's native consensus protocol, KRaft. A few things to note about the deployment:
- The cluster is configured with mTLS for authentication. Inter-broker communication and client authentication are established via certificate identity.
- The minimum cluster size is three, with three controllers configured at all times for fault tolerance.
- Clients connecting to the cluster need their own valid certificate. All certificates are signed with a self-signed Certificate Authority (CA). Client keystores and the truststore are on the first Kafka node in
/etc/kafka/ssl/keystoreand/etc/kafka/ssl/truststore. - The CA key and certificate pair are on the first Kafka node in
/etc/kafka/ssl/ca.
Cluster deploymentThis app deploys three, five, or seven Linode instances to create a distributed Apache Kafka cluster, each with the plan type and size you select.
Each of these Linode instances will appear on your invoice as separate items.
1. Deploy Apache Kafka cluster
clusterFollow the deployment instructions from the Get started section to configure the app, deploy it, and verify software installation.
For information on the app-specific configurations, see the Configuration options section.
Software included
Software installed on your Linode when deploying the app.
| Package | Description |
|---|---|
| Apache Kafka | A scalable, high-performance, fault-tolerant stream processing application. |
| KRaft | A Kafka native consensus protocol. |
| UFW (Uncomplicated Firewall) | A firewall utility. |
| Fail2ban | A brute force protection utility. |
Base distribution and plan
- Supported distribution: Ubuntu 24.04 LTS
- Recommended plan: All plan types and sizes can be used depending on your storage needs.
Configuration options
Configure the required options to deploy your instance. For additional customization, add advanced options.
The table maps the Cloud Manager UI fields to their corresponding API/CLI keys (stackscript_data) required for automated deployments.
StackScript ID: 1377657
| UI field | API/CLI key | Description |
|---|---|---|
| Required options | ||
| Linode API token | token_password | A valid Linode API token used to deploy the additional Linode instances that make up this cluster. Follow Manage personal access tokens to get the token on your account with Read/Write access to Linodes. |
| Limited sudo user | sudo_username | Your preferred username for the limited sudo user, entered without any capital letters, spaces, or special characters. When adding a limited sudo user, the user is created with a strong generated password for your new Linode instance, and the account is assigned to the sudo group, which provides elevated permissions when running commands with the sudo prefix.Note: For easier and more secure access with the sudo user, add an account SSH key for the Cloud Manager user during deployment and select that user as an |
| Number of clients connecting to Kafka | client_count | The number of clients that will connect to the Kafka cluster. SSL certificates are created for each client. Must be an integer of 1 or greater. |
| Kafka cluster size | cluster_size | The number of Linode instances created as part of this cluster. Possible values are 3, 5, or 7. |
| SSL Information | sslheader | Set to Yes by default. This requires providing details for a self-signed TLS/SSL certificate, like country, town, organization, and email address. |
| Country or region | country_name | Applies to a self-signed TLS/SSL certificate. The country or region for you or your organization. When using the API/CLI, specify it as a two-letter ISO country or region code. |
| State or province | state_or_province_name | Applies to a self-signed TLS/SSL certificate. The state or province for you or your organization. |
| Locality | locality_name | Applies to a self-signed TLS/SSL certificate. The town or other locality for you or your organization. |
| Organization | organization_name | Applies to a self-signed TLS/SSL certificate. The name of your organization. |
| Email address | email_address | Applies to a self-signed TLS/SSL certificate. The email address you want to use for your certificate file. |
| CA Common Name | ca_common_name | Applies to a self-signed TLS/SSL certificate. The common name for the self-signed Certificate Authority (CA). For example, Kafka RootCA. |
| Advanced options | ||
| Kafka version | kafka_version | The version of Kafka to install. Defaults to 3.8.0. |
| Cluster Settings | clusterheader | Set to Yes by default. Details of the cluster settings, including whether to add account SSH keys to all nodes. |
| Add Account SSH Keys to All Nodes | add_ssh_keys | When set to yes, any SSH Keys that are added to the root user account (in the SSH Keys section) are also added to your limited user account on all deployed Linode instances. Possible values are yes or no. Defaults to yes. |
Note: After the app deployment completes, the password for your limited sudo user is generated and stored in the
.credentialsfile in the home directory, along with application-specific passwords. Log in to your instance asrootthrough the Lish console or SSH, then runcat /home/$USERNAME/.credentialsto view its contents.
Use API, CLI, or Terraform
In addition to deploying the app to a new Linode instance via Cloud Manager, you can also use the Linode API, CLI, or Terraform. When running the operation, you need to provide the StackScript ID, supported Linux distribution, and app-specific fields along with the standard Linode deployment configurations.
Note: Generate a personal access token to authenticate your API, CLI, or Terraform requests.
curl --location 'https://api.linode.com/v4/linode/instances' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer abc123def456hij789klm' \
--data-raw '{
"region": "us-east",
"type": "g6-standard-4",
"image": "linode/ubuntu24.04",
"label": "my-kafka-cluster-one-click-app",
"root_pass": "@C0mpl3x#P@ssw0rd",
"stackscript_id": 1377657,
"stackscript_data": {
"token_password": "abc123def456hij789klm",
"sudo_username": "jsmith",
"client_count": "1",
"cluster_size": "5",
"country_name": "US",
"state_or_province_name": "Massachusetts",
"locality_name": "Cambridge",
"organization_name": "Akamai Technologies",
"email_address": "jsmith@example.com",
"ca_common_name": "Kafka RootCA"
}
}'linode-cli linodes create \
--region us-east \
--type g6-standard-4 \
--label my-kafka-cluster-one-click-app \
--image linode/ubuntu24.04 \
--root_pass @C0mpl3x#P@ssw0rd \
--stackscript_id 1377657 \
--stackscript_data '{"token_password":"abc123def456hij789klm", "sudo_username":"jsmith", "client_count":"1", "cluster_size":"5", "country_name":"US", "state_or_province_name":"Massachusetts", "locality_name":"Cambridge", "organization_name":"Akamai Technologies", "email_address":"jsmith@example.com", "ca_common_name":"Kafka RootCA"}'resource "linode_instance" "my-linode" {
region = "us-east"
type = "g6-standard-4"
label = "my-kafka-cluster-one-click-app"
image = "linode/ubuntu24.04"
root_pass = "@C0mpl3x#P@ssw0rd"
stackscript_id = 1377657
stackscript_data = {
"token_password" = "abc123def456hij789klm"
"sudo_username" = "jsmith"
"client_count" = "1"
"cluster_size" = "5"
"country_name" = "US"
"state_or_province_name" = "Massachusetts"
"locality_name" = "Cambridge"
"organization_name" = "Akamai Technologies"
"email_address" = "jsmith@example.com"
"ca_common_name" = "Kafka RootCA"
}
}2. Connect to Kafka
Get the keystore and truststore
Once the deployment is complete, get your client certificates from the first Kafka node.
Authenticating clients requires a keystore and truststore. Access the first Kafka server to get these from /etc/kafka/ssl/keystore and /etc/kafka/ssl/truststore. Client certificates start with the word client followed by a number, depending on the number of clients requested, for example client1 and client2.
Use a secure method such as SSH or an encrypted HTTPS web UI when transferring the client certificates to the Kafka consumer/producer
Test the cluster
Run a quick test from any of the Kafka nodes using Kafka's utilities found in /etc/kafka/bin.
-
Create a
client.propertiesfile with the following content, replacing the placeholder values with your own:security.protocol=SSL ssl.truststore.location=/etc/kafka/ssl/truststore/server.truststore.jks ssl.truststore.password=CHANGE-ME ssl.keystore.location=/etc/kafka/ssl/keystore/client1.keystore.jks ssl.keystore.password=CHANGE-ME -
Create a topic to test the connection and authentication.
The output returns a message confirming the topic with the specified name was created.
/etc/kafka/bin/kafka-topics.sh --create --topic test-ssl --bootstrap-server kafka3:9092 --command-config client.propertiesCreated topic test-ssl. -
Publish a message to the topic as a producer.
echo "Kafka rocks!" | /etc/kafka/bin/kafka-console-producer.sh --topic test-ssl --bootstrap-server kafka3:9092 --producer.config client.properties -
Read the message as a consumer.
The output returns the previously published message.
/etc/kafka/bin/kafka-console-consumer.sh --topic test-ssl --from-beginning --bootstrap-server kafka3:9092 --consumer.config client.propertiesKafka rocks!
Additional resources
For more information about the installed packages, see their official documentation.
Note that we can't vouch for the accuracy or timeliness of externally hosted resources.
Updated 14 days ago
