Search in sources :

Example 1 with KafkaMirrorMaker2Spec

use of io.strimzi.api.kafka.model.KafkaMirrorMaker2Spec in project strimzi-kafka-operator by strimzi.

the class KafkaMirrorMaker2Cluster method fromCrd.

/**
 * Creates instance of KafkaMirrorMaker2Cluster from CRD definition.
 *
 * @param reconciliation    The reconciliation
 * @param kafkaMirrorMaker2 The Custom Resource based on which the cluster model should be created.
 * @param versions The image versions for MirrorMaker 2.0 clusters.
 * @return The MirrorMaker 2.0 cluster model.
 */
public static KafkaMirrorMaker2Cluster fromCrd(Reconciliation reconciliation, KafkaMirrorMaker2 kafkaMirrorMaker2, KafkaVersion.Lookup versions) {
    KafkaMirrorMaker2Cluster cluster = new KafkaMirrorMaker2Cluster(reconciliation, kafkaMirrorMaker2);
    KafkaMirrorMaker2Spec spec = kafkaMirrorMaker2.getSpec();
    cluster.setOwnerReference(kafkaMirrorMaker2);
    cluster.setImage(versions.kafkaMirrorMaker2Version(spec.getImage(), spec.getVersion()));
    List<KafkaMirrorMaker2ClusterSpec> clustersList = ModelUtils.asListOrEmptyList(spec.getClusters());
    cluster.setClusters(clustersList);
    KafkaMirrorMaker2ClusterSpec connectCluster = new KafkaMirrorMaker2ClusterSpecBuilder().build();
    String connectClusterAlias = spec.getConnectCluster();
    if (connectClusterAlias != null) {
        connectCluster = clustersList.stream().filter(clustersListItem -> spec.getConnectCluster().equals(clustersListItem.getAlias())).findFirst().orElseThrow(() -> new InvalidResourceException("connectCluster with alias " + connectClusterAlias + " cannot be found in the list of clusters at spec.clusters"));
    }
    cluster.setConfiguration(new KafkaMirrorMaker2Configuration(reconciliation, connectCluster.getConfig().entrySet()));
    KafkaMirrorMaker2Cluster mm2 = fromSpec(reconciliation, buildKafkaConnectSpec(spec, connectCluster), versions, cluster);
    mm2.templatePodLabels = Util.mergeLabelsOrAnnotations(mm2.templatePodLabels, DEFAULT_POD_LABELS);
    return mm2;
}
Also used : VolumeMount(io.fabric8.kubernetes.api.model.VolumeMount) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) GenericSecretSource(io.strimzi.api.kafka.model.GenericSecretSource) HashMap(java.util.HashMap) KafkaClientAuthenticationPlain(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationPlain) Supplier(java.util.function.Supplier) KafkaConnectSpecBuilder(io.strimzi.api.kafka.model.KafkaConnectSpecBuilder) KafkaClientAuthenticationOAuth(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationOAuth) Map(java.util.Map) KafkaClientAuthenticationTls(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTls) Volume(io.fabric8.kubernetes.api.model.Volume) CertSecretSource(io.strimzi.api.kafka.model.CertSecretSource) KafkaMirrorMaker2ClusterSpec(io.strimzi.api.kafka.model.KafkaMirrorMaker2ClusterSpec) KafkaMirrorMaker2Spec(io.strimzi.api.kafka.model.KafkaMirrorMaker2Spec) KafkaClientAuthenticationScram(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationScram) ClientTls(io.strimzi.api.kafka.model.ClientTls) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) PasswordSecretSource(io.strimzi.api.kafka.model.PasswordSecretSource) KafkaMirrorMaker2Resources(io.strimzi.api.kafka.model.KafkaMirrorMaker2Resources) KafkaMirrorMaker2(io.strimzi.api.kafka.model.KafkaMirrorMaker2) Reconciliation(io.strimzi.operator.common.Reconciliation) List(java.util.List) Util(io.strimzi.operator.common.Util) KafkaMirrorMaker2ClusterSpecBuilder(io.strimzi.api.kafka.model.KafkaMirrorMaker2ClusterSpecBuilder) Entry(java.util.Map.Entry) KafkaConnectSpec(io.strimzi.api.kafka.model.KafkaConnectSpec) KafkaClientAuthentication(io.strimzi.api.kafka.model.authentication.KafkaClientAuthentication) KafkaMirrorMaker2Spec(io.strimzi.api.kafka.model.KafkaMirrorMaker2Spec) KafkaMirrorMaker2ClusterSpecBuilder(io.strimzi.api.kafka.model.KafkaMirrorMaker2ClusterSpecBuilder) KafkaMirrorMaker2ClusterSpec(io.strimzi.api.kafka.model.KafkaMirrorMaker2ClusterSpec)

Example 2 with KafkaMirrorMaker2Spec

use of io.strimzi.api.kafka.model.KafkaMirrorMaker2Spec in project strimzi by strimzi.

the class KafkaMirrorMaker2Cluster method fromCrd.

/**
 * Creates instance of KafkaMirrorMaker2Cluster from CRD definition.
 *
 * @param reconciliation    The reconciliation
 * @param kafkaMirrorMaker2 The Custom Resource based on which the cluster model should be created.
 * @param versions The image versions for MirrorMaker 2.0 clusters.
 * @return The MirrorMaker 2.0 cluster model.
 */
