Search in sources :

Example 6 with Arguments

use of io.fabric8.maven.docker.config.Arguments in project docker-maven-plugin by fabric8io.

the class DockerFileBuilderTest method testBuildDockerFileBadPort.

@Test(expected = IllegalArgumentException.class)
public void testBuildDockerFileBadPort() throws Exception {
    Arguments a = Arguments.Builder.get().withParam("c1").withParam("c2").build();
    new DockerFileBuilder().add("/src", "/dest").baseImage("image").cmd(a).env(ImmutableMap.of("foo", "bar")).basedir("/export").expose(Collections.singletonList("8080aaa/udp")).maintainer("maintainer@example.com").workdir("/tmp").labels(ImmutableMap.of("com.acme.foobar", "How are \"you\" ?")).volumes(Collections.singletonList("/vol1")).run(Arrays.asList("echo something", "echo second")).content();
}
Also used : Arguments(io.fabric8.maven.docker.config.Arguments) Test(org.junit.Test)

Example 7 with Arguments

use of io.fabric8.maven.docker.config.Arguments in project docker-maven-plugin by fabric8io.

the class DockerFileBuilderTest method testEntryPointParams.

@Test
public void testEntryPointParams() {
    Arguments a = Arguments.Builder.get().withParam("java").withParam("-jar").withParam("/my-app-1.1.1.jar").withParam("server").build();
    String dockerfileContent = new DockerFileBuilder().entryPoint(a).content();
    assertThat(dockerfileToMap(dockerfileContent), hasEntry("ENTRYPOINT", "[\"java\",\"-jar\",\"/my-app-1.1.1.jar\",\"server\"]"));
}
Also used : Arguments(io.fabric8.maven.docker.config.Arguments) Test(org.junit.Test)

Example 8 with Arguments

use of io.fabric8.maven.docker.config.Arguments in project docker-maven-plugin by fabric8io.

the class DockerFileBuilderTest method testEntryPointShell.

@Test
public void testEntryPointShell() {
    Arguments a = Arguments.Builder.get().withShell("java -jar /my-app-1.1.1.jar server").build();
    String dockerfileContent = new DockerFileBuilder().entryPoint(a).content();
    assertThat(dockerfileToMap(dockerfileContent), hasEntry("ENTRYPOINT", "java -jar /my-app-1.1.1.jar server"));
}
Also used : Arguments(io.fabric8.maven.docker.config.Arguments) Test(org.junit.Test)

Example 9 with Arguments

use of io.fabric8.maven.docker.config.Arguments in project fabric8 by jboss-fuse.

the class ContainerEditJvmOptionsAction method doExecute.

