use of io.fabric8.openshift.api.model.DeploymentConfig in project syndesis-qe by syndesisio.
the class OpenShiftUtils method updateEnvVarInDeploymentConfig.
public static void updateEnvVarInDeploymentConfig(String dcName, String key, String value) {
DeploymentConfig dc = getInstance().getDeploymentConfig(dcName);
List<EnvVar> vars = dc.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv();
Optional<EnvVar> var = vars.stream().filter(a -> a.getName().equalsIgnoreCase(key)).findFirst();
if (var.isPresent()) {
var.get().setValue(value);
} else {
log.warn("Variable " + key + " not found in " + dcName + " deployment config, creating it.");
vars.add(new EnvVar(key, value, null));
}
dc.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(vars);
getInstance().updateDeploymentconfig(dc);
}
use of io.fabric8.openshift.api.model.DeploymentConfig in project syndesis-qe by syndesisio.
the class HTTPValidationSteps method configureKeystore.
@When("^configure keystore in (HTTP|HTTPS) integration dc$")
public void configureKeystore(String protocol) {
if ("HTTP".equals(protocol)) {
return;
}
try {
OpenShiftWaitUtils.waitFor(() -> !OpenShiftUtils.getInstance().deploymentConfigs().withLabel("syndesis.io/type", "integration").list().getItems().isEmpty(), 300000L);
} catch (TimeoutException | InterruptedException e) {
fail("Unable to find integration deployment config after 5 minutes");
} catch (Exception e) {
// ignore
}
List<DeploymentConfig> integrationDcs = OpenShiftUtils.getInstance().deploymentConfigs().withLabel("syndesis.io/type", "integration").list().getItems();
Assertions.assertThat(integrationDcs).as("There should be only one integration deployment config").hasSize(1);
DeploymentConfig dc = integrationDcs.get(0);
log.debug("Waiting until next integration state check interval");
String serverLog = OpenShiftUtils.getPodLogs("syndesis-server");
while (serverLog.equals(OpenShiftUtils.getPodLogs("syndesis-server"))) {
TestUtils.sleepIgnoreInterrupt(5000L);
}
TestUtils.withRetry(() -> {
try {
// @formatter:off
OpenShiftUtils.getInstance().deploymentConfigs().withName(dc.getMetadata().getName()).edit().editSpec().editTemplate().editSpec().addNewVolume().withName("keystore").withNewSecret().withSecretName(HTTPEndpoints.KEYSTORE_SECRET_NAME).endSecret().endVolume().editFirstContainer().addNewVolumeMount().withNewMountPath("/opt/jboss/").withName("keystore").endVolumeMount().addToEnv(new EnvVar("JAVA_OPTIONS", "-Djackson.deserialization.whitelist.packages=io.syndesis.common.model,io.atlasmap" + " -Djavax.net.ssl.trustStore=/opt/jboss/keystore.p12 -Djavax.net.ssl.trustStorePassword=tomcat -Djavax.net.ssl.trustStoreAlias=tomcat", null)).endContainer().endSpec().endTemplate().endSpec().done();
// @formatter:on
// Just to be sure, delete the integration pod if it exists, so that the change in DC is picked up
OpenShiftUtils.getInstance().deletePods("syndesis.io/type", "integration");
return true;
} catch (KubernetesClientException kce) {
log.debug("Caught KubernetesClientException: ", kce);
return false;
}
}, 3, 30000L, "Unable to edit deployment config");
}
use of io.fabric8.openshift.api.model.DeploymentConfig in project syndesis-qe by syndesisio.
the class OpenshiftValidationSteps method checkSar.
@Then("check that SAR check is enabled for namespace {string}")
public void checkSar(String namespace) {
if (namespace.isEmpty()) {
namespace = TestConfiguration.openShiftNamespace();
}
DeploymentConfig dc = OpenShiftUtils.getInstance().getDeploymentConfig("syndesis-oauthproxy");
Optional<String> sarArg = dc.getSpec().getTemplate().getSpec().getContainers().get(0).getArgs().stream().filter(arg -> arg.contains("--openshift-sar")).findFirst();
assertThat(sarArg).isPresent();
assertThat(sarArg.get()).contains("\"namespace\":\"" + namespace + "\"");
}
use of io.fabric8.openshift.api.model.DeploymentConfig in project fabric8 by fabric8io.
the class Util method displaySessionStatus.
public static void displaySessionStatus(KubernetesClient client, Session session) throws MultiException {
if (client == null) {
session.getLogger().warn("No KubernetesClient for session: " + session.getId());
return;
}
if (client.isAdaptable(OpenShiftClient.class)) {
OpenShiftClient oClient = client.adapt(OpenShiftClient.class);
List<DeploymentConfig> deploymentConfigs = oClient.deploymentConfigs().inNamespace(session.getNamespace()).list().getItems();
if (deploymentConfigs == null) {
throw new MultiException("No deployment configs found in namespace" + session.getNamespace());
}
for (DeploymentConfig deploymentConfig : deploymentConfigs) {
session.getLogger().info("Deployment config:" + KubernetesHelper.getName(deploymentConfig));
}
} else {
List<Deployment> deployments = client.extensions().deployments().inNamespace(session.getNamespace()).list().getItems();
if (deployments == null) {
throw new MultiException("No deployments found in namespace" + session.getNamespace());
}
for (Deployment deployment : deployments) {
session.getLogger().info("Deployment:" + KubernetesHelper.getName(deployment));
}
}
List<Pod> pods = client.pods().inNamespace(session.getNamespace()).list().getItems();
if (pods == null) {
throw new MultiException("No pods found in namespace" + session.getNamespace());
}
for (Pod pod : pods) {
session.getLogger().info("Pod:" + KubernetesHelper.getName(pod) + " Status:" + pod.getStatus());
}
List<Service> svcs = client.services().inNamespace(session.getNamespace()).list().getItems();
if (svcs == null) {
throw new MultiException("No services found in namespace" + session.getNamespace());
}
for (Service service : svcs) {
session.getLogger().info("Service:" + KubernetesHelper.getName(service) + " IP:" + getPortalIP(service) + " Port:" + getPorts(service));
}
}
use of io.fabric8.openshift.api.model.DeploymentConfig in project fabric8 by fabric8io.
the class KubernetesHelper method summaryText.
/**
* Returns a short summary text message for the given kubernetes resource
*/
public static String summaryText(DeploymentConfig entity) {
StringBuilder buffer = new StringBuilder();
DeploymentConfigSpec spec = entity.getSpec();
if (spec != null) {
buffer.append("replicas: " + spec.getReplicas());
PodTemplateSpec podTemplateSpec = spec.getTemplate();
if (podTemplateSpec != null) {
appendSummaryText(buffer, podTemplateSpec);
}
}
return buffer.toString();
}
Aggregations