public static KafkaMirrorMaker2Cluster fromCrd(Reconciliation reconciliation, KafkaMirrorMaker2 kafkaMirrorMaker2, KafkaVersion.Lookup versions) {
    KafkaMirrorMaker2Cluster cluster = new KafkaMirrorMaker2Cluster(reconciliation, kafkaMirrorMaker2);
    KafkaMirrorMaker2Spec spec = kafkaMirrorMaker2.getSpec();
    cluster.setOwnerReference(kafkaMirrorMaker2);
    cluster.setImage(versions.kafkaMirrorMaker2Version(spec.getImage(), spec.getVersion()));
    List<KafkaMirrorMaker2ClusterSpec> clustersList = ModelUtils.asListOrEmptyList(spec.getClusters());
    cluster.setClusters(clustersList);
    KafkaMirrorMaker2ClusterSpec connectCluster = new KafkaMirrorMaker2ClusterSpecBuilder().build();
    String connectClusterAlias = spec.getConnectCluster();
    if (connectClusterAlias != null) {
        connectCluster = clustersList.stream().filter(clustersListItem -> spec.getConnectCluster().equals(clustersListItem.getAlias())).findFirst().orElseThrow(() -> new InvalidResourceException("connectCluster with alias " + connectClusterAlias + " cannot be found in the list of clusters at spec.clusters"));
    }
    cluster.setConfiguration(new KafkaMirrorMaker2Configuration(reconciliation, connectCluster.getConfig().entrySet()));
    KafkaMirrorMaker2Cluster mm2 = fromSpec(reconciliation, buildKafkaConnectSpec(spec, connectCluster), versions, cluster);
    mm2.templatePodLabels = Util.mergeLabelsOrAnnotations(mm2.templatePodLabels, DEFAULT_POD_LABELS);
    return mm2;
}
Also used : VolumeMount(io.fabric8.kubernetes.api.model.VolumeMount) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) GenericSecretSource(io.strimzi.api.kafka.model.GenericSecretSource) HashMap(java.util.HashMap) KafkaClientAuthenticationPlain(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationPlain) Supplier(java.util.function.Supplier) KafkaConnectSpecBuilder(io.strimzi.api.kafka.model.KafkaConnectSpecBuilder) KafkaClientAuthenticationOAuth(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationOAuth) Map(java.util.Map) KafkaClientAuthenticationTls(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTls) Volume(io.fabric8.kubernetes.api.model.Volume) CertSecretSource(io.strimzi.api.kafka.model.CertSecretSource) KafkaMirrorMaker2ClusterSpec(io.strimzi.api.kafka.model.KafkaMirrorMaker2ClusterSpec) KafkaMirrorMaker2Spec(io.strimzi.api.kafka.model.KafkaMirrorMaker2Spec) KafkaClientAuthenticationScram(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationScram) ClientTls(io.strimzi.api.kafka.model.ClientTls) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) PasswordSecretSource(io.strimzi.api.kafka.model.PasswordSecretSource) KafkaMirrorMaker2Resources(io.strimzi.api.kafka.model.KafkaMirrorMaker2Resources) KafkaMirrorMaker2(io.strimzi.api.kafka.model.KafkaMirrorMaker2) Reconciliation(io.strimzi.operator.common.Reconciliation) List(java.util.List) Util(io.strimzi.operator.common.Util) KafkaMirrorMaker2ClusterSpecBuilder(io.strimzi.api.kafka.model.KafkaMirrorMaker2ClusterSpecBuilder) Entry(java.util.Map.Entry) KafkaConnectSpec(io.strimzi.api.kafka.model.KafkaConnectSpec) KafkaClientAuthentication(io.strimzi.api.kafka.model.authentication.KafkaClientAuthentication) KafkaMirrorMaker2Spec(io.strimzi.api.kafka.model.KafkaMirrorMaker2Spec) KafkaMirrorMaker2ClusterSpecBuilder(io.strimzi.api.kafka.model.KafkaMirrorMaker2ClusterSpecBuilder) KafkaMirrorMaker2ClusterSpec(io.strimzi.api.kafka.model.KafkaMirrorMaker2ClusterSpec)

Aggregations

EnvVar (io.fabric8.kubernetes.api.model.EnvVar)2 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)2 Volume (io.fabric8.kubernetes.api.model.Volume)2 VolumeMount (io.fabric8.kubernetes.api.model.VolumeMount)2 CertSecretSource (io.strimzi.api.kafka.model.CertSecretSource)2 ClientTls (io.strimzi.api.kafka.model.ClientTls)2 GenericSecretSource (io.strimzi.api.kafka.model.GenericSecretSource)2 KafkaConnectSpec (io.strimzi.api.kafka.model.KafkaConnectSpec)2 KafkaConnectSpecBuilder (io.strimzi.api.kafka.model.KafkaConnectSpecBuilder)2 KafkaMirrorMaker2 (io.strimzi.api.kafka.model.KafkaMirrorMaker2)2 KafkaMirrorMaker2ClusterSpec (io.strimzi.api.kafka.model.KafkaMirrorMaker2ClusterSpec)2 KafkaMirrorMaker2ClusterSpecBuilder (io.strimzi.api.kafka.model.KafkaMirrorMaker2ClusterSpecBuilder)2 KafkaMirrorMaker2Resources (io.strimzi.api.kafka.model.KafkaMirrorMaker2Resources)2 KafkaMirrorMaker2Spec (io.strimzi.api.kafka.model.KafkaMirrorMaker2Spec)2 PasswordSecretSource (io.strimzi.api.kafka.model.PasswordSecretSource)2 KafkaClientAuthentication (io.strimzi.api.kafka.model.authentication.KafkaClientAuthentication)2 KafkaClientAuthenticationOAuth (io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationOAuth)2 KafkaClientAuthenticationPlain (io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationPlain)2 KafkaClientAuthenticationScram (io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationScram)2 KafkaClientAuthenticationTls (io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationTls)2