protected Object doExecute() throws Exception {
    validateContainerName(container);
    if (!FabricCommand.doesContainerExist(fabricService, container)) {
        System.out.println("Container " + container + " does not exists!");
        return null;
    }
    Container containerInstance = FabricCommand.getContainerIfExists(fabricService, container);
    String type = containerInstance.getType();
    if (!"karaf".equals(type)) {
        System.out.println("Sorry, currently only \"karaf\" type container are supported");
        return null;
    }
    // read current jvm values
    FabricManager fabricManager = new FabricManager(fabricService);
    if (full) {
        String jmxUrl = null;
        JMXConnector connector = null;
        MBeanServerConnection remote = null;
        HashMap<String, String[]> authenticationData = null;
        jmxUrl = containerInstance.getJmxUrl();
        authenticationData = prepareAuthenticationData();
        try {
            connector = connectOrRetry(authenticationData, jmxUrl);
        } catch (Exception e) {
            username = null;
            password = null;
            System.out.println("Operation Failed. Check logs.");
            log.error("Unable to connect to JMX Server", e);
            return null;
        }
        ObjectName objName = new ObjectName(JAVA_LANG_OBJECT_NAME);
        try {
            remote = connector.getMBeanServerConnection();
            String[] arguments = (String[]) remote.getAttribute(objName, "InputArguments");
            String output = Arrays.toString(arguments);
            output = output.replaceAll(",", "");
            output = output.substring(1, output.length() - 1);
            System.out.println(output);
        } catch (Exception e) {
            System.out.println("Operation Failed. Check logs.");
            log.error("Unable to fetch child jvm opts", e);
        }
        try {
            connector.close();
        } catch (IOException e) {
            log.error("Errors closing remote MBean connection", e);
        }
    } else {
        try {
            String output = fabricManager.getJvmOpts(container);
            if ("Inapplicable".equals(output)) {
                String message = container + " jvmOpts cannot be handled within Fabric. You have to set required values directly in startup scripts.";
                System.out.println(message);
                log.error(message);
                return null;
            }
            if (jvmOptions == null) {
                System.out.println(output);
            } else {
                fabricManager.setJvmOpts(container, jvmOptions);
                System.out.println("Operation succeeded. New JVM flags will be loaded at the next start of " + container + " container");
                log.info("Updated JVM flags for container {}", container);
            }
        } catch (Exception e) {
            System.out.println("Operation Failed. Check logs.");
            log.error("Unable to set ssh jvm opts", e);
        }
    }
    return null;
}
Also used : Container(io.fabric8.api.Container) FabricManager(io.fabric8.core.jmx.FabricManager) JMXConnector(javax.management.remote.JMXConnector) IOException(java.io.IOException) MBeanServerConnection(javax.management.MBeanServerConnection) FabricAuthenticationException(io.fabric8.api.FabricAuthenticationException) IOException(java.io.IOException) ObjectName(javax.management.ObjectName)

Example 10 with Arguments

use of io.fabric8.maven.docker.config.Arguments in project fabric8 by fabric8io.

the class PodIdToReplicationControllerIDExample method main.

public static void main(String[] args) {
    if (args.length < 3) {
        System.out.println("Arguments: kuberneteMasterUrl namespace podID");
        return;
    }
    String kuberneteMasterUrl = args[0];
    String namespace = args[1];
    String podID = args[2];
    System.out.println("Looking up ReplicationController for pod ID: " + podID);
    KubernetesClient client = new DefaultKubernetesClient(new ConfigBuilder().withMasterUrl(kuberneteMasterUrl).build());
    Pod pod = (Pod) client.pods().inNamespace(namespace).withName(podID);
    pod.getMetadata().getLabels();
    List<ReplicationController> replicationControllers = client.replicationControllers().inNamespace(namespace).withLabels(pod.getMetadata().getLabels()).list().getItems();
    if (replicationControllers.size() == 1) {
        ReplicationController replicationController = replicationControllers.get(0);
        String id = KubernetesHelper.getName(replicationController);
        System.out.println("Found replication controller: " + id);
    } else {
        System.out.println("Could not find replication controller!");
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) Pod(io.fabric8.kubernetes.api.model.Pod) ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Aggregations

Arguments (io.fabric8.maven.docker.config.Arguments)12 Test (org.junit.Test)8 ContainerCreateConfig (io.fabric8.maven.docker.access.ContainerCreateConfig)2 ContainerHostConfig (io.fabric8.maven.docker.access.ContainerHostConfig)2 PortMapping (io.fabric8.maven.docker.access.PortMapping)2 Properties (java.util.Properties)2 Configuration (io.fabric8.annotations.Configuration)1 Endpoint (io.fabric8.annotations.Endpoint)1 External (io.fabric8.annotations.External)1 Path (io.fabric8.annotations.Path)1 PortName (io.fabric8.annotations.PortName)1 Protocol (io.fabric8.annotations.Protocol)1 ServiceName (io.fabric8.annotations.ServiceName)1 Container (io.fabric8.api.Container)1 FabricAuthenticationException (io.fabric8.api.FabricAuthenticationException)1 FabricManager (io.fabric8.core.jmx.FabricManager)1 Pod (io.fabric8.kubernetes.api.model.Pod)1 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)1 ConfigBuilder (io.fabric8.kubernetes.client.ConfigBuilder)1 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)1