Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit b6da752

Browse files
Merge pull request #13 from santosh-philips/25681-Kafka-Update-Config
Added kafka message related property configuration
2 parents 3b1e842 + e46bfe0 commit b6da752

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# HSDP Kafka module
44

55
Module to create an Apache kafka cluster deployed
6-
on the HSDP Container Host infrastructure. This module serves as a
6+
on the HSDP Container Host infrastructure. This module serves as a
77
blueprint for future HSDP Container Host modules. Example usage
88

99
```hcl
@@ -31,15 +31,16 @@ module "kafka" {
3131
zoo_key_store = {
3232
keystore = "./zookeystore.jks"
3333
password = "somepass"
34-
}
34+
}
35+
max_request_size = 1048576
3536
}
3637
```
3738

3839
__IMPORTANT SECURITY INFORMATION__
3940
> This module currently **enables** only mTLS-SSL
4041
> between Kafka, Zookeeper or any connecting client apps.
4142
> Operating and maintaining applications on Container Host is always
42-
> your responsibility. This includes ensuring any security
43+
> your responsibility. This includes ensuring any security
4344
> measures are in place in case you need them.
4445
4546
## Requirements
@@ -84,6 +85,8 @@ __IMPORTANT SECURITY INFORMATION__
8485
| zoo\_key\_store | Zookeeper Key store for SSL | <pre>object(<br> { keystore = string,<br> password = string }<br> )</pre> | n/a | yes |
8586
| zoo\_trust\_store | Zookeeper Trust store for SSL | <pre>object(<br> { truststore = string,<br> password = string }<br> )</pre> | n/a | yes |
8687
| zookeeper\_connect | Zookeeper connect string to use | `string` | n/a | yes |
88+
| max\_request\_size | Maximum request size of a message supported in broker | `number` | n/a | no |
89+
| max\_partition\_fetch\_bytes | The maximum amount of data per-partition the broker will return | `number` | n/a | no |
8790

8891
Incase you are wondering why we need zookeeper key store, its required by bitnami please refer to bitnami documentation.
8992

