use of io.strimzi.api.kafka.model.connect.ExternalConfiguration in project strimzi by strimzi.
the class KafkaConnectCluster method fromSpec.
/**
* Abstracts the calling of setters on a (subclass of) KafkaConnectCluster
* from the instantiation of the (subclass of) KafkaConnectCluster,
* thus permitting reuse of the setter-calling code for subclasses.
*/
protected static <C extends KafkaConnectCluster> C fromSpec(Reconciliation reconciliation, KafkaConnectSpec spec, KafkaVersion.Lookup versions, C kafkaConnect) {
kafkaConnect.setReplicas(spec.getReplicas() != null && spec.getReplicas() >= 0 ? spec.getReplicas() : DEFAULT_REPLICAS);
kafkaConnect.tracing = spec.getTracing();
AbstractConfiguration config = kafkaConnect.getConfiguration();
if (config == null) {
config = new KafkaConnectConfiguration(reconciliation, spec.getConfig().entrySet());
kafkaConnect.setConfiguration(config);
}
if (kafkaConnect.tracing != null) {
config.setConfigOption("consumer.interceptor.classes", "io.opentracing.contrib.kafka.TracingConsumerInterceptor");
config.setConfigOption("producer.interceptor.classes", "io.opentracing.contrib.kafka.TracingProducerInterceptor");
}
if (kafkaConnect.getImage() == null) {
kafkaConnect.setImage(versions.kafkaConnectVersion(spec.getImage(), spec.getVersion()));
}
kafkaConnect.setResources(spec.getResources());
kafkaConnect.setLogging(spec.getLogging());
kafkaConnect.setGcLoggingEnabled(spec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : spec.getJvmOptions().isGcLoggingEnabled());
if (spec.getJvmOptions() != null) {
kafkaConnect.setJavaSystemProperties(spec.getJvmOptions().getJavaSystemProperties());
}
kafkaConnect.setJvmOptions(spec.getJvmOptions());
if (spec.getJmxOptions() != null) {
kafkaConnect.setJmxEnabled(Boolean.TRUE);
AuthenticationUtils.configureKafkaConnectJmxOptions(spec.getJmxOptions().getAuthentication(), kafkaConnect);
}
if (spec.getReadinessProbe() != null) {
kafkaConnect.setReadinessProbe(spec.getReadinessProbe());
}
if (spec.getLivenessProbe() != null) {
kafkaConnect.setLivenessProbe(spec.getLivenessProbe());
}
kafkaConnect.setRack(spec.getRack());
String initImage = spec.getClientRackInitImage();
if (initImage == null) {
initImage = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_KAFKA_INIT_IMAGE, "quay.io/strimzi/operator:latest");
}
kafkaConnect.setInitImage(initImage);
// Parse different types of metrics configurations
ModelUtils.parseMetrics(kafkaConnect, spec);
kafkaConnect.setBootstrapServers(spec.getBootstrapServers());
kafkaConnect.setTls(spec.getTls());
String warnMsg = AuthenticationUtils.validateClientAuthentication(spec.getAuthentication(), spec.getTls() != null);
if (!warnMsg.isEmpty()) {
LOGGER.warnCr(reconciliation, warnMsg);
}
kafkaConnect.setAuthentication(spec.getAuthentication());
if (spec.getTemplate() != null) {
KafkaConnectTemplate template = spec.getTemplate();
ModelUtils.parseDeploymentTemplate(kafkaConnect, template.getDeployment());
ModelUtils.parsePodTemplate(kafkaConnect, template.getPod());
ModelUtils.parseInternalServiceTemplate(kafkaConnect, template.getApiService());
if (template.getClusterRoleBinding() != null && template.getClusterRoleBinding().getMetadata() != null) {
kafkaConnect.templateClusterRoleBindingLabels = template.getClusterRoleBinding().getMetadata().getLabels();
kafkaConnect.templateClusterRoleBindingAnnotations = template.getClusterRoleBinding().getMetadata().getAnnotations();
}
if (template.getConnectContainer() != null && template.getConnectContainer().getEnv() != null) {
kafkaConnect.templateContainerEnvVars = template.getConnectContainer().getEnv();
}
if (template.getInitContainer() != null && template.getInitContainer().getEnv() != null) {
kafkaConnect.templateInitContainerEnvVars = template.getInitContainer().getEnv();
}
if (template.getConnectContainer() != null && template.getConnectContainer().getSecurityContext() != null) {
kafkaConnect.templateContainerSecurityContext = template.getConnectContainer().getSecurityContext();
}
if (template.getInitContainer() != null && template.getInitContainer().getSecurityContext() != null) {
kafkaConnect.templateInitContainerSecurityContext = template.getInitContainer().getSecurityContext();
}
if (template.getServiceAccount() != null && template.getServiceAccount().getMetadata() != null) {
kafkaConnect.templateServiceAccountLabels = template.getServiceAccount().getMetadata().getLabels();
kafkaConnect.templateServiceAccountAnnotations = template.getServiceAccount().getMetadata().getAnnotations();
}
if (template.getJmxSecret() != null && template.getJmxSecret().getMetadata() != null) {
kafkaConnect.templateJmxSecretLabels = template.getJmxSecret().getMetadata().getLabels();
kafkaConnect.templateJmxSecretAnnotations = template.getJmxSecret().getMetadata().getAnnotations();
}
ModelUtils.parsePodDisruptionBudgetTemplate(kafkaConnect, template.getPodDisruptionBudget());
}
if (spec.getExternalConfiguration() != null) {
ExternalConfiguration externalConfiguration = spec.getExternalConfiguration();
if (externalConfiguration.getEnv() != null && !externalConfiguration.getEnv().isEmpty()) {
kafkaConnect.externalEnvs = externalConfiguration.getEnv();
}
if (externalConfiguration.getVolumes() != null && !externalConfiguration.getVolumes().isEmpty()) {
kafkaConnect.externalVolumes = externalConfiguration.getVolumes();
}
}
kafkaConnect.templatePodLabels = Util.mergeLabelsOrAnnotations(kafkaConnect.templatePodLabels, DEFAULT_POD_LABELS);
return kafkaConnect;
}
use of io.strimzi.api.kafka.model.connect.ExternalConfiguration in project strimzi-kafka-operator by strimzi.
the class KafkaConnectCluster method fromSpec.
/**
* Abstracts the calling of setters on a (subclass of) KafkaConnectCluster
* from the instantiation of the (subclass of) KafkaConnectCluster,
* thus permitting reuse of the setter-calling code for subclasses.
*/
protected static <C extends KafkaConnectCluster> C fromSpec(Reconciliation reconciliation, KafkaConnectSpec spec, KafkaVersion.Lookup versions, C kafkaConnect) {
kafkaConnect.setReplicas(spec.getReplicas() != null && spec.getReplicas() >= 0 ? spec.getReplicas() : DEFAULT_REPLICAS);
kafkaConnect.tracing = spec.getTracing();
AbstractConfiguration config = kafkaConnect.getConfiguration();
if (config == null) {
config = new KafkaConnectConfiguration(reconciliation, spec.getConfig().entrySet());
kafkaConnect.setConfiguration(config);
}
if (kafkaConnect.tracing != null) {
config.setConfigOption("consumer.interceptor.classes", "io.opentracing.contrib.kafka.TracingConsumerInterceptor");
config.setConfigOption("producer.interceptor.classes", "io.opentracing.contrib.kafka.TracingProducerInterceptor");
}
if (kafkaConnect.getImage() == null) {
kafkaConnect.setImage(versions.kafkaConnectVersion(spec.getImage(), spec.getVersion()));
}
kafkaConnect.setResources(spec.getResources());
kafkaConnect.setLogging(spec.getLogging());
kafkaConnect.setGcLoggingEnabled(spec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : spec.getJvmOptions().isGcLoggingEnabled());
if (spec.getJvmOptions() != null) {
kafkaConnect.setJavaSystemProperties(spec.getJvmOptions().getJavaSystemProperties());
}
kafkaConnect.setJvmOptions(spec.getJvmOptions());
if (spec.getJmxOptions() != null) {
kafkaConnect.setJmxEnabled(Boolean.TRUE);
AuthenticationUtils.configureKafkaConnectJmxOptions(spec.getJmxOptions().getAuthentication(), kafkaConnect);
}
if (spec.getReadinessProbe() != null) {
kafkaConnect.setReadinessProbe(spec.getReadinessProbe());
}
if (spec.getLivenessProbe() != null) {
kafkaConnect.setLivenessProbe(spec.getLivenessProbe());
}
kafkaConnect.setRack(spec.getRack());
String initImage = spec.getClientRackInitImage();
if (initImage == null) {
initImage = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_KAFKA_INIT_IMAGE, "quay.io/strimzi/operator:latest");
}
kafkaConnect.setInitImage(initImage);
// Parse different types of metrics configurations
ModelUtils.parseMetrics(kafkaConnect, spec);
kafkaConnect.setBootstrapServers(spec.getBootstrapServers());
kafkaConnect.setTls(spec.getTls());
String warnMsg = AuthenticationUtils.validateClientAuthentication(spec.getAuthentication(), spec.getTls() != null);
if (!warnMsg.isEmpty()) {
LOGGER.warnCr(reconciliation, warnMsg);
}
kafkaConnect.setAuthentication(spec.getAuthentication());
if (spec.getTemplate() != null) {
KafkaConnectTemplate template = spec.getTemplate();
ModelUtils.parseDeploymentTemplate(kafkaConnect, template.getDeployment());
ModelUtils.parsePodTemplate(kafkaConnect, template.getPod());
ModelUtils.parseInternalServiceTemplate(kafkaConnect, template.getApiService());
if (template.getClusterRoleBinding() != null && template.getClusterRoleBinding().getMetadata() != null) {
kafkaConnect.templateClusterRoleBindingLabels = template.getClusterRoleBinding().getMetadata().getLabels();
kafkaConnect.templateClusterRoleBindingAnnotations = template.getClusterRoleBinding().getMetadata().getAnnotations();
}
if (template.getConnectContainer() != null && template.getConnectContainer().getEnv() != null) {
kafkaConnect.templateContainerEnvVars = template.getConnectContainer().getEnv();
}
if (template.getInitContainer() != null && template.getInitContainer().getEnv() != null) {
kafkaConnect.templateInitContainerEnvVars = template.getInitContainer().getEnv();
}
if (template.getConnectContainer() != null && template.getConnectContainer().getSecurityContext() != null) {
kafkaConnect.templateContainerSecurityContext = template.getConnectContainer().getSecurityContext();
}
if (template.getInitContainer() != null && template.getInitContainer().getSecurityContext() != null) {
kafkaConnect.templateInitContainerSecurityContext = template.getInitContainer().getSecurityContext();
}
if (template.getServiceAccount() != null && template.getServiceAccount().getMetadata() != null) {
kafkaConnect.templateServiceAccountLabels = template.getServiceAccount().getMetadata().getLabels();
kafkaConnect.templateServiceAccountAnnotations = template.getServiceAccount().getMetadata().getAnnotations();
}
if (template.getJmxSecret() != null && template.getJmxSecret().getMetadata() != null) {
kafkaConnect.templateJmxSecretLabels = template.getJmxSecret().getMetadata().getLabels();
kafkaConnect.templateJmxSecretAnnotations = template.getJmxSecret().getMetadata().getAnnotations();
}
ModelUtils.parsePodDisruptionBudgetTemplate(kafkaConnect, template.getPodDisruptionBudget());
}
if (spec.getExternalConfiguration() != null) {
ExternalConfiguration externalConfiguration = spec.getExternalConfiguration();
if (externalConfiguration.getEnv() != null && !externalConfiguration.getEnv().isEmpty()) {
kafkaConnect.externalEnvs = externalConfiguration.getEnv();
}
if (externalConfiguration.getVolumes() != null && !externalConfiguration.getVolumes().isEmpty()) {
kafkaConnect.externalVolumes = externalConfiguration.getVolumes();
}
}
kafkaConnect.templatePodLabels = Util.mergeLabelsOrAnnotations(kafkaConnect.templatePodLabels, DEFAULT_POD_LABELS);
return kafkaConnect;
}
Aggregations