Search in sources :

Example 26 with EnvVar

use of io.fabric8.kubernetes.api.model.EnvVar in project che by eclipse.

the class KubernetesEnvVar method getEnvFrom.

/**
     * Retrieves list of {@link EnvVar} based on environment variables specified
     * in {@link ContainerConfig}
     *
     * @param envVariables
     * @return list of {@link EnvVar}
     */
public static List<EnvVar> getEnvFrom(String[] envVariables) {
    LOG.info("Container environment variables:");
    List<EnvVar> env = new ArrayList<>();
    for (String envVariable : envVariables) {
        String[] nameAndValue = envVariable.split("=", 2);
        String varName = nameAndValue[0];
        String varValue = nameAndValue[1];
        EnvVar envVar = new EnvVarBuilder().withName(varName).withValue(varValue).build();
        env.add(envVar);
        LOG.info("- {}={}", varName, varValue);
    }
    return env;
}
Also used : ArrayList(java.util.ArrayList) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) EnvVarBuilder(io.fabric8.kubernetes.api.model.EnvVarBuilder)

Example 27 with EnvVar

use of io.fabric8.kubernetes.api.model.EnvVar in project vertx-openshift-it by cescoffier.

the class PhantomJSDeployment method createPhantomPod.

private void createPhantomPod() {
    if (!retrievePod()) {
        Container c = new ContainerBuilder().withName(PHANTOMJS).withImage("maschmid/phantomjs").withImagePullPolicy("Always").withEnv(new EnvVar("IGNORE_SSL_ERRORS", "true", null)).withPorts(new ContainerPortBuilder().withContainerPort(4444).withName("webdriver").build()).build();
        Pod pb = new PodBuilder().withNewMetadata().withName(PHANTOMJS).addToLabels("name", PHANTOMJS).endMetadata().withNewSpec().withTerminationGracePeriodSeconds(0L).withDnsPolicy("ClusterFirst").withRestartPolicy("Always").withContainers(c).endSpec().build();
        client.pods().create(pb);
    }
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder) Pod(io.fabric8.kubernetes.api.model.Pod) ContainerPortBuilder(io.fabric8.kubernetes.api.model.ContainerPortBuilder) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) EnvVar(io.fabric8.kubernetes.api.model.EnvVar)

Example 28 with EnvVar

use of io.fabric8.kubernetes.api.model.EnvVar in project strimzi by strimzi.

the class KafkaSetOperatorTest method testNeedsRollingUpdateEnvZkConnect.

@Test
public void testNeedsRollingUpdateEnvZkConnect() {
    String envVar = KEY_KAFKA_ZOOKEEPER_CONNECT;
    a.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().add(new EnvVar(envVar, containerEnvVars(a.getSpec().getTemplate().getSpec().getContainers().get(0)).get(envVar) + "-foo", null));
    assertTrue(KafkaSetOperator.needsRollingUpdate(diff()));
}
Also used : EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Test(org.junit.Test)

Example 29 with EnvVar

use of io.fabric8.kubernetes.api.model.EnvVar in project strimzi by strimzi.

the class KafkaSetOperatorTest method testNeedsRollingUpdateEnvDefaultRepFactor.

@Test
public void testNeedsRollingUpdateEnvDefaultRepFactor() {
    String envVar = KEY_KAFKA_DEFAULT_REPLICATION_FACTOR;
    a.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().add(new EnvVar(envVar, containerEnvVars(a.getSpec().getTemplate().getSpec().getContainers().get(0)).get(envVar) + "-foo", null));
    assertTrue(KafkaSetOperator.needsRollingUpdate(diff()));
}
Also used : EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Test(org.junit.Test)

Example 30 with EnvVar

use of io.fabric8.kubernetes.api.model.EnvVar in project strimzi by strimzi.

the class ZookeeperSetOperatiorTest method testNeedsRollingUpdateEnvZkMetricsEnabled.

@Test
public void testNeedsRollingUpdateEnvZkMetricsEnabled() {
    String envVar = KEY_ZOOKEEPER_METRICS_ENABLED;
    a.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv().add(new EnvVar(envVar, containerEnvVars(a.getSpec().getTemplate().getSpec().getContainers().get(0)).get(envVar) + "-foo", null));
    assertTrue(ZookeeperSetOperator.needsRollingUpdate(diff()));
}
Also used : EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Test(org.junit.Test)

Aggregations

EnvVar (io.fabric8.kubernetes.api.model.EnvVar)51 ArrayList (java.util.ArrayList)15 Test (org.junit.Test)15 ContainerPortBuilder (io.fabric8.kubernetes.api.model.ContainerPortBuilder)11 EnvVarBuilder (io.fabric8.kubernetes.api.model.EnvVarBuilder)10 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)10 HashMap (java.util.HashMap)10 Container (io.fabric8.kubernetes.api.model.Container)9 ContainerPort (io.fabric8.kubernetes.api.model.ContainerPort)9 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)9 File (java.io.File)8 List (java.util.List)8 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)7 Pod (io.fabric8.kubernetes.api.model.Pod)7 ServiceSpecBuilder (io.fabric8.kubernetes.api.model.ServiceSpecBuilder)7 Map (java.util.Map)7 Test (org.testng.annotations.Test)7 LinkedList (java.util.LinkedList)6 ContainerBuilder (io.fabric8.kubernetes.api.model.ContainerBuilder)5 VolumeMount (io.fabric8.kubernetes.api.model.VolumeMount)5