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());
}
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);
}
}
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);
}
Aggregations