Git Product home page Git Product logo

dcos-maven-plugin's Introduction

DC/OS Maven Plugin

Maven plugin to deploy containerized java applications to DC/OS

Containerized applications deployed on DC/OS are realized through Marathon. You can find more information about Marathon and container deployment with DC/OS here:

Configuration

Example plugin configuration:

    <build>
        <plugins>
            <plugin>
                <groupId>dcos</groupId>
                <artifactId>dcos-maven-plugin</artifactId>
                <version>0.1</version>
                <configuration>
                    <dcosUrl>http://junterste-elasticl-1j6yqdjx1qa8f-2107866714.us-west-2.elb.amazonaws.com/</dcosUrl>
                    <ignoreSslCertificate>true</ignoreSslCertificate>
                </configuration>
            </plugin>
        </plugins>
    </build>

appDefinition

By default, you need to place your application definition in the app-definition.json. You can change this filename with the appDefinition parameter.

dcosTokenFile

By default, you need to place your DC/OS authentication token in the .dcos-token file. You can change this filename with the dcosTokenFile parameter.

dcosUrl

You can configure the URL of your DC/OS with the dcosUrl configuration node in your plugin configuration within your pom.xml.

ignoreSslCertificate

If you want to skip ssl certificate verification, e.g. you have a self-signed certificate, you can set configure <ignoreSslCertificate>true</ignoreSslCertificate> to disable this verification.

How do I get my DC/OS auth token?!

If you are using the DC/OS CLI, just do the following:

# log in
dcos auth login

# get the token
dcos config show core.dcos_acs_token

Commands

dcos:deploy

If you want to create or update your application, you want to use mvn dcos:deploy. This will send the file configured as appDefinition to DC/OS.

dcos:restart

If you just want to restart your application, for example you updated the docker image in your registry, you want to use mvn dcos:restart. No application definition will be sent to DC/OS, only the restart trigger for the defined application ID will be sent.

dcos:uploadArtifact

If you run mvn clean package dcos:uploadArtifact, this plugin will take the newly built jar file and publish it to your configured nexus server, see example configuration here.

dcos:deployUCR

If you successfully uploaded your jar file to your configured nexus server (no matter if you used the maven plugin or did a manual upload) and you have an app definition like this, the mvn dcos:deployUCR command will replace your placeholders in your application.json with your nexus URLs and deploy this to marathon.

Docker Maven Plugin

Using the plugin

This plugin plays well with the docker-maven-plugin of spotify. You might want to use this plugin to build and push your docker images. After using

mvn docker:build docker:push

to update your docker image in your registry, you might want to use

mvn dcos:restart

to restart your application on DC/OS. Combined: mvn docker:build docker:push dcos:restart

Attention: When using mvn dcos:restart please make sure you you are using the forcePullImage flag in your marathon configuration to disable image caching, for example:

{
  "type": "DOCKER",
  "docker": {
    "image": "your/image",
    "forcePullImage": true
  }
}

Configuring docker hub credentials

You need to configure your docker hub login credentials within your maven ~/.m2/settings.xml configuration:

<servers>
   <server>
      <id>docker-hub</id>
      <username>your-user</username>
      <password>your-password</password>
      <configuration>
         <email>[email protected]</email>
      </configuration>
   </server>
</servers>

Limitations

Security

Security is bound to DC/OS auth tokens which have defined time to life of 5 days.

Run example

You can find a complete example using a Spring Boot web application in the sample/spring-boot-sample folder.

Docker

<pluginRepositories>
   <pluginRepository>
      <id>mesosphere-repo</id>
      <name>Mesosphere Repo</name>
      <url>http://downloads.mesosphere.io/maven</url>
   </pluginRepository>
</pluginRepositories>

<build>
   <plugins>
      <plugin>
         <groupId>com.spotify</groupId>
         <artifactId>docker-maven-plugin</artifactId>
         <version>0.4.13</version>
         <configuration>
            <serverId>docker-hub</serverId>
            <imageName>unterstein/dcos-maven-spring-sample</imageName>
            <baseImage>java</baseImage>
            <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
            <exposes>
               <expose>8080</expose>
            </exposes>
            <resources>
               <resource>
                  <targetPath>/</targetPath>
                  <directory>${project.build.directory}</directory>
                  <include>${project.build.finalName}.jar</include>
               </resource>
            </resources>
         </configuration>
      </plugin>
      <plugin>
         <groupId>dcos</groupId>
         <artifactId>dcos-maven-plugin</artifactId>
         <version>0.2</version>
         <configuration>
            <dcosUrl>http://junterste-elasticl-nne0d6r823fs-2010862002.eu-central-1.elb.amazonaws.com/</dcosUrl>
            <ignoreSslCertificate>true</ignoreSslCertificate>
         </configuration>
      </plugin>
   </plugins>
</build>

You only need to adapt the configuration (.dcos-token & pom.xml) and run

mvn clean package docker:build docker:push dcos:deploy

Groups

<pluginRepositories>
   <pluginRepository>
      <id>mesosphere-repo</id>
      <name>Mesosphere Repo</name>
      <url>http://downloads.mesosphere.io/maven</url>
   </pluginRepository>
</pluginRepositories>

<build>
   <plugins>
      <plugin>
         <groupId>dcos</groupId>
         <artifactId>dcos-maven-plugin</artifactId>
         <version>0.2</version>
         <configuration>
            <dcosUrl>http://junterste-elasticl-nne0d6r823fs-2010862002.eu-central-1.elb.amazonaws.com/</dcosUrl>
            <deployable>group</deployable>
            <ignoreSslCertificate>true</ignoreSslCertificate>
         </configuration>
      </plugin>
   </plugins>
