~evilnick/juju-core/docs-redesign

« back to all changes in this revision

Viewing changes to src/getting-started.jade

  • Committer: Nick Veitch
  • Date: 2013-06-25 19:16:03 UTC
  • Revision ID: nick.veitch@canonical.com-20130625191603-d7s7z57ihbr44awu
First HTML5-only version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
extends inc/layout
2
 
 
3
 
block vars
4
 
  - var title='Getting Started'
5
 
  - var page='getting-started'
6
 
 
7
 
block content
8
 
  article.
9
 
    <section id="intro">
10
 
    <h1>Introduction</h1>
11
 
 
12
 
    <p>This tutorial will show you how to get started with Juju, including installing, configuring and bootstrapping a new Juju environment.
13
 
    Before you start you will need:</p>
14
 
    <ul>
15
 
    <li> An Ubuntu server or desktop to install the Juju software on.</li>
16
 
    <li> An environment which can provide a new server with an Ubuntu cloud operating system image on-demand. This includes services such as Amazon EC2 , HP Cloud or RackSpace. For testing purposes, you can also configure a local environment.</li>
17
 
    <li> It's also required that the environment provides a permanent storage facility such as Amazon S3. For the moment, though, the only environment supported is EC2, OpenStack, and LXC containers.</li>
18
 
    <li> An SSH key-pair. If you have not already set one up, you can generate an appropriate keypair with:</li>
19
 
    <pre>ssh-keygen -t rsa -b 2048</pre>
20
 
    </ul>
21
 
    </section>
22
 
 
23
 
    <section id="install">
24
 
    <h1 >Installation</h1>
25
 
 
26
 
    <p>
27
 
    To install Juju, you simply need to grab the latest juju-core package:</p>
28
 
 
29
 
    <pre>sudo apt-get update
30
 
    sudo apt-get install juju-core</pre>
31
 
 
32
 
    <p>Juju is provided automatically as a backport in Ubuntu Server. Backports are usually enabled by default, but if you've turned them off <a href="http://askubuntu.com/a/285474/235">here's how you can enable them</a>. If apt complains that it cannot find the packages you might need to use the PPA:</p>
33
 
 
34
 
    <pre><code>sudo add-apt-repository ppa:juju/devel
35
 
    sudo apt-get update && sudo apt-get install juju-core
36
 
    </code></pre>
37
 
    <p>Regular updates will be made to the backported packages, unless you want to follow along with Juju development we recommend users to not use the PPA.</p>
38
 
 
39
 
    <p>You can switch between the default (0.7) version and 1.10 versions by using the following:</p>
40
 
 
41
 
    <pre><code>sudo update-alternatives --set juju /usr/lib/juju-0.7/bin/juju</code></pre>
42
 
 
43
 
    <p>or to the new 1.10.0 release using:</p>
44
 
 
45
 
    <pre><code>sudo update-alternatives --set juju /usr/lib/juju-1.10.0/bin/juju</code></pre>
46
 
 
47
 
    <section id="config">
48
 
    <h1>Configuring</h1>
49
 
 
50
 
    <p>Now the Juju software is installed, it needs to be configured to use your particular cloud provider. This is done by generating and editing a file, "environments.yaml", which will live in your ~/.juju/ directory. You can generate the environments file manually, but Juju also includes a boilerplate configuration option that will flesh out most of the file for you and minimise the amount of work (and potential errors).</p>
51
 
    <p>To generate an initial config file, you simply need to run:</p>
52
 
    <pre><code>juju generate-config -w</code></pre>
53
 
 
54
 
    <p>The -w switch causes the file to be written to your ~/.juju directory if an environments.yaml file does not already exist. It will also create the ~./juju directory if that does not exist.</p>
55
 
    <p>This file will contain sample profiles for different types of cloud services, but you will need to edit the files to provide specific information for your cloud provider. Sections are created for Amazon (AWS) services, HPCloud and a generic OpenStack instance. For more specifics on what needs to be changed, see the relevant sections below.</p>
56
 
    <ul>
57
 
     <li><a href="config-aws.html">Configuring for Amazon AWS</a></li>
58
 
     <li><a href="config-hpcloud.html">Configuring for HP Cloud</a></li>
59
 
     <li><a href="config-openstack.html">Configuring for OpenStack</a></li>
60
 
    </ul>
61
 
 
62
 
    </section>
63
 
    <section id="test">
64
 
    <h1>Testing your setup</h1>
65
 
 
66
 
    <p>Once you have installed and configured Juju, it is probably a good idea to take it for a bit of a test drive and check that everything is working as expected. Because Juju makes it really easy to deploy services, this is actually quick and straightforward.</p>
67
 
 
68
 
    <aside>
69
 
    <iframe class="youtube-player" type="text/html" width="400" height="300" src="http://www.youtube.com/embed/0AT6qKyam9I" frameborder="0">
70
 
    </iframe>
71
 
    </aside>
72
 
 
73
 
    <p> The first thing to do is set up a bootstrap environment. This is an instance in the cloud that Juju will use to deploy and control other services with. It will be created according to the configuration you have provided, and your SSH key will automatically be uploaded so that Juju can communicate securely with the bootstrap instance. </p>
74
 
 
75
 
    <pre>juju bootstrap </pre>
76
 
 
77
 
    <p class="note"><strong>Note:</strong> If you have multiple environments configured, you can choose which one to address with a particular command by adding the -e switch followed by the environment name, E.g. "-e hpcloud".</p>
78
 
 
79
 
    <p>You may have to wait a few moments for this command to return, as it needs to perform various tasks and contact your cloud provider. </p>
80
 
    <p>Assuming it returns successfully (otherwise see <a href="#errors">common error messages and what to do about them</a>), we can now deploy some services and explore the basic operations of Juju.</p>
81
 
    <p>To start with, we will deploy Wordpress, by running this command:</p>
82
 
    <pre>juju deploy wordpress</pre>
83
 
    <p>Now juju will fetch the Wordpress charm and use it, through the bootstrap instance to request and deploy whatever resources it needs to set up this service.</p>
84
 
    <p>Wordpress needs a database though, so we will also deploy one of those:</p>
85
 
    <pre>juju deploy mysql</pre>
86
 
    <p>Once again, juju will do whatever is necessary to deploy this service for you, and it may take some time for the command to return.</p>
87
 
    <p class="note"><strong>Note:</strong> If you want to get more information on what is actually happening, or to help resolve problems, you can add the -v switch to the juju command to get verbose output.</p>
88
 
    <p>Although we have deployed Wordpress and a MySQL database, they are not linked together in any way yet. To do this we should run:</p> 
89
 
 
90
 
    <pre>juju add-relation wordpress mysql</pre>
91
 
 
92
 
    <p>This command uses information provided by the relevant charms to associate these services with each other in whatever way makes sense. There is much more to be said about linking services together which <a href="#add-relation">is covered in the juju command documentation</a>, but for the moment, we just need to know that it will link these services together.</p>
93
 
    <p>In order to make our Wordpress public, we now need to expose this service:<p>
94
 
    <pre>juju expose wordpress</pre>
95
 
    <p>This service will now be configured to respond to web requests, so visitors can see it. But where exactly is it? If we run the juju status command, we will be able to see what services are running, and where they are located.<p>
96
 
    <pre>juju status</pre>
97
 
    <p>The output from this command should look something like this:</p>
98
 
    <pre><code>
99
 
    $juju status
100
 
    machines:
101
 
    &nbsp;&nbsp;"0":
102
 
    &nbsp;&nbsp;&nbsp;&nbsp;agent-state: started
103
 
    &nbsp;&nbsp;&nbsp;&nbsp;agent-version: 1.10.0
104
 
    &nbsp;&nbsp;&nbsp;&nbsp;dns-name: ec2-50-16-167-135.compute-1.amazonaws.com
105
 
    &nbsp;&nbsp;&nbsp;&nbsp;instance-id: i-781bf614
