summaryrefslogtreecommitdiff
path: root/docs/en/guide/environments.html
blob: db82302d65af1471c651b2ab2f10a84399991430 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<!DOCTYPE html>
<html lang='en'>
<head>
<title>
Environments - LEAP Platform Documentation
</title>
<meta content='width=device-width, initial-scale=1.0' name='viewport'>
<meta charset='UTF-8'>
<base href="" />
<style>
  body {
    background: #444;
    display: flex;
    flex-direction: row;
    padding: 10px;
    margin: 0px;
  }
  #sidebar {
    flex: 0 0 250px;
    background: white;
    margin-right: 10px;
    padding: 20px;
  }
  #sidebar ul {
    list-style-type: none;
    padding-left: 0px;
    margin: 0;
  }
  #sidebar li { padding: 4px }
  #sidebar li a { text-decoration: none }
  #sidebar li.active { background: #444 }
  #sidebar li.active a { color: white }
  #sidebar li.level1 { padding-left: 20px }
  #sidebar li.level2 { padding-left: 40px }
  #main {
    flex: 1 1 auto;
    background: white;
    padding: 20px;
  }
  #title-box {
    padding-bottom: 20px;
    border-bottom: 5px solid #eee;
  }
  #title-box h1 {
    margin-top: 0px;
  }
  pre {
    padding: 10px;
    background: #eef;
  }
  code {
    background: #eef;
  }
  table {border-collapse: collapse}
  table td {
    border: 1px solid #ccc;
    padding: 4px;
    vertical-align: top;
  }
</style>
</head>
<body>
<div id='sidebar'>
<ul>
<li class=''>
<a href='../../index.html'>Home</a>
</li>
<li class='semi-active level0'>
<a class='' href='../guide.html'>Guide</a>
</li>
<li class=' level1'>
<a class='' href='getting-started.html'>Getting Started</a>
</li>
<li class=' level1'>
<a class='' href='config.html'>Configuration Files</a>
</li>
<li class=' level1'>
<a class='' href='nodes.html'>Nodes</a>
</li>
<li class=' level1'>
<a class='' href='keys-and-certificates.html'>Keys and Certificates</a>
</li>
<li class=' level1'>
<a class='' href='domains.html'>Domains</a>
</li>
<li class=' level1'>
<a class='' href='provider-configuration.html'>Provider Configuration</a>
</li>
<li class='active level1'>
<a class='' href='environments.html'>Environments</a>
</li>
<li class=' level1'>
<a class='' href='virtual-machines.html'>Virtual Machines</a>
</li>
<li class=' level1'>
<a class='' href='miscellaneous.html'>Miscellaneous</a>
</li>
<li class=' level1'>
<a class='' href='commands.html'>Command Line Reference</a>
</li>
<li class=' level0'>
<a class='' href='../tutorials.html'>Tutorials</a>
</li>
<li class=' level0'>
<a class='' href='../services.html'>Services</a>
</li>
<li class=' level0'>
<a class='' href='../upgrading.html'>Upgrading</a>
</li>
<li class=' level0'>
<a class='' href='../troubleshooting.html'>Troubleshooting</a>
</li>
<li class=' level0'>
<a class='' href='../details.html'>Details</a>
</li>
</ul>
</div>
<div id='main'>
<div id='title-box'>
<h1>Working with environments</h1>

<div id='summary'>How to partition the nodes into separate environments.</div>
</div>
<div id='content-box'>
<div id="TOC"><ol>
  <li>
    <a href="environments/index.html#assign-an-environment">Assign an environment</a>
  </li>
  <li>
    <a href="environments/index.html#environment-commands">Environment commands</a>
  </li>
  <li>
    <a href="environments/index.html#environment-specific-json-files">Environment specific JSON files</a>
  </li>
  <li>
    <a href="environments/index.html#bind-an-environment-to-a-platform-version">Bind an environment to a Platform version</a>
  </li>
</ol></div>

