marathon_deploy 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b3a0f127044b188815965b3e84ab4557089fba6c
4
+ data.tar.gz: 914fee4de65ceb166a9790fa4ca1b6d84af8981d
5
+ SHA512:
6
+ metadata.gz: 3b380869cd355157e8f323de645cd8b5da55be01241447e1bb6e0dfe3bb6ba0ec697b61facc3255fa5e1b1a3c576083dca6dca7c5b9bb1f419ccc8bbd6e17f7a
7
+ data.tar.gz: 7244d59e9504ec09c195ff4bf73a0fca16030644c29bbbc036cc59f57152c17bca2e08b2f5a1237305a500cfe333040f9735acb83293b4341d8cb982c2b0c43d
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ .buildpath
2
+ .project
3
+ /.bundle/
4
+ /.yardoc
5
+ /Gemfile.lock
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
12
+ *.bundle
13
+ *.so
14
+ *.o
15
+ *.a
16
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in marathon_deploy.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jonathan Colby
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/NOTES ADDED
@@ -0,0 +1,5 @@
1
+ # http://www.mudskipper-solutions.com/home/how-to-send-jsonhttp-using-ruby
2
+ # http://www.bls.gov/developers/api_ruby.htm
3
+ # https://gist.github.com/amirrajan/2369851
4
+ # http://mikeebert.tumblr.com/post/56891815151/posting-json-with-net-http
5
+ # https://github.com/augustl/net-http-cheat-sheet
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # MarathonDeploy
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'marathon_deploy'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install marathon_deploy
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/marathon_deploy/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/TODO ADDED
@@ -0,0 +1,11 @@
1
+ - SLACK notification
2
+ - https://mesosphere.com/blog/2015/04/02/continuous-deployment-with-mesos-marathon-docker/
3
+ - log to database
4
+ DONE datacenter handling, iterate
5
+ DONE deployment status polling
6
+ - config assembler / generate properties script ?
7
+ - read in ENVIRONMENT VARIABLES WITH MARATHON_ and add to deployment json ?
8
+ - inject / replce minimumHealthCapacity is 1, maximumOverCapacity is 1
9
+ DESCOPED custom external ports (must be provided in json)
10
+ - read macros %NAME% from yaml/json and verify they are defined
11
+ - gem structure / packaging / metadata
data/bin/deploy ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ # TODO
data/bin/deploy.rb ADDED
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'marathon_deploy/marathon_defaults'
4
+ require 'marathon_deploy/marathon_client'
5
+ require 'marathon_deploy/error'
6
+ require 'marathon_deploy/application'
7
+ require 'marathon_deploy/environment'
8
+ require 'optparse'
9
+ require 'logger'
10
+
11
+ options = {}
12
+
13
+ # DEFAULTS
14
+ options[:deployfile] = MarathonDefaults::DEFAULT_DEPLOYFILE
15
+ options[:verbose] = MarathonDefaults::DEFAULT_LOGLEVEL
16
+ options[:environment] = MarathonDefaults::DEFAULT_ENVIRONMENT_NAME
17
+ options[:marathon_endpoints] = nil
18
+ options[:logfile] = MarathonDefaults::DEFAULT_LOGFILE
19
+
20
+ OptionParser.new do |opts|
21
+ opts.banner = "Usage: deploy.rb [options]"
22
+
23
+ opts.on("-u","--url MARATHON_URL(S)", Array, "Default: #{options[:marathon_endpoints]}") do |u|
24
+ options[:marathon_endpoints] = u
25
+ end
26
+
27
+ opts.on("-l", "--logfile LOGFILE", "Default: STDOUT") do |l|
28
+ options[:logfile] = l
29
+ end
30
+
31
+ opts.on("-v", "--verbose", "Run verbosely") do |v|
32
+ options[:verbose] = Logger::DEBUG
33
+ end
34
+
35
+ opts.on("-f", "--file DEPLOYFILE" ,"Deploy file with json or yaml file extension. Default: #{options[:deployfile]}") do |f|
36
+ options[:deployfile] = f
37
+ end
38
+
39
+ opts.on("-e", "--environment ENVIRONMENT", "Default: #{options[:environment]}" ) do |e|
40
+ options[:environment] = e
41
+ end
42
+
43
+ opts.on_tail("-h", "--help", "Show this message") do
44
+ puts opts
45
+ exit
46
+ end
47
+ end.parse!
48
+
49
+ $LOG = options[:logfile] ? Logger.new(options[:logfile]) : Logger.new(STDOUT)
50
+ $LOG.level = options[:verbose]
51
+
52
+ deployfile = options[:deployfile]
53
+ environment = Environment.new(options[:environment])
54
+
55
+ marathon_endpoints = Array.new
56
+ if (options[:marathon_endpoints].nil?)
57
+ if (environment.is_production?)
58
+ marathon_endpoints = MarathonDefaults::DEFAULT_PRODUCTION_MARATHON_ENDPOINTS
59
+ else
60
+ marathon_endpoints = MarathonDefaults::DEFAULT_PREPRODUCTION_MARATHON_ENDPOINTS
61
+ end
62
+ else
63
+ marathon_endpoints = options[:marathon_endpoints]
64
+ end
65
+
66
+ begin
67
+ application = Application.new(deployfile)
68
+ rescue Error::IOError, Error::UndefinedMacroError,Error::MissingMarathonAttributesError,Error::UnsupportedFileExtension => e
69
+ $LOG.debug(e)
70
+ $LOG.error(e.message)
71
+ exit!
72
+ end
73
+
74
+ begin
75
+ application.add_envs({ :APPLICATION_NAME => application.id, :ENVIRONMENT => environment})
76
+ rescue Error::BadFormatError => e
77
+ $LOG.error(e)
78
+ exit!
79
+ end
80
+
81
+ if (!environment.is_production?)
82
+ application.overlay_preproduction_settings
83
+ end
84
+
85
+ puts "#" * 100
86
+ puts JSON.pretty_generate(application.json)
87
+ puts "#" * 100
88
+
89
+ # deploy to each endpoint
90
+ marathon_endpoints.each do |marathon_url|
91
+ begin
92
+ client = MarathonClient.new(marathon_url)
93
+ client.application = application
94
+ client.deploy
95
+ rescue Error::MissingMarathonAttributesError,Error::BadURLError, Timeout::Error => e
96
+ $LOG.error(e.message)
97
+ exit!
98
+ rescue Error::DeploymentError => e
99
+ $LOG.error("Deployment of #{application} failed => #{e}")
100
+ exit!
101
+ rescue SocketError, Error::MarathonError => e
102
+ $LOG.error("Problem talking to marathon endpoint => #{marathon_url} (#{e.message})")
103
+ exit!
104
+ end
105
+
106
+ end
data/bin/json2yaml.rb ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'marathon_deploy/yaml_json'
4
+ yaml = ARGV[0]
5
+ puts YamlJson.json2yaml(yaml,false)
@@ -0,0 +1,66 @@
1
+ {
2
+ "args": [
3
+ "properties.py && FOO=\"`cat /opt/etc/public-search-germany-webapp.properties | grep -v '^\\s*#' | grep -E '.+=.+'`\"; echo $FOO; echo; env $FOO; echo; env $FOO hostName=$HOSTNAME backend.instance.name=$HOSTNAME java -Dhttp.port=8080 -Dajp.port=8009 -Dinstance.confdir=file:///opt/etc -Dbackend.logdir=$MESOS_SANDBOX -Dlog.rootDir=$MESOS_SANDBOX -DlogDir=$MESOS_SANDBOX $CMD_OPTS -Xmx$JAVA_XMX -Xms$JAVA_XMS -jar $MESOS_SANDBOX/public-search-germany-webapp*.jar"
4
+ ],
5
+ "cmd": null,
6
+ "container": {
7
+ "docker": {
8
+ "image": "dockerregistry.mobile.rz/mobile-java8:latest",
9
+ "network": "BRIDGE",
10
+ "portMappings": [
11
+ {
12
+ "containerPort": 8080,
13
+ "hostPort": 0,
14
+ "protocol": "tcp"
15
+ },
16
+ {
17
+ "containerPort": 8009,
18
+ "hostPort": 0,
19
+ "protocol": "tcp"
20
+ }
21
+ ]
22
+ },
23
+ "type": "DOCKER"
24
+ },
25
+ "cpus": 0.1,
26
+ "env": {
27
+ "APPLICATION_NAME": "public-search-germany-webapp",
28
+ "CMD_OPTS": "",
29
+ "CONFIG_ASSEMBLER_BASE_URL": "http://mobile-config-assembler.service.consul/config-assembler",
30
+ "DATACENTER_NUMBER": "44",
31
+ "JAVA_XMS": "252m",
32
+ "JAVA_XMX": "504m",
33
+ "SERVERCLASS_NAME": "pubse",
34
+ "SERVICE_8009_NAME": "public-search-germany-webapp",
35
+ "SERVICE_8009_TAGS": "ajp",
36
+ "SERVICE_8080_CHECK_SCRIPT": "curl --fail --silent $HOST_IP:$SERVICE_PORT/fz/release-info",
37
+ "SERVICE_8080_NAME": "public-search-germany-webapp",
38
+ "SERVICE_8080_TAGS": "http,haproxy"
39
+ },
40
+ "healthChecks": [
41
+ {
42
+ "gracePeriodSeconds": 30,
43
+ "intervalSeconds": 10,
44
+ "maxConsecutiveFailures": 3,
45
+ "portIndex": 0,
46
+ "protocol": "TCP",
47
+ "timeoutSeconds": 30
48
+ },
49
+ {
50
+ "gracePeriodSeconds": 30,
51
+ "intervalSeconds": 10,
52
+ "maxConsecutiveFailures": 3,
53
+ "path": "/fz/release-info",
54
+ "portIndex": 0,
55
+ "protocol": "HTTP",
56
+ "timeoutSeconds": 30
57
+ }
58
+ ],
59
+ "id": "public-search-germany-webapp",
60
+ "instances": 4,
61
+ "mem": 512,
62
+ "storeUrls": [
63
+ "http://maven-download.mobile.rz/maven/hosted-mobile-deployment-productive-releases/de/mobile/public-search-germany-webapp/ecs-1558-gb70c745/public-search-germany-webapp-ecs-1558-gb70c745.jar"
64
+ ],
65
+ "uris": []
66
+ }
@@ -0,0 +1,54 @@
1
+ ---
2
+ args:
3
+ - properties.py && FOO="`cat /opt/etc/public-search-germany-webapp.properties | grep
4
+ -v '^\s*#' | grep -E '.+=.+'`"; echo $FOO; echo; env $FOO; echo; env $FOO hostName=$HOSTNAME
5
+ backend.instance.name=$HOSTNAME java -Dhttp.port=8080 -Dajp.port=8009 -Dinstance.confdir=file:///opt/etc
6
+ -Dbackend.logdir=$MESOS_SANDBOX -Dlog.rootDir=$MESOS_SANDBOX -DlogDir=$MESOS_SANDBOX
7
+ $CMD_OPTS -Xmx$JAVA_XMX -Xms$JAVA_XMS -jar $MESOS_SANDBOX/public-search-germany-webapp*.jar
8
+ cmd:
9
+ container:
10
+ docker:
11
+ image: dockerregistry.mobile.rz/mobile-java8:latest
12
+ network: BRIDGE
13
+ portMappings:
14
+ - containerPort: 8080
15
+ hostPort: 0
16
+ protocol: tcp
17
+ - containerPort: 8009
18
+ hostPort: 0
19
+ protocol: tcp
20
+ type: DOCKER
21
+ cpus: 0.1
22
+ env:
23
+ APPLICATION_NAME: public-search-germany-webapp
24
+ CMD_OPTS: ''
25
+ CONFIG_ASSEMBLER_BASE_URL: http://mobile-config-assembler.service.consul/config-assembler
26
+ DATACENTER_NUMBER: '44'
27
+ JAVA_XMS: 252m
28
+ JAVA_XMX: 504m
29
+ SERVERCLASS_NAME: pubse
30
+ SERVICE_8009_NAME: public-search-germany-webapp
31
+ SERVICE_8009_TAGS: ajp
32
+ SERVICE_8080_CHECK_SCRIPT: curl --fail --silent $HOST_IP:$SERVICE_PORT/fz/release-info
33
+ SERVICE_8080_NAME: public-search-germany-webapp
34
+ SERVICE_8080_TAGS: http,haproxy
35
+ healthChecks:
36
+ - gracePeriodSeconds: 30
37
+ intervalSeconds: 10
38
+ maxConsecutiveFailures: 3
39
+ portIndex: 0
40
+ protocol: TCP
41
+ timeoutSeconds: 30
42
+ - gracePeriodSeconds: 30
43
+ intervalSeconds: 10
44
+ maxConsecutiveFailures: 3
45
+ path: "/fz/release-info"
46
+ portIndex: 0
47
+ protocol: HTTP
48
+ timeoutSeconds: 30
49
+ id: public-search-germany-webapp
50
+ instances: 4
51
+ mem: 512
52
+ storeUrls:
53
+ - http://maven-download.mobile.rz/maven/hosted-mobile-deployment-productive-releases/de/mobile/public-search-germany-webapp/ecs-1558-gb70c745/public-search-germany-webapp-ecs-1558-gb70c745.jar
54
+ uris: []
@@ -0,0 +1,16 @@
1
+ ---
2
+ cmd: while true; echo "HELLO WORLD $(date)"; do sleep 1 ; done
3
+ cpus: 0.5
4
+ env:
5
+ APPLICATION_NAME: public-search-germany-webapp
6
+ CONFIG_ASSEMBLER_BASE_URL: http://mobile-config-assembler.service.consul/config-assembler
7
+ DATACENTER_NUMBER: '666'
8
+ JAVA_XMS: 252m
9
+ JAVA_XMX: 504m
10
+ SERVERCLASS_NAME: pubse
11
+ SERVICE_8009_NAME: public-search-germany-webapp
12
+ SERVICE_8009_TAGS: ajp
13
+ id: public-search-germany-webapp
14
+ instances: 15
15
+ mem: 32
16
+ uris: []
@@ -0,0 +1,24 @@
1
+ ---
2
+ cmd: while true ; do echo "i got probed ..." ; /bin/nc -l -p $PORT0 ; done
3
+ cpus: 0.5
4
+ env:
5
+ APPLICATION_NAME: public-search-germany-webapp
6
+ CONFIG_ASSEMBLER_BASE_URL: http://mobile-config-assembler.service.consul/config-assembler
7
+ DATACENTER_NUMBER: '666'
8
+ JAVA_XMS: 252m
9
+ JAVA_XMX: 504m
10
+ SPECIAL_PROPERTY: %%SPECIAL_PROPERTY%%
11
+ SERVERCLASS_NAME: pubse
12
+ SERVICE_8009_NAME: public-search-germany-webapp
13
+ SERVICE_8009_TAGS: ajp
14
+ id: content-webapp
15
+ instances: 3
16
+ mem: 32
17
+ uris: []
18
+ healthChecks:
19
+ - gracePeriodSeconds: 30
20
+ intervalSeconds: 10
21
+ maxConsecutiveFailures: 3
22
+ portIndex: 0
23
+ protocol: TCP
24
+ timeoutSeconds: 30
@@ -0,0 +1,18 @@
1
+ ---
2
+ cmd: while true ; do echo "i got probed ..." ; /bin/nc -l -p $PORT0 ; done
3
+ cpus: 0.5
4
+ env:
5
+ APPLICATION_NAME: public-search-germany-webapp
6
+ CONFIG_ASSEMBLER_BASE_URL: http://mobile-config-assembler.service.consul/config-assembler
7
+ DATACENTER_NUMBER: '666'
8
+ JAVA_XMS: 252m
9
+ JAVA_XMX: 504m
10
+ MYMACRO_TEST: ABC-%%MACRO_TEST%%-DEFG-%%MACRO_TEST%%-HIJKL
11
+ SERVERCLASS_NAME: pubse
12
+ SERVICE_8009_NAME: public-search-germany-webapp
13
+ SERVICE_8009_TAGS: ajp
14
+ id: content-webapp
15
+ instances: 1
16
+ mem: 32
17
+ uris: []
18
+ healthChecks: []
@@ -0,0 +1,67 @@
1
+ {
2
+ "args": [
3
+ "properties.py && FOO=\"`cat /opt/etc/public-search-germany-webapp.properties | grep -v '^\\s*#' | grep -E '.+=.+'`\"; echo $FOO; echo; env $FOO; echo; env $FOO hostName=$HOSTNAME backend.instance.name=$HOSTNAME java -Dhttp.port=8080 -Dajp.port=8009 -Dinstance.confdir=file:///opt/etc -Dbackend.logdir=$MESOS_SANDBOX -Dlog.rootDir=$MESOS_SANDBOX -DlogDir=$MESOS_SANDBOX $CMD_OPTS -Xmx$JAVA_XMX -Xms$JAVA_XMS -jar $MESOS_SANDBOX/public-search-germany-webapp*.jar"
4
+ ],
5
+ "cmd": null,
6
+ "container": {
7
+ "docker": {
8
+ "image": "dockerregistry.mobile.rz/mobile-java8:latest",
9
+ "network": "BRIDGE",
10
+ "portMappings": [
11
+ {
12
+ "containerPort": 8080,
13
+ "hostPort": 0,
14
+ "protocol": "tcp"
15
+ },
16
+ {
17
+ "containerPort": 8009,
18
+ "hostPort": 0,
19
+ "protocol": "tcp"
20
+ }
21
+ ]
22
+ },
23
+ "type": "DOCKER"
24
+ },
25
+ "cpus": 0.1,
26
+ "env": {
27
+ "APPLICATION_NAME": "public-search-germany-webapp",
28
+ "CMD_OPTS": "",
29
+ "CONFIG_ASSEMBLER_BASE_URL": "http://mobile-config-assembler.service.consul/config-assembler",
30
+ "DATACENTER_NUMBER": "44",
31
+ "MACRO_TEST": "this should be defined: %%MACRO_TEST%%",
32
+ "JAVA_XMS": "252m",
33
+ "JAVA_XMX": "504m",
34
+ "SERVERCLASS_NAME": "pubse",
35
+ "SERVICE_8009_NAME": "public-search-germany-webapp",
36
+ "SERVICE_8009_TAGS": "ajp",
37
+ "SERVICE_8080_CHECK_SCRIPT": "curl --fail --silent $HOST_IP:$SERVICE_PORT/fz/release-info",
38
+ "SERVICE_8080_NAME": "public-search-germany-webapp",
39
+ "SERVICE_8080_TAGS": "http,haproxy"
40
+ },
41
+ "healthChecks": [
42
+ {
43
+ "gracePeriodSeconds": 30,
44
+ "intervalSeconds": 10,
45
+ "maxConsecutiveFailures": 3,
46
+ "portIndex": 0,
47
+ "protocol": "TCP",
48
+ "timeoutSeconds": 30
49
+ },
50
+ {
51
+ "gracePeriodSeconds": 30,
52
+ "intervalSeconds": 10,
53
+ "maxConsecutiveFailures": 3,
54
+ "path": "/fz/release-info",
55
+ "portIndex": 0,
56
+ "protocol": "HTTP",
57
+ "timeoutSeconds": 30
58
+ }
59
+ ],
60
+ "id": "public-search-germany-webapp",
61
+ "instances": 4,
62
+ "mem": 512,
63
+ "storeUrls": [
64
+ "http://maven-download.mobile.rz/maven/hosted-mobile-deployment-productive-releases/de/mobile/public-search-germany-webapp/ecs-1558-gb70c745/public-search-germany-webapp-ecs-1558-gb70c745.jar"
65
+ ],
66
+ "uris": []
67
+ }