106
 
    &nbsp;&nbsp;&nbsp;&nbsp;series: precise
107
 
    &nbsp;&nbsp;"1":
108
 
    &nbsp;&nbsp;&nbsp;&nbsp;agent-state: started
109
 
    &nbsp;&nbsp;&nbsp;&nbsp;agent-version: 1.10.0
110
 
    &nbsp;&nbsp;&nbsp;&nbsp;dns-name: ec2-23-22-225-54.compute-1.amazonaws.com
111
 
    &nbsp;&nbsp;&nbsp;&nbsp;instance-id: i-9e8927f6
112
 
    &nbsp;&nbsp;&nbsp;&nbsp;series: precise
113
 
    &nbsp;&nbsp;"2":
114
 
    &nbsp;&nbsp;&nbsp;&nbsp;agent-state: started
115
 
    &nbsp;&nbsp;&nbsp;&nbsp;agent-version: 1.10.0
116
 
    &nbsp;&nbsp;&nbsp;&nbsp;dns-name: ec2-54-224-220-210.compute-1.amazonaws.com
117
 
    &nbsp;&nbsp;&nbsp;&nbsp;instance-id: i-5c440436
118
 
    &nbsp;&nbsp;&nbsp;&nbsp;series: precise
119
 
    services:
120
 
    &nbsp;&nbsp;mysql:
121
 
    &nbsp;&nbsp;&nbsp;&nbsp;charm: cs:precise/mysql-18
122
 
    &nbsp;&nbsp;&nbsp;&nbsp;exposed: false
123
 
    &nbsp;&nbsp;&nbsp;&nbsp;relations:
124
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;db:
125
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- wordpress
126
 
    &nbsp;&nbsp;&nbsp;&nbsp;units:
127
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mysql/0:
128
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;agent-state: started
129
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;agent-version: 1.10.0
130
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;machine: "1"
131
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public-address: ec2-23-22-225-54.compute-1.amazonaws.com
132
 
    &nbsp;&nbsp;wordpress:
133
 
    &nbsp;&nbsp;&nbsp;&nbsp;charm: cs:precise/wordpress-12
134
 
    &nbsp;&nbsp;&nbsp;&nbsp;exposed: true
135
 
    &nbsp;&nbsp;&nbsp;&nbsp;relations:
136
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;db:
137
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- mysql
138
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loadbalancer:
139
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- wordpress
140
 
    &nbsp;&nbsp;&nbsp;&nbsp;units:
141
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wordpress/0:
142
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;agent-state: started
143
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;agent-version: 1.10.0
144
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;machine: "2"
145
 
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public-address: ec2-54-224-220-210.compute-1.amazonaws.com
146
 
    </code></pre>
147
 
    <p>There is quite a lot of information here. the first section, titled <strong>machines:</strong>, details all the instances which are currently running. For each you will see the version of Juju they are running, their hostname, instance id and the series or version of Ubuntu they are running.</p>
148
 
    <p>After that, the sections list the services which are currently deployed. The information here differs slightly according to the service and how it is configured. It will however, always list the charm that was used to deploy the service, whether it is exposed or not, its address and whatever relationships exist.</p>
149
 
    <p>From this status readout, we can see that wordpress is exposed and ready. If we simply copy the address into a web browser, we should be able to see it running</p>
150
 
    <img src="./media/getting_started-wordpress.png" alt="Image showing wordpress in a web browser" > 
151
 
    <p>Congratulations, you have just deployed a service with Juju!</p>
152
 
    <p>Now you are ready to deploy whatever service you really want from the 100s available at the <a href="http://jujucharms.com">Juju Charm Store.</a></p>
153
 
    <p>To remove all current deployments and clear up everything in your cloud, you can run the command:</p>
154
 
    <pre><code>juju destroy-environment </code></pre>
155
 
    <p>This will remove everything, including the bootstrap node.</p>
156
 
    <p>To learn more about charms, including configuring options and managing running systems, you should continue to <a href="./charms.html">read the charm documentation.</a></p>
157
 
    </section>