Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MGDSTRM-8601- Allow configuration of Kafka exporter image via bundle #758

Merged
merged 5 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public static class OperandOverrides {

@JsonProperty(value = "zookeeper")
public OperandOverride zookeeper = new OperandOverride();

@JsonProperty(value = "kafka-exporter")
public OperandOverride kafkaExporter = new OperandOverride();
}

static final OperandOverrides EMPTY = new OperandOverrides();
Expand All @@ -139,6 +142,9 @@ public static class OperandOverrides {
@ConfigProperty(name = "image.zookeeper")
Optional<String> zookeeperImage;

@ConfigProperty(name = "image.kafka-exporter")
Optional<String> kafkaExporterImage;

@Inject
KubernetesClient kubernetesClient;

Expand Down Expand Up @@ -216,6 +222,12 @@ public Optional<String> getZookeeperImage(String strimzi) {
return getImage(getZookeeperOverride(strimzi), strimzi, "zookeeper").or(() -> zookeeperImage);
}

public OperandOverride getKafkaExporterOverride(String strimzi) { return getOverrides(strimzi).kafkaExporter; }

public Optional<String> getKafkaExporterImage(String strimzi) {
return getImage(getKafkaExporterOverride(strimzi), strimzi, "kafka-exporter").or(() -> kafkaExporterImage);
}

Optional<String> getImage(OperandOverride override, String strimzi, String componentName) {
return Optional.ofNullable(override.getImage())
.or(() -> {
Expand Down
10 changes: 10 additions & 0 deletions operator/src/main/java/org/bf2/operator/operands/KafkaCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,21 @@ private JvmOptions buildZooKeeperJvmOptions(ManagedKafka managedKafka) {

private KafkaExporterSpec buildKafkaExporter(ManagedKafka managedKafka) {
ConfigMap configMap = cachedConfigMap(managedKafka, kafkaExporterLoggingConfigMapName(managedKafka));
String strimzi = managedKafka.getSpec().getVersions().getStrimzi();
KafkaInstanceConfiguration config = this.configs.getConfig(managedKafka);
KafkaExporterSpecBuilder specBuilder = new KafkaExporterSpecBuilder()
.withTopicRegex(".*")
.withGroupRegex(".*")
.withImage(this.overrideManager.getKafkaExporterImage(strimzi).orElse(null))
biswassri marked this conversation as resolved.
Show resolved Hide resolved
.withResources(config.getExporter().buildResources());
var pullSecrets = imagePullSecretManager.getOperatorImagePullSecrets(managedKafka);
if (!pullSecrets.isEmpty()) {
specBuilder.editOrNewTemplate()
.editOrNewPod()
.withImagePullSecrets(pullSecrets)
.endPod()
.endTemplate();
}

if (configMap != null) {
String logLevel = configMap.getData().get(KAFKA_EXPORTER_LOG_LEVEL);
Expand Down
4 changes: 4 additions & 0 deletions operator/src/test/resources/expected/strimzi_su2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ spec:
requests:
memory: "256Mi"
cpu: "500m"
template:
pod:
imagePullSecrets:
- name: "myimage:0.0.1"
cruiseControl:
resources:
limits:
Expand Down