<p>With environments, you can divide your nodes into different and entirely separate sets. For example, you might have sets of nodes for &lsquo;testing&rsquo;, &lsquo;staging&rsquo; and &lsquo;production&rsquo;.</p>

<p>Typically, the nodes in one environment are totally isolated from the nodes in a different environment. Each environment will have its own separate database, for example.</p>

<p>There are a few exceptions to this rule: backup nodes, for example, will by default attempt to back up data from all the environments (excluding local).</p>

<h2><a name="assign-an-environment"></a>Assign an environment</h2>

<p>To assign an environment to a node, you just set the <code>environment</code> node property. This is typically done with tags, although it is not necessary. For example:</p>

<p><code>tags/production.json</code></p>

<pre><code>{
  "environment": "production"
}
</code></pre>

<p><code>nodes/mynode.json</code></p>

<pre><code>{
  "tags": ["production"]
}
</code></pre>

<p>There are several built-in tags that will apply a value for the environment:</p>

<ul>
<li><code>production</code>: An environment for nodes that are in use by end users.</li>
<li><code>development</code>: An environment to be used for nodes that are being used for experiments or staging.</li>
<li><code>local</code>: This environment gets automatically applied to all nodes that run only on local VMs. Nodes with a <code>local</code> environment are treated special and excluded from certain calculations.</li>
</ul>


<p>You don&rsquo;t need to use these and you can add your own.</p>

<h2><a name="environment-commands"></a>Environment commands</h2>

<ul>
<li><code>leap env</code> &ndash; List the available environments and disply which one is active.</li>
<li><code>leap env pin ENV</code> &ndash; Pin the current environment to ENV.</li>
<li><code>leap env unpin</code> &ndash; Remove the environment pin.</li>
</ul>


<p>The environment pin is only active for your local machine: it is not recorded in the provider directory and not shared with other users.</p>

<h2><a name="environment-specific-json-files"></a>Environment specific JSON files</h2>

<p>You can add JSON configuration files that are only applied when a specific environment is active. For example, if you create a file <code>provider.production.json</code>, these values will only get applied to the <code>provider.json</code> file for the <code>production</code> environment.</p>

<p>This will also work for services and tags. For example:</p>

<pre><code>provider.local.json
services/webapp.development.json
tags/seattle.production.json
</code></pre>

<p>In this example, <code>local</code>, <code>development</code>, and <code>production</code> are the names of environments.</p>

<h2><a name="bind-an-environment-to-a-platform-version"></a>Bind an environment to a Platform version</h2>

<p>If you want to ensure that a particular environment is bound to a particular version of the LEAP Platform, you can add a <code>platform</code> section to the <code>provider.ENV.json</code> file (where ENV is the name of the environment in question).</p>

<p>The available options are <code>platform.version</code>, <code>platform.branch</code>, or <code>platform.commit</code>. For example:</p>

<pre><code>{
  "platform": {
    "version": "1.6.1",
    "branch": "develop",
    "commit": "5df867fbd3a78ca4160eb54d708d55a7d047bdb2"
  }
}
</code></pre>

<p>You can use any combination of <code>version</code>, <code>branch</code>, and <code>commit</code> to specify the binding. The values for <code>branch</code> and <code>commit</code> only work if the <code>leap_platform</code> directory is a git repository.</p>

<p>The value for <code>commit</code> is passed directly through to <code>git log</code> to query for a list of acceptable commits. See <a href="https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html#_specifying_ranges">man gitrevisions</a> to see how to specify ranges. For example:</p>

<ul>
<li><code>HEAD^..HEAD</code> - current commit must be head of the branch.</li>
<li><code>3172444652af71bd771609d6b80258e70cc82ce9..HEAD</code> - current commit must be after 3172444652af71bd771609d6b80258e70cc82ce9.</li>
<li><code>refs/tags/0.6.0rc1..refs/tags/0.6.0rc2</code> - current commit must be after tag 0.6.0rc1 and before or including tag 0.6.0rc2.</li>
</ul>


</div>
</div>
</body>
</html>