use of io.fabric8.kubernetes.api.model.EnvVar in project syndesis-qe by syndesisio.
the class ExternalDatabase method deploy.
@Override
public void deploy() {
OpenShiftUtils.getInstance().deploymentConfigs().createOrReplaceWithNew().withNewMetadata().withName(NAME).withLabels(TestUtils.map("app", NAME)).endMetadata().withNewSpec().withReplicas(1).withNewTemplate().withNewMetadata().withLabels(TestUtils.map("app", NAME)).endMetadata().withNewSpec().withContainers(new ContainerBuilder().withEnv(new EnvVar("POSTGRESQL_DATABASE", "testdb", null), new EnvVar("POSTGRESQL_PASSWORD", "testpassword", null), new EnvVar("POSTGRESQL_USER", "testuser", null)).withPorts(new ContainerPortBuilder().withContainerPort(5432).withProtocol("TCP").build()).withName(NAME).withImage(" ").build()).endSpec().endTemplate().withSelector(TestUtils.map("app", NAME)).withTriggers(new DeploymentTriggerPolicyBuilder().withNewImageChangeParams().withContainerNames(NAME).withFrom(new ObjectReferenceBuilder().withKind("ImageStreamTag").withName("postgresql:12").withNamespace("openshift").build()).withAutomatic(true).endImageChangeParams().withNewType("ImageChange").build()).endSpec().done();
OpenShiftUtils.getInstance().services().createOrReplaceWithNew().withNewMetadata().withName(NAME).withLabels(TestUtils.map("app", NAME)).endMetadata().withNewSpec().addToPorts(new ServicePortBuilder().withNewName("5432-tcp").withNewTargetPort(5432).withNewProtocol("TCP").withPort(5432).build()).addToSelector(TestUtils.map("app", NAME)).endSpec().done();
// create a needed secret with the password
OpenShiftUtils.getInstance().secrets().createOrReplaceWithNew().withNewMetadata().withName("syndesis-global-config").endMetadata().withStringData(TestUtils.map("POSTGRESQL_PASSWORD", "testpassword")).withNewType("Opaque").done();
}
use of io.fabric8.kubernetes.api.model.EnvVar 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.kubernetes.api.model.EnvVar in project flink by apache.
the class KubernetesJobManagerFactoryTest method testPodSpec.
@Test
public void testPodSpec() throws IOException {
kubernetesJobManagerSpecification = KubernetesJobManagerFactory.buildKubernetesJobManagerSpecification(flinkPod, kubernetesJobManagerParameters);
final PodSpec resultPodSpec = this.kubernetesJobManagerSpecification.getDeployment().getSpec().getTemplate().getSpec();
assertEquals(1, resultPodSpec.getContainers().size());
assertEquals(SERVICE_ACCOUNT_NAME, resultPodSpec.getServiceAccountName());
assertEquals(3, resultPodSpec.getVolumes().size());
final Container resultedMainContainer = resultPodSpec.getContainers().get(0);
assertEquals(Constants.MAIN_CONTAINER_NAME, resultedMainContainer.getName());
assertEquals(CONTAINER_IMAGE, resultedMainContainer.getImage());
assertEquals(CONTAINER_IMAGE_PULL_POLICY.name(), resultedMainContainer.getImagePullPolicy());
assertEquals(3, resultedMainContainer.getEnv().size());
assertTrue(resultedMainContainer.getEnv().stream().anyMatch(envVar -> envVar.getName().equals("key1")));
assertEquals(3, resultedMainContainer.getPorts().size());
final Map<String, Quantity> requests = resultedMainContainer.getResources().getRequests();
assertEquals(Double.toString(JOB_MANAGER_CPU), requests.get("cpu").getAmount());
assertEquals(String.valueOf(JOB_MANAGER_MEMORY), requests.get("memory").getAmount());
assertEquals(1, resultedMainContainer.getCommand().size());
// The args list is [bash, -c, 'java -classpath $FLINK_CLASSPATH ...'].
assertEquals(3, resultedMainContainer.getArgs().size());
assertEquals(3, resultedMainContainer.getVolumeMounts().size());
}
use of io.fabric8.kubernetes.api.model.EnvVar in project flink by apache.
the class EnvSecretsDecoratorTest method testWhetherPodOrContainerIsDecorated.
@Test
public void testWhetherPodOrContainerIsDecorated() {
final FlinkPod resultFlinkPod = envSecretsDecorator.decorateFlinkPod(baseFlinkPod);
List<EnvVar> envVarList = resultFlinkPod.getMainContainer().getEnv();
assertEquals(1, envVarList.size());
assertEquals(ENV_NAME, envVarList.get(0).getName());
}
use of io.fabric8.kubernetes.api.model.EnvVar in project flink by apache.
the class HadoopConfMountDecoratorTest method testMainContainerWithHadoopConfVolumeMount.
@Test
public void testMainContainerWithHadoopConfVolumeMount() throws IOException {
setHadoopConfDirEnv();
generateHadoopConfFileItems();
final FlinkPod resultFlinkPod = hadoopConfMountDecorator.decorateFlinkPod(baseFlinkPod);
final List<VolumeMount> resultVolumeMounts = resultFlinkPod.getMainContainer().getVolumeMounts();
assertEquals(1, resultVolumeMounts.size());
final VolumeMount resultVolumeMount = resultVolumeMounts.get(0);
assertEquals(Constants.HADOOP_CONF_VOLUME, resultVolumeMount.getName());
assertEquals(Constants.HADOOP_CONF_DIR_IN_POD, resultVolumeMount.getMountPath());
final Map<String, String> expectedEnvs = new HashMap<String, String>() {
{
put(Constants.ENV_HADOOP_CONF_DIR, Constants.HADOOP_CONF_DIR_IN_POD);
}
};
final Map<String, String> resultEnvs = resultFlinkPod.getMainContainer().getEnv().stream().collect(Collectors.toMap(EnvVar::getName, EnvVar::getValue));
assertEquals(expectedEnvs, resultEnvs);
}
Aggregations