cfcm 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,17 +1,64 @@
1
- cloudfoundry-chaos-monkey
2
- =========================
1
+ #cloudfoundry-chaos-monkey
3
2
 
4
3
  Chaos Monkey style service for Cloud Foundry
5
4
 
6
- Using Cloud Foundry Chaos Monkey
7
- --------------------------------
5
+ ##Using Cloud Foundry Chaos Monkey
8
6
 
9
7
  First off, grab the Cloud Foundry Chaos Monkey gem
10
8
 
11
- `gem install cfcm`
9
+ ```gem install cfcm```
12
10
 
13
- and then unleash the monkey! In this example, we'll use CFCM on an application named `myapp`, keeping between 2 and 5 instances. We want CFCM to have a 30% chance of adding or removing an instance every 10 seconds. Adding and removeing instances is known as "soft mode", that is, this is equvilant to doing "vmc instane [app] -1". There is a "hard mode" planned that is a bit more chaotic.
11
+ and then unleash the monkey!
14
12
 
15
- `cfcm soft [email] [password] myapp --min 2 --max 5 -p 30 -f 10`
13
+ ### Soft Mode
14
+ Soft mode will simply remove/add instances at random. This uses the standard VMC APIs and you can specify the minimum and maximum number of instances the app may have.
16
15
 
17
- It's as easy as that!
16
+ In this example, we'll use CFCM on an application named `myapp`, keeping between 2 and 5 instances. We want CFCM to have a 30% chance of adding or removing an instance every 10 seconds. Adding and removeing instances is known as "soft mode", that is, this is equvilant to doing "vmc instane [app] -1".
17
+
18
+ ```cfcm soft [email] [password] myapp --min 2 --max 5 -p 30 -f 10```
19
+
20
+ ### Hard Mode
21
+
22
+ Hard mode gets a bit more bananas. BOSH-inspired, there is an IaaS-layer shim that sits between CFCM and your virtual machines. Currently, the following IaaS layers are supported...
23
+
24
+ - vSphere
25
+
26
+ and the following are planned...
27
+
28
+ - AWS
29
+ - OpenStack
30
+ - BOSH (I realize this is a bit odd, but this will allow some interesting things in addition to straight IaaS)
31
+
32
+ As with BOSH, my goal is to allow the community to add their on IaaS layer. There's simply two commands that will be needed though; Power On and Power Off
33
+
34
+ There are two files that will be needed to run Hard Mode, a config file and an input file. The config file will contain the configuration specific to the IaaS you're targeting. The input file will list the VMs that are valid targets for CFCM. For vSphere, an example ```config.yml``` file would look like...
35
+
36
+ <pre>
37
+ host: 127.0.0.1
38
+ user: john_doe
39
+ password: p@ssw0rd
40
+ datacenter: Monkey Island
41
+ </pre>
42
+
43
+ and a sample ```input.list``` file would look like...
44
+
45
+ <pre>
46
+ cf-cfcm-testing-dea-001
47
+ cf-cfcm-testing-dea-002
48
+ cf-cfcm-testing-dea-003
49
+ cf-cfcm-testing-dea-004
50
+ cf-cfcm-testing-dea-005
51
+ </pre>
52
+
53
+ Note: These don't JUST have to be DEAs. Really, CFCM could be used to rip VMs out from any distributed systems. This could be other pieces of Cloud Foundry (Service Gateways, Cloud Controllers, Routers, etc.) or for something completely unrelated to Cloud Foundry (AD servers? Replica database servers?)
54
+
55
+ Then to unleash the monkey on your infrastructure, attempting to hit the VMs every 10 seconds with a 30% chance of taking out a VM, run...
56
+
57
+ ```cfcm hard --iaas vsphere -c config.yml -i input.list -f 10 -p 30```
58
+
59
+ ## To-Do
60
+
61
+ - Add option to add/remove more than one instance/VM at a time
62
+ - Implement the remaining IaaS layers
63
+ - Provide a proper interface for the community to insert an IaaS layer
64
+ - Add the ability to specify min/max VMs to be powered on for Hard Mode, including if we should power VMs back on (i.e. We shut down a DEA last time, let's power it back on and power off a Router)
@@ -64,6 +64,7 @@ module CFCM
64
64
  method_option :config, :aliases => ["--config", "-c"], :type => :string, :desc => "Path to IaaS config YML file (See Documentation)"
65
65
  method_option :probability, :aliases => ["--probability", "-p"], :type => :numeric, :desc => "[1-100] Probablity for the Chaos Monkey to add/remove an instance (Default: 10)"
66
66
  method_option :frequency, :aliases => ["--frequency", "-f"], :type => :numeric, :desc => "Number of seconds between attempts to add/remove an instance (Default: 10)"
67
+ method_option :dry_run, :aliases => ["--dry-run", "-d"], :type => :boolean, :desc => "Simply output the actions that would be taken, do not perform them"
67
68
  def hard(probability = 10, frequency = 10)
68
69
  if (!options[:iaas] || !options[:input] || !options[:config])
69
70
  CFCM::Monkey::HardMonkey.new.show_help
@@ -79,8 +80,13 @@ module CFCM
79
80
  if options[:frequency]
80
81
  frequency = options[:frequency]
81
82
  end
82
-
83
- monkey = CFCM::Monkey::HardMonkey.new(options[:iaas], options[:config], options[:input], probability, frequency)
83
+ dry_run = false
84
+ if (options[:dry_run])
85
+ dry_run = true
86
+ end
87
+
88
+ puts "Awakening the monkey on your #{options[:iaas]} infrastructure with a #{probability}% chance of chaos every #{frequency} second#{frequency > 1? "s" : ""}"
89
+ monkey = CFCM::Monkey::HardMonkey.new(options[:iaas], options[:config], options[:input], probability, frequency, dry_run)
84
90
  monkey.start
85
91
  end
86
92
  end
@@ -60,10 +60,11 @@ module CFCM
60
60
  puts "Description coming soon"
61
61
  end
62
62
 
63
- def initialize(iaas, config_file, input_file, probability, frequency)
63
+ def initialize(iaas, config_file, input_file, probability, frequency, dry_run = false)
64
64
 
65
65
  @probability = probability
66
66
  @frequency = frequency
67
+ @dry_run = dry_run
67
68
 
68
69
  # Parse the config file
69
70
  @config = YAML.load_file(config_file)
@@ -90,7 +91,11 @@ module CFCM
90
91
  if (Random.rand(100) + 1) <= @probability
91
92
  vm = @input.sample
92
93
  puts "Sending Power Off to #{vm}"
93
- @iaas_interface.power_off_vm(vm)
94
+ if @dry_run
95
+ puts "Power Off not sent -- runing in dry run mode"
96
+ else
97
+ @iaas_interface.power_off_vm(vm)
98
+ end
94
99
  end
95
100
  end
96
101
  end
@@ -1,3 +1,3 @@
1
1
  module CFCM
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfcm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-05 00:00:00.000000000 Z
12
+ date: 2012-09-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor