use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project jkube by eclipse.
the class DebugServiceTest method enableDebuggingWithReplicaSet.
@Test
public void enableDebuggingWithReplicaSet() {
// Given
final ReplicaSet replicaSet = initReplicaSet();
// When
debugService.enableDebugging(replicaSet, "file.name", false);
// Then
assertThat(replicaSet).extracting("spec.template.spec.containers").asList().flatExtracting("env").extracting("name", "value").containsExactlyInAnyOrder(new Tuple("JAVA_DEBUG_SUSPEND", "false"), new Tuple("JAVA_ENABLE_DEBUG", "true"));
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project jkube by eclipse.
the class PodAnnotationEnricherTest method enrich_withReplicaSet_shouldAddAnnotationsToPodTemplateSpec.
@Test
public void enrich_withReplicaSet_shouldAddAnnotationsToPodTemplateSpec() {
// Given
klb.addToItems(new ReplicaSetBuilder().withMetadata(createResourceMetadata()).withNewSpec().withNewTemplate().withMetadata(createPodTemplateSpecMetadata()).endTemplate().endSpec());
// When
podAnnotationEnricher.enrich(PlatformMode.kubernetes, klb);
// Then
KubernetesList kubernetesList = klb.build();
assertThat(kubernetesList.getItems()).hasSize(1).first().isInstanceOf(ReplicaSet.class);
ReplicaSet replicaSet = (ReplicaSet) kubernetesList.getItems().get(0);
assertThat(replicaSet).extracting(ReplicaSet::getSpec).extracting(ReplicaSetSpec::getTemplate).extracting(PodTemplateSpec::getMetadata).extracting(ObjectMeta::getAnnotations).hasFieldOrPropertyWithValue("key1", "value1").hasFieldOrPropertyWithValue("key2", "value2");
}
use of io.fabric8.kubernetes.api.model.apps.ReplicaSet in project dekorate by dekorateio.
the class OpenshiftExtension method startProject.
private void startProject(ExtensionContext context, Project project) throws InterruptedException {
LOGGER.info("Starting project at " + project.getRoot());
OpenshiftIntegrationTestConfig config = getOpenshiftIntegrationTestConfig(context);
KubernetesClient client = getKubernetesClient(context);
KubernetesList list = getOpenshiftResources(context, project);
OpenshiftConfig openshiftConfig = getOpenshiftConfig(project);
ImageConfiguration imageConfiguration = ImageConfiguration.from(openshiftConfig);
BuildService buildService = null;
try {
BuildServiceFactory buildServiceFactory = BuildServiceFactories.find(project, imageConfiguration).orElseThrow(() -> new IllegalStateException("No applicable BuildServiceFactory found."));
buildService = buildServiceFactory.create(project, imageConfiguration, list.getItems());
} catch (Exception e) {
throw DekorateException.launderThrowable("Failed to lookup BuildService.", e);
}
if (config.isPushEnabled()) {
buildService.prepare();
buildService.build();
buildService.push();
} else if (config.isBuildEnabled()) {
buildService.prepare();
buildService.build();
}
if (config.isDeployEnabled()) {
// Create the remaining resources.
list.getItems().stream().filter(i -> !(i instanceof BuildConfig)).forEach(i -> {
try {
HasMetadata r = client.resource(i).fromServer().get();
if (r == null) {
client.resource(i).apply();
} else if (r instanceof ImageStream) {
// let's not delete image streams at this point
} else if (deleteAndWait(context, i, 1, TimeUnit.MINUTES)) {
client.resource(i).apply();
}
} catch (Exception e) {
e.printStackTrace(System.err);
}
LOGGER.info("Created: " + i.getKind() + " name:" + i.getMetadata().getName() + ".");
});
List<HasMetadata> waitables = list.getItems().stream().filter(i -> i instanceof Deployment || i instanceof DeploymentConfig || i instanceof Pod || i instanceof ReplicaSet || i instanceof ReplicationController).collect(Collectors.toList());
long started = System.currentTimeMillis();
LOGGER.info("Waiting until ready (" + config.getReadinessTimeout() + " ms)...");
waitUntilCondition(context, waitables, i -> OpenshiftReadiness.isReady(i), config.getReadinessTimeout(), TimeUnit.MILLISECONDS);
long ended = System.currentTimeMillis();
LOGGER.info("Waited: " + (ended - started) + " ms.");
// Display the item status
waitables.stream().map(r -> client.resource(r).fromServer().get()).forEach(i -> {
if (!OpenshiftReadiness.isReady(i)) {
readinessFailed(context);
LOGGER.warning(i.getKind() + ":" + i.getMetadata().getName() + " not ready!");
}
});
if (hasReadinessFailed(context)) {
throw new IllegalStateException("Readiness Failed");
}
}
}
Aggregations