Search in sources :

Example 21 with Versions

use of org.bf2.operator.resources.v1alpha1.Versions in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class ManagedKafkaProvisioner method deployCluster.

/**
 * TODO: if/when this will need to test bin packing, then we'll separate the profile setting from deployCluster
 *
 * Deploy a Kafka cluster using this provisioner.
 * @param profile
 */
public ManagedKafkaDeployment deployCluster(String name, ManagedKafkaCapacity managedKafkaCapacity, KafkaInstanceConfiguration profile) throws Exception {
    // set and validate the strimzi version
    String strimziVersion = PerformanceEnvironment.STRIMZI_VERSION;
    if (strimziVersion == null) {
        strimziVersion = strimziVersions.get(strimziVersions.size() - 1);
    }
    String kafkaVersion = PerformanceEnvironment.KAFKA_VERSION;
    if (kafkaVersion == null) {
        kafkaVersion = getKafkaVersion(strimziVersion);
    }
    List<String> versions = strimziManager.getVersions();
    if (!versions.contains(strimziVersion)) {
        throw new IllegalStateException(String.format("Strimzi version %s is not in the set of installed versions %s", strimziVersion, versions));
    }
    int replicas = 3;
    if (managedKafkaCapacity.getMaxPartitions() != null) {
        replicas = (int) (3 * Math.ceil(managedKafkaCapacity.getMaxPartitions() / (double) profile.getKafka().getPartitionCapacity()));
    }
    applyProfile(profile, replicas);
    String namespace = Constants.KAFKA_NAMESPACE;
    ManagedKafka managedKafka = new ManagedKafkaBuilder().withNewMetadata().withName(name).withNamespace(namespace).endMetadata().withSpec(new ManagedKafkaSpecBuilder().withCapacity(managedKafkaCapacity).withNewEndpoint().withBootstrapServerHost(String.format("%s-kafka-bootstrap-%s.%s", name, namespace, domain)).withNewTls().withCert(tlsConfig.getCert()).withKey(tlsConfig.getKey()).endTls().endEndpoint().withNewVersions().withKafka(kafkaVersion).withStrimzi(strimziVersion).endVersions().build()).build();
    clusters.add(managedKafka);
    LOGGER.info("Deploying {}", Serialization.asYaml(managedKafka));
    ManagedKafkaDeployment kafkaDeployment = deployCluster(namespace, managedKafka);
    kafkaDeployment.start();
    return kafkaDeployment;
}
Also used : ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) ManagedKafkaSpecBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaSpecBuilder) ManagedKafkaBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaBuilder)

Aggregations

Versions (com.netflix.spinnaker.halyard.core.registry.v1.Versions)11 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)6 StrimziVersionStatus (org.bf2.operator.resources.v1alpha1.StrimziVersionStatus)4 VersionsService (com.netflix.spinnaker.halyard.config.services.v1.VersionsService)3 Objects (java.util.Objects)3 Optional (java.util.Optional)3 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)2 DeploymentType (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment.DeploymentType)2 Validator (com.netflix.spinnaker.halyard.config.model.v1.node.Validator)2 ConfigProblemSetBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemSetBuilder)2 Problem (com.netflix.spinnaker.halyard.core.problem.v1.Problem)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ManagedKafka (org.bf2.operator.resources.v1alpha1.ManagedKafka)2 Versions (org.bf2.operator.resources.v1alpha1.Versions)2 Test (org.junit.jupiter.api.Test)2 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)1 Canary (com.netflix.spinnaker.halyard.config.model.v1.canary.Canary)1