dev-lxc 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4d56770910d2c693b886f65c3b233d8aeca752a
4
- data.tar.gz: b0e22969f25e6e3def0807322f5041ca51482bb8
3
+ metadata.gz: 8824c3d24a5ba9e63bca4fdeeec59220ea35f656
4
+ data.tar.gz: b4f6c6304ceced41d0fc2913140d9540a55c6055
5
5
  SHA512:
6
- metadata.gz: b216fc333e7b71c654ae83ee247169be68cdb75dd072bb72f2e0bcf5e1a8f4fa66d1ebfcb26647ac80af92720d352c7cd6d880fd5f9560ba94c913b229b02946
7
- data.tar.gz: 2520dc769f5320ec1fecf416ad0b223d0553c0f1b44591288e5efac1e860e0258534ddd0097d1bbd71a4d0ae824f98bab8e9b21db7caf44654693b04d5be64da
6
+ metadata.gz: a9618dd49101a04df2d44a01ecbc67439af667bb93fa9314c5012f8af8c228dccece53eac7608590cc76599e229d7d9fab7568697f5b3523f33412c40b3c1093
7
+ data.tar.gz: 76897cac3f3b281060dc7ceb0fa667b71bfb74a127ea616bb1062f818c69a641062f0fd8aa95d8b646f2fe5499907286eb48f38b65c5e0134d7745ecd644fc85
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # dev-lxc Change Log
2
2
 
3
+ ## 2.5.0 (2017-02-08)
4
+
5
+ * Add memory_per_server config option to limit memory per server
6
+
3
7
  ## 2.4.0 (2017-02-03)
4
8
 
5
9
  * Refactor DHCP address management
data/README.md CHANGED
@@ -7,7 +7,7 @@ Cluster management includes the ability to manage snapshots of the containers wh
7
7
 
8
8
  ### Features
9
9
 
10
- 1. LXC 2.0 Containers - Resource efficient servers with fast start/stop times and standard init
10
+ 1. LXC Containers - Resource efficient servers with fast start/stop times and standard init
11
11
  2. Btrfs - Efficient, persistent storage backend provides fast, lightweight container snapshots
12
12
  3. Dnsmasq - DHCP networking and DNS resolution
13
13
  4. Base Containers - Containers that are built to resemble a traditional server
@@ -26,33 +26,58 @@ The Btrfs backed snapshots provide a quick clean slate which is helpful especial
26
26
  experimenting and troubleshooting. Or it can be used to build a customized cluster
27
27
  for demo purposes and be able to bring it up quickly and reliably.
28
28
 
29
- If you aren't familiar with using containers please read this introduction.
29
+ If you aren't familiar with using containers you might be interested in this introduction.
30
30
 