</build>

Pods

<pluginRepositories>
   <pluginRepository>
      <id>mesosphere-repo</id>
      <name>Mesosphere Repo</name>
      <url>http://downloads.mesosphere.io/maven</url>
   </pluginRepository>
</pluginRepositories>

<build>
   <plugins>
      <plugin>
         <groupId>dcos</groupId>
         <artifactId>dcos-maven-plugin</artifactId>
         <version>0.2</version>
         <configuration>
            <dcosUrl>http://junterste-elasticl-nne0d6r823fs-2010862002.eu-central-1.elb.amazonaws.com/</dcosUrl>
            <deployable>pod</deployable>
            <ignoreSslCertificate>true</ignoreSslCertificate>
         </configuration>
      </plugin>
   </plugins>
</build>

For sure docker can be combined with groups and pods as well.

Versions

0.4

0.3

  • Fixes #7 by changing default name for marathon configurations to application.json
  • Fixes #11 by enabling auto detection for apps, groups and pods
  • DEPRECATION: Usage of app-definition.json is deprecated in favor of application.json and will be removed in later versions

0.2

  • Fixes #2 by adding support for groups
  • Fixes #3 by adding support for pods

0.1

  • Initial version enabling dcos:deploy and dcos:restart

dcos-maven-plugin's People

Contributors

arun-gupta avatar joerg84 avatar unterstein avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dcos-maven-plugin's Issues

Appdefinition parameter not being honored

Appdefinition parameter not working...

   <properties> 
        <DCOS_URL>https://m1.dcos</DCOS_URL>
        <DCOS_DEPLOYMENT_FILE>topologies-two-node-app.json</DCOS_DEPLOYMENT_FILE>        
    </properties>
..
            <plugin>
                <groupId>dcos</groupId>
                <artifactId>dcos-maven-plugin</artifactId>
                <version>0.3</version>
                <configuration>
                    <appDefinition>${DCOS_DEPLOYMENT_FILE}</appDefinition>
                    <dcosUrl>${DCOS_URL}</dcosUrl>
                    <ignoreSslCertificate>true</ignoreSslCertificate>
                </configuration>
            </plugin>  

Error:
[INFO] --- dcos-maven-plugin:0.3:deploy (default-cli) @ dcos ---
[INFO] About to execute DC/OS deploy
[INFO] app definition: C:\cygwin\home\dcos\application.json
[INFO] legacy default app definition: C:\cygwin\home\dcos\app-definition.json
[INFO] dcos token: C:\cygwin\home\dcos.dcos-token
[INFO] dcos url: https://m1.dcos
[INFO] ignore ssl certificate: true
[INFO] deployable: EMPTY
[ERROR] Unable to perform deployment
java.lang.RuntimeException: Unable to read marathon app definition
at dcos.DcosPluginHelper.readJsonFileToMap(DcosPluginHelper.java:29)
at dcos.DcosPluginHelper.readJsonFileToMap(DcosPluginHelper.java:38)
at dcos.DcosDeployMojo.execute(DcosDeployMojo.java:27)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.io.FileNotFoundException: File 'C:\cygwin\home\ayen\dtmexamples\cloud\dcos\app-definition.json' does not exist
at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:292)
at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1765)
at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1800)
at dcos.DcosPluginHelper.readJsonFileToMap(DcosPluginHelper.java:27)
... 24 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Can't find the dcos-maven-plugin in repository

I've run into issues when running dcos:deploy goal. Output of mvn dcos:deploy:

[INFO] -----------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.955 s
[INFO] Finished at: 2017-05-02T15:58:58+02:00
[INFO] Final Memory: 13M/301M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'dcos' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/dchrzascik/.m2/repository), mesosphere-repo (http://downloads.mesosphere.io/maven), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR] 

I have added a proper section of pluginRepositories but it doesn't seem to work:

    <pluginRepositories>
        <pluginRepository>
            <id>mesosphere-repo</id>
            <name>Mesosphere Repo</name>
            <url>http://downloads.mesosphere.io/maven</url>
        </pluginRepository>
    </pluginRepositories>

How can I access the plugin? Is it really published in mesosphere repo or perhaps some account is needed to access it? samples/simple-sample doesn't work as well so I am positive that my pom.xml is correct.

Note: This issue is related to: #9 as publishing it to maven central would do the trick.

Publish plugin to central

The current configuration of plugin requires to setup plugin repository in pom.xml:

<pluginRepositories>
   <pluginRepository>
      <id>mesosphere-repo</id>
      <name>Mesosphere Repo</name>
      <url>http://downloads.mesosphere.io/maven</url>
   </pluginRepository>
</pluginRepositories>

The plugin should be published to maven central so that this fragment is not required.

Enable Metronome Jobs?

Can me make this work for a "job" in metronome.

Given a json like this:

{
"id": myapp",
"description": "myapp",
"run": {
"artifacts": [
{
"uri": "file:///docker.tar.gz"
}
],
"cmd": "java -Xmx768m -Xss256k -Djava.security.egd=file:/dev/./urandom -jar /app.jar",
"cpus": 0.1,
"mem": 1024,
"disk": 512,
"docker": {
"image": "us.gcr.io/myrepo/yournotready"
}
},
"schedules": [
{
"id": "default",
"enabled": true,
"cron": "0 0 * * *",
"timezone": "America/Chicago",
"concurrencyPolicy": "ALLOW",
"startingDeadlineSeconds": 600
}
]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.