Search in sources :

Example 6 with Service

use of org.bf2.cos.fleetshard.support.Service in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class OMB method createWorker.

private void createWorker(String jvmOpts, String name, Node node) throws IOException {
    KubeClient kubeClient = ombCluster.kubeClient();
    DeploymentBuilder deploymentBuilder = new DeploymentBuilder().editOrNewMetadata().withName(name).withNamespace(Constants.OMB_NAMESPACE).addToLabels("app", "worker").endMetadata().editOrNewSpec().withReplicas(1).editOrNewSelector().addToMatchLabels("worker", name).endSelector().editOrNewTemplate().editOrNewMetadata().addToLabels("worker", name).addToLabels("app", "worker").endMetadata().editOrNewSpec().addNewContainer().withName("worker").withImage(Constants.OMB_WORKER_IMAGE).withResources(new ResourceRequirementsBuilder().withLimits(getResourceLimits()).withRequests(getResourceLimits()).build()).addToCommand("sh", "-c").addToEnv(new EnvVar("_JAVA_OPTIONS", jvmOpts, null)).addToEnv(envVars.toArray(new EnvVar[0])).addToArgs("cd /tmp/src; ./bin/benchmark-worker").addToPorts(new ContainerPortBuilder().withContainerPort(8080).build(), new ContainerPortBuilder().withContainerPort(8081).build()).withLivenessProbe(new ProbeBuilder().withInitialDelaySeconds(10).withHttpGet(new HTTPGetActionBuilder().withPort(new IntOrString(8080)).withPath("counters-stats").build()).build()).addNewVolumeMount().withName("ca").withMountPath("/cert").withReadOnly(true).endVolumeMount().endContainer().withTerminationGracePeriodSeconds(15L).addNewVolume().withName("ca").editOrNewSecret().withSecretName("ext-listener-crt").endSecret().endVolume().endSpec().endTemplate().endSpec();
    if (node != null) {
        deploymentBuilder.editSpec().editTemplate().editSpec().withNodeSelector(Collections.singletonMap("kubernetes.io/hostname", node.getMetadata().getLabels().get("kubernetes.io/hostname"))).endSpec().endTemplate().endSpec();
    }
    kubeClient.client().apps().deployments().inNamespace(Constants.OMB_NAMESPACE).createOrReplace(deploymentBuilder.build());
    kubeClient.client().services().inNamespace(Constants.OMB_NAMESPACE).createOrReplace(new ServiceBuilder().editOrNewMetadata().withName(name).withNamespace(Constants.OMB_NAMESPACE).addToLabels("app", "worker").endMetadata().editOrNewSpec().addToSelector("worker", name).addNewPort().withPort(80).withTargetPort(new IntOrString(8080)).withProtocol("TCP").endPort().endSpec().build());
    kubeClient.client().adapt(OpenShiftClient.class).routes().inNamespace(Constants.OMB_NAMESPACE).createOrReplace(new RouteBuilder().editOrNewMetadata().withName(name).withNamespace(Constants.OMB_NAMESPACE).withAnnotations(Map.of("haproxy.router.openshift.io/timeout", "360s")).addToLabels("app", "worker").addToLabels("app.kubernetes.io/name", name).endMetadata().editOrNewSpec().editOrNewTo().withKind("Service").withName(name).endTo().endSpec().build());
}
Also used : HTTPGetActionBuilder(io.fabric8.kubernetes.api.model.HTTPGetActionBuilder) ProbeBuilder(io.fabric8.kubernetes.api.model.ProbeBuilder) KubeClient(org.bf2.test.k8s.KubeClient) RouteBuilder(io.fabric8.openshift.api.model.RouteBuilder) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) ResourceRequirementsBuilder(io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder) ContainerPortBuilder(io.fabric8.kubernetes.api.model.ContainerPortBuilder) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) DeploymentBuilder(io.fabric8.kubernetes.api.model.apps.DeploymentBuilder) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder)

Example 7 with Service

use of org.bf2.cos.fleetshard.support.Service in project srs-fleet-manager by bf2fc6cc711aee1a0c2a.

the class AccountManagementServiceImpl method init.

