use of io.fabric8.kubernetes.api.model.apps.Deployment in project kubernetes by ballerinax.
the class Sample7Test method validateDeployment.
@Test
public void validateDeployment() {
Assert.assertNotNull(deployment);
Assert.assertEquals(deployment.getMetadata().getName(), "hello-world-secret-mount-k8s-deployment");
Assert.assertEquals(deployment.getSpec().getReplicas().intValue(), 1);
Assert.assertEquals(deployment.getSpec().getTemplate().getSpec().getVolumes().size(), 4);
Assert.assertEquals(deployment.getMetadata().getLabels().get(KubernetesConstants.KUBERNETES_SELECTOR_KEY), "hello_world_secret_mount_k8s");
Assert.assertEquals(deployment.getSpec().getTemplate().getSpec().getContainers().size(), 1);
// Assert Containers
Container container = deployment.getSpec().getTemplate().getSpec().getContainers().get(0);
Assert.assertEquals(container.getVolumeMounts().size(), 4);
Assert.assertEquals(container.getImage(), DOCKER_IMAGE);
Assert.assertEquals(container.getImagePullPolicy(), KubernetesConstants.ImagePullPolicy.IfNotPresent.name());
Assert.assertEquals(container.getPorts().size(), 1);
}
use of io.fabric8.kubernetes.api.model.apps.Deployment in project kubernetes by ballerinax.
the class Sample9Test method validateDeployment.
@Test
public void validateDeployment() {
Assert.assertNotNull(deployment);
Assert.assertEquals(deployment.getMetadata().getName(), "hello-world-persistence-volume-k8s-deployment");
Assert.assertEquals(deployment.getSpec().getReplicas().intValue(), 1);
Assert.assertEquals(deployment.getSpec().getTemplate().getSpec().getVolumes().size(), 2);
Assert.assertEquals(deployment.getMetadata().getLabels().get(KubernetesConstants.KUBERNETES_SELECTOR_KEY), "hello_world_persistence_volume_k8s");
Assert.assertEquals(deployment.getSpec().getTemplate().getSpec().getContainers().size(), 1);
// Assert Containers
Container container = deployment.getSpec().getTemplate().getSpec().getContainers().get(0);
Assert.assertEquals(container.getVolumeMounts().size(), 2);
Assert.assertEquals(container.getImage(), DOCKER_IMAGE);
Assert.assertEquals(container.getImagePullPolicy(), KubernetesConstants.ImagePullPolicy.IfNotPresent.name());
Assert.assertEquals(container.getPorts().size(), 1);
}
use of io.fabric8.kubernetes.api.model.apps.Deployment in project syndesis-qe by syndesisio.
the class Syndesis method deployOperator.
public void deployOperator() {
List<HasMetadata> resourceList = getOperatorResources();
final String operatorResourcesName = "syndesis-operator";
Optional<HasMetadata> serviceAccount = resourceList.stream().filter(resource -> "ServiceAccount".equals(resource.getKind()) && operatorResourcesName.equals(resource.getMetadata().getName())).findFirst();
if (serviceAccount.isPresent()) {
((ServiceAccount) serviceAccount.get()).getImagePullSecrets().add(new LocalObjectReference(TestConfiguration.syndesisPullSecretName()));
} else {
log.error("Service account not found in resources");
}
OpenShiftUtils.getInstance().serviceAccounts().withName("default").edit().addToImagePullSecrets(new LocalObjectReference(TestConfiguration.syndesisPullSecretName())).done();
List<EnvVar> envVarsToAdd = new ArrayList<>();
envVarsToAdd.add(new EnvVar("TEST_SUPPORT", "true", null));
// For upgrade, we want to override images only for "current" version
if (operatorImage.equals(TestConfiguration.syndesisOperatorImage())) {
Set<Image> images = EnumSet.allOf(Image.class);
for (Image image : images) {
if (TestConfiguration.image(image) != null) {
// override image, e.g. from BUILD_PROPERTIES
log.info("Overriding " + image.name().toLowerCase() + " image with " + TestConfiguration.image(image));
envVarsToAdd.add(new EnvVar("RELATED_IMAGE_" + image.name(), TestConfiguration.image(image), null));
} else {
// use images from Quay instead of DockerHub for Syndesis components
switch(image) {
case META:
case S2I:
case UI:
case SERVER:
case UPGRADE:
log.info("Overriding " + image.name().toLowerCase() + " image with quay variant");
String version = TestConfiguration.syndesisInstallVersion() != null ? TestConfiguration.syndesisInstallVersion() : "latest";
envVarsToAdd.add(new EnvVar("RELATED_IMAGE_" + image.name(), String.format("%s/syndesis/syndesis-%s:%s", TestConfiguration.get().readValue(SYNDESIS_DOCKER_REGISTRY), image.name().toLowerCase(), version), null));
}
}
}
}
if ((TestUtils.isProdBuild() && getOperatorImage().contains("1.8")) || getOperatorImage().contains("1.11")) {
// apply this hotfix for 1.8 prod version, needs for OSD because it doesn't see proxy eng repo
if (TestUtils.isProdBuild()) {
envVarsToAdd.add(new EnvVar("RELATED_IMAGE_PSQL_EXPORTER", "registry.redhat.io/fuse7/fuse-postgres-exporter-rhel7:1.8", null));
}
// needs for upgrade test when previous version is 1.11
DeploymentConfig dc = (DeploymentConfig) resourceList.stream().filter(r -> "DeploymentConfig".equals(r.getKind()) && operatorResourcesName.equals(r.getMetadata().getName())).findFirst().orElseThrow(() -> new RuntimeException("Unable to find deployment config in operator resources"));
dc.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().addAll(envVarsToAdd);
} else {
Deployment deployment = (Deployment) resourceList.stream().filter(r -> "Deployment".equals(r.getKind()) && operatorResourcesName.equals(r.getMetadata().getName())).findFirst().orElseThrow(() -> new RuntimeException("Unable to find deployment in operator resources"));
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().addAll(envVarsToAdd);
}
OpenShiftUtils.asRegularUser(() -> OpenShiftUtils.getInstance().resourceList(resourceList).createOrReplace());
log.info("Waiting for syndesis-operator to be ready");
try {
OpenShiftUtils.getInstance().waiters().areExactlyNPodsReady(1, "syndesis.io/component", operatorResourcesName).interval(TimeUnit.SECONDS, 20).timeout(TimeUnit.MINUTES, 10).waitFor();
} catch (WaiterException e) {
InfraFail.fail("Unable to find operator pod in 10 minutes");
}
}
use of io.fabric8.kubernetes.api.model.apps.Deployment in project syndesis-qe by syndesisio.
the class OpenshiftValidationSteps method setResourceValues.
@When("set resources for deployment config {string}")
public void setResourceValues(String dcName, DataTable dataTable) {
DeploymentConfig dc = OpenShiftUtils.getInstance().getDeploymentConfig(dcName);
Map<String, Quantity> currentLimits = dc.getSpec().getTemplate().getSpec().getContainers().get(0).getResources().getLimits();
Map<String, Quantity> currentRequests = dc.getSpec().getTemplate().getSpec().getContainers().get(0).getResources().getRequests();
Map<String, Quantity> limits = currentLimits == null ? new HashMap<>() : new HashMap<>(currentLimits);
Map<String, Quantity> requests = currentRequests == null ? new HashMap<>() : new HashMap<>(currentRequests);
for (List<String> l : dataTable.asLists()) {
if ("limits".equals(l.get(0))) {
limits.put(l.get(1), new Quantity(l.get(2)));
} else {
requests.put(l.get(1), new Quantity(l.get(2)));
}
}
// @formatter:off
OpenShiftUtils.getInstance().deploymentConfigs().withName(dcName).edit().editSpec().editTemplate().editSpec().editFirstContainer().editResources().withLimits(limits).withRequests(requests).endResources().endContainer().endSpec().endTemplate().endSpec().done();
// @formatter:on
}
use of io.fabric8.kubernetes.api.model.apps.Deployment in project syndesis-qe by syndesisio.
the class Jaeger method processResources.
private void processResources() {
for (String jaegerResource : JAEGER_RESOURCES) {
// version 1.20.0 ==> repo v1.20.0
jaegerResource = String.format(jaegerResource, "v" + TestConfiguration.jaegerVersion());
log.info("Processing " + jaegerResource);
try (InputStream is = new URL(jaegerResource).openStream()) {
List<HasMetadata> resources = OpenShiftUtils.getInstance().load(is).get();
// Change the namespace in the resources to the current
for (HasMetadata resource : resources) {
if (resource instanceof ClusterRoleBinding) {
for (Subject subject : ((ClusterRoleBinding) resource).getSubjects()) {
subject.setNamespace(TestConfiguration.openShiftNamespace());
}
}
resource.getMetadata().setNamespace(TestConfiguration.openShiftNamespace());
processedResources.add(resource);
// change docker image to quay
if (resource instanceof Deployment) {
((Deployment) resource).getSpec().getTemplate().getSpec().getContainers().get(0).setImage("quay.io/jaegertracing/jaeger-operator:" + TestConfiguration.jaegerVersion());
}
}
} catch (IOException e) {
fail("Unable to process Jaeger resource " + jaegerResource, e);
}
}
}
Aggregations