@@ -128,7 +131,7 @@ openssl pkcs12 -in $inputJksFilename -out $outputPublicKeyFilename -clcerts -nok
128131
129132
#Export the private key with the PEM format
130133
keytool -importkeystore -srckeystore $inputJksFilename -destkeystore tempKeyStore.p12 -deststoretype PKCS12 -srcstorepass $inputKeyStorePassword -deststorepass $inputKeyStorePassword -noprompt
131-
openssl pkcs12 -in tempKeyStore.p12 -nodes -nocerts -out $outputPrivateKeyFilename -passin pass:$inputKeyStorePassword -passout pass:$inputKeyStorePassword
134+
openssl pkcs12 -in tempKeyStore.p12 -nodes -nocerts -out $outputPrivateKeyFilename -passin pass:$inputKeyStorePassword -passout pass:$inputKeyStorePassword
132135
```
133136

134137

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ resource "hsdp_container_host_exec" "cluster" {
102102
commands = [
103103
"chmod +x /home/${var.user}/bootstrap-cluster.sh",
104104
"chmod 755 /home/${var.user}/jmxconfig.yml.tmpl",
105-
"/home/${var.user}/bootstrap-cluster.sh -n ${join(",", hsdp_container_host.kafka.*.private_ip)} -c ${random_id.id.hex} -d ${var.image} -i ${count.index + 1} -z ${var.zookeeper_connect} -x ${element(hsdp_container_host.kafka.*.private_ip, count.index)} -r \"${var.retention_hours}\" -p ${var.kafka_key_store.password} -t ${var.zoo_trust_store.password} -k ${var.zoo_key_store.password} -R ${var.default_replication_factor} -a ${var.auto_create_topics_enable} -e ${var.enable_exporters}"
105+
"/home/${var.user}/bootstrap-cluster.sh -n ${join(",", hsdp_container_host.kafka.*.private_ip)} -c ${random_id.id.hex} -d ${var.image} -i ${count.index + 1} -z ${var.zookeeper_connect} -x ${element(hsdp_container_host.kafka.*.private_ip, count.index)} -r \"${var.retention_hours}\" -p ${var.kafka_key_store.password} -t ${var.zoo_trust_store.password} -k ${var.zoo_key_store.password} -R ${var.default_replication_factor} -a ${var.auto_create_topics_enable} -e ${var.enable_exporters} -m ${var.max_request_size} -f ${var.max_partition_fetch_bytes}"
106106
]
107-
}
107+
}

scripts/bootstrap-cluster.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ usage: bootstrap-cluster.sh
1616
-R default_replication_factor
1717
-a auto_create_topics_enable
1818
-e enable_exporters
19+
-m max-request-size
20+
-f max-partition-fetch-bytes
1921
EOF
2022
}
2123

@@ -80,6 +82,8 @@ start_kafka() {
8082
local zoo_trust_pass="$9"
8183
local default_replication_factor="${10}"
8284
local auto_create_topics_enable="${11}"
85+
local max-request-size="${12}"
86+
local max-partition-fetch-bytes="${13}"
8387

8488
servers="$(kafka_servers "$index" "$nodes")"
8589
echo KAFKA_SERVERS="$servers"
@@ -104,6 +108,8 @@ start_kafka() {
104108
--env JMX_PORT=5555 \
105109
--env KAFKA_CFG_DEFAULT_REPLICATION_FACTOR=$default_replication_factor \
106110
--env KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=$auto_create_topics_enable \
111+
--env KAFKA_CFG_MAX_REQUEST_SIZE=$max-request-size \
112+
--env KAFKA_CFG_MAX_PARTITION_FETCH_BYTES=$max-partition-fetch-bytes \
107113
--network $kafka_network \
108114
-v $kafka_broker_name:/bitnami/kafka \
109115
-v 'kafkacert:/bitnami/kafka/config/certs/' \
@@ -133,7 +139,7 @@ start_jmx_exporter(){
133139
# Substitute container name in jmx config and move it
134140
export container_name=$kafka_broker_name
135141
envsubst < jmxconfig.yml.tmpl > ./jmx/config.yml
136-
142+
137143
# create jmx volume mapping the jmx config file
138144
docker volume create --driver local --name jmx_config_volume --opt type=none --opt device=`pwd`/jmx --opt o=uid=root,gid=root --opt o=bind
139145

@@ -187,6 +193,8 @@ zoo_trust_store_pass=
187193
default_replication_factor=
188194
auto_create_topics_enable=
189195
enable_exporters=
196+
max-request-size=
197+
max-partition-fetch-bytes=
190198

191199
while [ "$1" != "" ]; do
192200
case $1 in
@@ -226,6 +234,12 @@ while [ "$1" != "" ]; do
226234
-a | --auto-create-topics ) shift
227235
auto_create_topics_enable=$1
228236
;;
237+
-m | --max-request-size ) shift
238+
max-request-size=$1
239+
;;
240+
-f | --max-partition-fetch-bytes ) shift
241+
max-partition-fetch-bytes=$1
242+
;;
229243
-e | --enable-exporters ) shift
230244
enable_exporters=$1
231245
;;
@@ -246,7 +260,7 @@ kill_monitoring
246260
kill_kafka
247261
create_volume
248262
create_network
249-
start_kafka "$index" "$nodes" "$image" "$zookeeper_connect" "$external_ip" "$retention_hours" "$kafka_cert_pass" "$zoo_key_store_pass" "$zoo_trust_store_pass" "$default_replication_factor" "$auto_create_topics_enable"
263+
start_kafka "$index" "$nodes" "$image" "$zookeeper_connect" "$external_ip" "$retention_hours" "$kafka_cert_pass" "$zoo_key_store_pass" "$zoo_trust_store_pass" "$default_replication_factor" "$auto_create_topics_enable" "$max-request-size" "$max-partition-fetch-bytes"
250264
load_certificates_and_restart
251265

252266
if [ "$enable_exporters" == true ]; then
@@ -258,4 +272,4 @@ sleep 30 # wait for 5 seconds to print out docker status
258272
docker ps -a
259273
docker start kafka_prometheus_exporter
260274
sleep 15
261-
docker ps -a
275+
docker ps -a

variables.tf

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,24 @@ variable "kafka_public_key" {
130130

131131
variable "kafka_private_key" {
132132
description = "Private Key for SSL (only applicable when exporter is required, so only when 'enable_exporters==true')"
133-
default = ""
133+
default = ""
134134
type = string
135135
}
136136

137137
variable "enable_exporters" {
138138
description = "Indicates whether jmx exporter and kafka exporter is enabled or not"
139139
default = false
140-
type = bool
141-
}
140+
type = bool
141+
}
142+
143+
variable "max_request_size" {
144+
description = "The maximum size of a request in bytes"
145+
default = 1048576
146+
type = number
147+
}
148+
149+
variable "max_partition_fetch_bytes" {
150+
description = "The maximum amount of data per-partition the server will return"
151+
default = 1048576
152+
type = number
153+
}

0 commit comments

Comments
 (0)