31
31
  [LXC 1.0 Introduction](https://www.stgraber.org/2013/12/20/lxc-1-0-blog-post-series/)
32
32
 
33
- ### Requirements
33
+ Additional dev-lxc related documentation can be found in the [docs folder](docs) in this repository.
34
34
 
35
- * Please follow the [Prerequisites Instructions](docs/prerequisites.md)
35
+ ## Build dev-lxc-platform instance
36
36
 
37
- When you are done with the prerequisites you should be able to log into the dev-lxc-platform VM and start using it.
37
+ The dev-lxc tool is used in a system that has been configured by the dev-lxc-platform cookbook.
38
38
 
39
- You must login to the root user to use the dev-lxc command.
39
+ The easiest way to build a dev-lxc-platform system is to download the dev-lxc-platform repository
40
+ and use Test Kitchen to build a VirtualBox Vagrant instance or an AWS EC2 instance.
41
+
42
+ Follow the instructions in the [dev-lxc-platform README](https://github.com/jeremiahsnapp/dev-lxc-platform) to build
43
+ a dev-lxc-platform instance.
44
+
45
+ ## Login to the dev-lxc-platform instance
46
+
47
+ Login to the dev-lxc-platform instance and switch to the root user to use the dev-lxc tool.
40
48
 
41
49
  ```
42
50
  cd dev-lxc-platform
43
- vagrant ssh
51
+ kitchen login <ec2 or vagrant>
44
52
  sudo -i
45
53
  ```
46
54
 
47
- ### Update dev-lxc gem
55
+ When you are logged in as the root user you should automatically enter a [byobu session](http://byobu.co/).
56
+
57
+ Byobu makes it easy to manage multiple terminal windows and panes. You can press `F1` to get help which includes a [list of keybindings](http://manpages.ubuntu.com/manpages/wily/en/man1/byobu.1.html#contenttoc8).
58
+
59
+ The prefix key is set to `Ctrl-o`
60
+
61
+ Some of the keys that will be most useful to you are:
62
+
63
+ * `option-Up`, `option-Down` to switch between Byobu sessions
64
+ * `option-Left`, `option-Right` to switch between windows in a session
65
+ * `shift-Left`, `shift-Right`, `shift-Up`, `shift-Down` to switch between panes in a window
66
+
67
+ ## Update dev-lxc gem
48
68
 
49
- Run the following command if you ever need to upgrade the dev-lxc gem inside the dev-lxc-platform VM.
69
+ Run the following command as the instance's root user if you ever need to upgrade the dev-lxc gem inside the dev-lxc-platform instance.
50
70
 
51
71
  ```
72
+ cd dev-lxc-platform
73
+ kitchen login <ec2 or vagrant>
74
+ sudo -i
52
75
  chef gem update dev-lxc
53
76
  ```
54
77
 
55
- ### Display Help
78
+ ## Demo: Build Chef Automate Cluster
79
+
80
+ ### Display dev-lxc help
56
81
 
57
82
  ```
58
83
  dev-lxc help
@@ -78,28 +103,7 @@ dev-lxc snapshot
78
103
  dl sn
79
104
  ```
80
105
 
81
- ### Demo: Build Chef Automate Cluster
82
-
83
- Log into the dev-lxc-platform VM's root user.
84
-
85
- ```
86
- cd dev-lxc-platform
87
- vagrant up # if the VM is not already running
88
- vagrant ssh
89
- sudo -i
90
- ```
91
-
92
- When you are logged in as the root user you should automatically enter a [byobu session](http://byobu.co/).
93
-
94
- Byobu makes it easy to manage multiple terminal windows and panes. You can press `fn-F1` to get help which includes a [list of keybindings](http://manpages.ubuntu.com/manpages/wily/en/man1/byobu.1.html#contenttoc8).
95
-
96
- Some of the keys that will be most useful to you are:
97
-
98
- * `option-Up`, `option-Down` to switch between Byobu sessions
99
- * `option-Left`, `option-Right` to switch between windows in a session
100
- * `shift-Left`, `shift-Right`, `shift-Up`, `shift-Down` to switch between panes in a window
101
-
102
- #### Create Base Container
106
+ ### Create Base Container
103
107
 
104
108
  The [base container](docs/base_containers.md) used for the cluster's containers must be created first. Let's use Ubuntu 14.04 for the base container.
105
109
 
@@ -107,7 +111,7 @@ The [base container](docs/base_containers.md) used for the cluster's containers
107
111
  dl create b-ubuntu-1404
108
112
  ```
109
113
 
110
- #### Create Config File
114
+ ### Create Config File
111
115
 
112
116
  Create the [dev-lxc.yml config file](docs/configuration.md) for the cluster.
113
117
 
@@ -138,7 +142,7 @@ Edit the dev-lxc.yml file:
138
142
  * (Optionally) If you built other clusters then you can modify the server names (including the nodes' `chef_server_url`) in this cluster to
139
143
  make them [unique from the other clusters](docs/manage_multiple_clusters.md).
140
144
 
141
- #### cluster-view
145
+ ### cluster-view
142
146
 
143
147
  Run the `cluster-view` command to create a Byobu session specifically for this cluster.
144
148
 
@@ -157,7 +161,7 @@ See the [usage docs](docs/usage.md) for more information about how to close/kill
157
161
  cluster-view /root/work/clusters/automate
158
162
  ```
159
163
 
160
- #### Specifying a Subset of Servers
164
+ ### Specifying a Subset of Servers
161
165
 
162
166
  Many dev-lxc subcommands can act on a subset of the cluster's servers by specifying a regular expression that matches the desired server names.
163
167
 
@@ -167,7 +171,7 @@ For example, the following command will show the status of the infrastructure no
167
171
  dl status node
168
172
  ```
169
173
 
170
- #### Build the Cluster
174
+ ### Build the Cluster
171
175
 
172
176
  dev-lxc knows to build the servers in an appropriate order.
173
177
 
@@ -182,13 +186,13 @@ dl up
182
186
  Note: You also have the option of running the `prepare-product-cache` subcommand which downloads required product packages to the cache.
183
187
  This can be helpful when you don't want to start building the cluster yet but you want the package cache ready when you build the cluster later.
184
188
 
185
- #### Use the Servers
189
+ ### Use the Servers
186
190
 
187
191
  At this point all of the cluster's servers should be running.
188
192
 
189
193
  If you setup the workstation's networking correctly as described in the prerequisites you should be able to ping any server from your workstation using it's FQDN. You can also browse to any server that has a web interface.
190
194
 
191
- Since the cluster has a Chef Server you can use the `chef-repo` subcommand to create a chef-repo directory in the VM that contains a knife.rb and all of the keys for the users and org validator clients that are defined in dev-lxc.yml. This makes it very easy to use tools such as knife or berkshelf.
195
+ Since the cluster has a Chef Server you can use the `chef-repo` subcommand to create a chef-repo directory in the host instance that contains a knife.rb and all of the keys for the users and org validator clients that are defined in dev-lxc.yml. This makes it very easy to use tools such as knife or berkshelf.
192
196
 
193
197
  ```
194
198
  dl chef
@@ -213,7 +217,7 @@ dl at chef
213
217
 
214
218
  Since the cluster has a Chef Server and an infrastructure node dev-lxc made sure it configured the node's chef-client for the Chef Server so it is easy to converge the node.
215
219
 
216
- #### Manage the Cluster
220
+ ### Manage the Cluster
217
221
 
218
222
  The right pane of the "cluster" window should show `dev-lxc status` output. This shows the status of each server including any existing snapshots.
219
223
 
@@ -21,6 +21,13 @@ The contents of `dev-lxc.yml` should look like this.
21
21
  # base_container must be the name of an existing container
22
22
  base_container: b-ubuntu-1404
23
23
 
24
+ # memory_per_server sets the maximum amount of user memory (including file cache) for each server.
25
+ # dev-lxc will set the `memory.limit_in_bytes` cgroup for each server to apply this limit.
26
+ # If no units are specified, the value is interpreted as bytes.
27
+ # You can use suffixes to represent larger units — k or K for kilobytes, m or M for megabytes, and g or G for gigabytes.
28
+ # The default behavior is that no limit is set.
29
+ #memory_per_server: 4G
30
+
24
31
  # list any host directories you want mounted into the servers
25
32
  #mounts:
26
33
  # - /root/work root/work
@@ -96,8 +103,7 @@ As you can see there are four server types represented by five servers.
96
103
 
97
104
  #### Global Settings
98
105
 
99
- The global settings used by each of the server types are `enable_build_snapshots`, the `base_container`, a list of `mounts` and
100
- a list of `ssh-keys`. These settings are described in the config comments.
106
+ The global settings used by each of the server types are `enable_build_snapshots`, the `base_container`, `memory_per_server`, a list of `mounts` and a list of `ssh-keys`. These settings are described in the config comments.
101
107
 
102
108
  Be sure to set `base_container` in the `dev-lxc.yml` to an existing container's name.
103
109
  This container will be cloned to create each container in the cluster.
@@ -106,7 +112,7 @@ If you don't already have a container to use as a `base_container` then you can
106
112
 
107
113
  #### Server Specific Settings
108
114
 
109
- It is possible to define different values for `enable_build_snapshots`, `base_container`, `mounts` or `ssh-keys` for a particular server type or even for a particular server as you can see in the following snippet.
115
+ It is possible to define different values for `enable_build_snapshots`, `base_container`, `memory_per_server`, `mounts` or `ssh-keys` for a particular server type or even for a particular server as you can see in the following snippet.
110
116
 
111
117
  ```
112
118
  nodes:
@@ -123,7 +129,7 @@ is not specified then a dynamic IP address is assigned when the server starts.
123
129
  #### mixlib-install Library Automatically Manages a Cache of Product Packages
124
130
 
125
131
  dev-lxc uses the [mixlib-install](https://github.com/chef/mixlib-install) library to download Chef products
126
- to a cache in `/var/dev-lxc` in the host VM. This cache is automatically mounted into each server when it starts.
132
+ to a cache in `/var/dev-lxc` in the host instance. This cache is automatically mounted into each server when it starts.
127
133
 
128
134
  A list of Chef products to be installed can be defined for each server
129
135
  using [product names that mixlib-install understands](https://github.com/chef/mixlib-install/blob/master/PRODUCT_MATRIX.md).
data/lib/dev-lxc/cli.rb CHANGED
@@ -67,6 +67,13 @@ module DevLXC::CLI
67
67
  # base_container must be the name of an existing container
68
68
  base_container: b-ubuntu-1404
69
69
 
70
+ # memory_per_server sets the maximum amount of user memory (including file cache) for each server.
71
+ # dev-lxc will set the `memory.limit_in_bytes` cgroup for each server to apply this limit.
72
+ # If no units are specified, the value is interpreted as bytes.
73
+ # You can use suffixes to represent larger units — k or K for kilobytes, m or M for megabytes, and g or G for gigabytes.
74
+ # The default behavior is that no limit is set.
75
+ #memory_per_server: 4G
76
+
70
77
  # list any host directories you want mounted into the servers
71
78
  #mounts:
72
79
  # - /root/work root/work
@@ -26,6 +26,10 @@ module DevLXC
26
26
  enable_build_snapshots = server_config["enable_build_snapshots"] if server_config.key?("enable_build_snapshots")
27
27
  enable_build_snapshots = true if enable_build_snapshots.nil?
28
28
 
29
+ memory_per_server = cluster_config[server_type]["memory_per_server"]
30
+ memory_per_server ||= cluster_config["memory_per_server"]
31
+ memory_per_server = server_config["memory_per_server"] if server_config["memory_per_server"]
32
+
29
33
  mounts = ["/var/dev-lxc var/dev-lxc"]
30
34
  if cluster_config[server_type]["mounts"]
31
35
  mounts.concat(cluster_config[server_type]["mounts"])
@@ -49,6 +53,7 @@ module DevLXC
49
53
  additional_fqdn: nil,
50
54
  enable_build_snapshots: enable_build_snapshots,
51
55
  first_run: false,
56
+ memory_per_server: memory_per_server,
52
57
  mounts: mounts,
53
58
  ssh_keys: ssh_keys,
54
59
  base_container_name: base_container_name
@@ -266,9 +271,10 @@ module DevLXC
266
271
  def get_server(server_name)
267
272
  ipaddress = @server_configs[server_name][:ipaddress]
268
273
  additional_fqdn = @server_configs[server_name][:additional_fqdn]
274
+ memory_per_server = @server_configs[server_name][:memory_per_server]
269
275
  mounts = @server_configs[server_name][:mounts]
270
276
  ssh_keys = @server_configs[server_name][:ssh_keys]
271
- Server.new(server_name, ipaddress, additional_fqdn, mounts, ssh_keys)
277
+ Server.new(server_name, ipaddress, additional_fqdn, memory_per_server, mounts, ssh_keys)
272
278
  end
273
279
 
274
280
  def get_sorted_servers(server_name_regex=nil)
@@ -5,10 +5,11 @@ module DevLXC
5
5
  class Server
6
6
  attr_reader :container
7
7
 
8
- def initialize(name, ipaddress, additional_fqdn, mounts, ssh_keys)
8
+ def initialize(name, ipaddress, additional_fqdn, memory_per_server, mounts, ssh_keys)
9
9
  @container = DevLXC::Container.new(name)
10
10
  @ipaddress = ipaddress
11
11
  @additional_fqdn = additional_fqdn
12
+ @memory_per_server = memory_per_server
12
13
  @mounts = mounts
13
14
  @ssh_keys = ssh_keys
14
15
  end
@@ -43,6 +44,7 @@ module DevLXC
43
44
  @container.sync_mounts(@mounts)
44
45
  @container.start
45
46
  @container.sync_ssh_keys(@ssh_keys)
47
+ @container.set_cgroup_item('memory.limit_in_bytes', @memory_per_server) if @memory_per_server
46
48
  puts
47
49
  end
48
50
 
@@ -1,3 +1,3 @@
1
1
  module DevLXC
2
- VERSION = "2.4.0"
2
+ VERSION = "2.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dev-lxc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremiah Snapp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-03 00:00:00.000000000 Z
11
+ date: 2017-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -101,7 +101,6 @@ files:
101
101
  - docs/configuration.md
102
102
  - docs/dev-lxc_version_2.md
103
103
  - docs/manage_multiple_clusters.md
104
- - docs/prerequisites.md
105
104
  - docs/usage.md
106
105
  - lib/dev-lxc.rb
107
106
  - lib/dev-lxc/cli.rb
@@ -129,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
128
  version: '0'
130
129
  requirements: []
131
130
  rubyforge_project:
132
- rubygems_version: 2.6.8
131
+ rubygems_version: 2.6.10
133
132
  signing_key:
134
133
  specification_version: 4
135
134
  summary: A tool for building Chef server clusters using LXC containers
@@ -1,81 +0,0 @@
1
-
2
- #### Download and Install Prerequisites
3
-
4
- Download and install [VirtualBox 5.0.14+](https://www.virtualbox.org/wiki/Downloads).
5
-
6
- Download and install [Vagrant 1.8.5+](https://www.vagrantup.com/downloads.html).
7
-
8
- Install the vagrant-persistent-storage plugin.
9
-
10
- ```
11
- vagrant plugin install vagrant-persistent-storage
12
- ```
13
-
14
- Download and install [ChefDK](http://downloads.chef.io/).
15
-
16
- Run `chef shell-init` to read its usage docs. Then run the appropriate command for your shell.
17
-
18
- #### Download dev-lxc-platform
19
-
20
- ```
21
- git clone https://github.com/jeremiahsnapp/dev-lxc-platform.git
22
- ```
23
-
24
- #### Configure .kitchen.yml
25
-
26
- The cpus and memory .kitchen.yml values are set high to give enough resources to comfortably run multiple containers.
27
-
28
- Configure .kitchen.yml settings such as cpus, memory, synced_folders as desired.
29
-
30
- #### Build the dev-lxc-platform VM
31
-
32
- This should take less than 15 minutes.
33
-
34
- ```
35
- cd dev-lxc-platform
36
- kitchen converge
37
- ```
38
-
39
- #### Enable Vagrant Control for VM
40
-
41
- Typically we want to be able to shutdown and startup the dev-lxc-platform VM rather than use the usual kitchen model of converge and destroy so we need to enable Vagrant control over the VM for easier management.
42
-
43
- Install [direnv](http://direnv.net/) to use the `.envrc` file included in the
44
- dev-lxc-platform repo to automatically set `VAGRANT_CWD` upon entering the top level directory
45
- of the dev-lxc-platform repo.
46
-
47
- Vagrant commands run from this directory such as `vagrant up`, `vagrant ssh` and `vagrant halt` will manage the dev-lxc-platform VM.
48
-
49
- ```
50
- brew install direnv
51
- ```
52
-
53
- Be sure to follow the [direnv install instructions](http://direnv.net/) to add the appropriate line to your user's shell rc file.
54
-
55
- Run the following to approve the `.envrc` file
56
-
57
- ```
58
- direnv allow
59
- ```
60
-
61
- #### Setup Networking
62
-
63
- Your workstation needs to know how to resolve the .lxc domain that dev-lxc containers use.
64
-
65
- For OS X you can run the following command.
66
-
67
- ```
68
- sudo mkdir -p /etc/resolver
69
- echo nameserver 10.0.3.1 | sudo tee /etc/resolver/lxc
70
- ```
71
-
72
- Adding a route entry to the workstation enables direct communication between
73
- the workstation and any dev-lxc container.
74
-
75
- For OS X run the following command.
76
-
77
- The route entry won't survive a workstation reboot. You will have to recreate it as needed.
78
-
79
- ```
80
- sudo route -n add 10.0.3.0/24 33.33.34.13
81
- ```