@PostConstruct
void init() {
    log.info("Using Account Management Service with Account Management URL: {}", endpoint);
    if (ssoEnabled) {
        ApicurioHttpClient httpClient = new JdkHttpClientProvider().create(ssoTokenEndpoint, Collections.emptyMap(), null, new AccountManagementSystemAuthErrorHandler());
        final OidcAuth auth = new OidcAuth(httpClient, ssoClientId, ssoClientSecret);
        restClient = new AccountManagementSystemRestClient(endpoint, Collections.emptyMap(), auth);
    } else {
        restClient = new AccountManagementSystemRestClient(endpoint, Collections.emptyMap(), null);
    }
}
Also used : JdkHttpClientProvider(io.apicurio.rest.client.JdkHttpClientProvider) OidcAuth(io.apicurio.rest.client.auth.OidcAuth) ApicurioHttpClient(io.apicurio.rest.client.spi.ApicurioHttpClient) AccountManagementSystemAuthErrorHandler(org.bf2.srs.fleetmanager.spi.ams.impl.exception.AccountManagementSystemAuthErrorHandler) PostConstruct(javax.annotation.PostConstruct)

Example 8 with Service

use of org.bf2.cos.fleetshard.support.Service in project srs-fleet-manager by bf2fc6cc711aee1a0c2a.

the class MigrationService method runMigration.

public void runMigration() throws TenantManagerServiceException {
    if (deleteAll.isPresent() && deleteAll.get()) {
        log.warn("Removing all data first");
        TenantManagerConfig tm = TenantManagerConfig.builder().tenantManagerUrl("http://tenant-manager:8585").registryDeploymentUrl("https://service-registry-stage.apps.app-sre-stage-0.k3s7.p1.openshiftapps.com").build();
        for (Tenant t : tenantManagerClient.getAllTenants(tm)) {
            log.warn("Deleting tenant '{}'", t.getId());
            try {
                tenantManagerClient.deleteTenant(tm, t.getId());
            } catch (TenantNotFoundServiceException ex) {
                log.warn("Could not delete tenant '{}'. Tenant does not exist and may have been already deleted.", t.getId());
            }
        }
        CleanResult cleanResult = flyway.clean();
        log.info("Database clean result: " + "flywayVersion = '{}', " + "database = '{}', " + "schemasCleaned = '{}', " + "schemasDropped = '{}', " + "warnings = '{}'.", cleanResult.flywayVersion, cleanResult.database, cleanResult.schemasCleaned, cleanResult.schemasDropped, cleanResult.warnings);
    }
    MigrateResult migrateResult = flyway.migrate();
    log.info("Database migrate result: " + "flywayVersion = '{}', " + "database = '{}', " + "initialSchemaVersion = '{}', " + "targetSchemaVersion = '{}', " + "migrations = '{}', " + "warnings = '{}'.", migrateResult.flywayVersion, migrateResult.database, migrateResult.initialSchemaVersion, migrateResult.targetSchemaVersion, migrateResult.migrations, migrateResult.warnings);
}
Also used : TenantNotFoundServiceException(org.bf2.srs.fleetmanager.spi.tenants.TenantNotFoundServiceException) Tenant(org.bf2.srs.fleetmanager.spi.tenants.model.Tenant) MigrateResult(org.flywaydb.core.api.output.MigrateResult) TenantManagerConfig(org.bf2.srs.fleetmanager.spi.tenants.model.TenantManagerConfig) CleanResult(org.flywaydb.core.api.output.CleanResult)

Aggregations

OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)4 Service (io.fabric8.kubernetes.api.model.Service)3 Route (io.fabric8.openshift.api.model.Route)3 ManagedKafka (org.bf2.operator.resources.v1alpha1.ManagedKafka)3 Node (io.fabric8.kubernetes.api.model.Node)2 Pod (io.fabric8.kubernetes.api.model.Pod)2 Quantity (io.fabric8.kubernetes.api.model.Quantity)2 ResourceRequirementsBuilder (io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder)2 ServiceBuilder (io.fabric8.kubernetes.api.model.ServiceBuilder)2 IngressController (io.fabric8.openshift.api.model.operator.v1.IngressController)2 QuarkusTest (io.quarkus.test.junit.QuarkusTest)2 Kafka (io.strimzi.api.kafka.model.Kafka)2 Comparator (java.util.Comparator)2 List (java.util.List)2 LongSummaryStatistics (java.util.LongSummaryStatistics)2 Map (java.util.Map)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 OperandUtils (org.bf2.common.OperandUtils)2