From 6005ef295485cc6a8fa559eab309a6d50bc4b478 Mon Sep 17 00:00:00 2001 From: Peter Matulis Date: Fri, 2 Nov 2018 16:21:05 -0400 Subject: [PATCH 1/6] begin refactor and reword --- src/en/charms.md | 2 - src/en/clouds.md | 2 +- src/en/tut-charms.md | 186 ++++++++++++++----------------------------- 3 files changed, 62 insertions(+), 128 deletions(-) diff --git a/src/en/charms.md b/src/en/charms.md index 9239329b1..2a008e1ba 100644 --- a/src/en/charms.md +++ b/src/en/charms.md @@ -14,7 +14,6 @@ Common charm-related tasks are listed below. - [Using constraints][charms-constraints] - [Configuring applications][charms-config] - [Managing relations][charms-relations] - - [Exposing applications][charms-exposing] - [Scaling applications][charms-scaling] - [Removing things][charms-destroy] - [Upgrading applications][charms-upgrading] @@ -36,7 +35,6 @@ Common charm-related tasks are listed below. [charms-constraints]: ./charms-constraints.md [charms-config]: ./charms-config.md [charms-relations]: ./charms-relations.md -[charms-exposing]: ./charms-exposing.md [charms-scaling]: ./charms-scaling.md [charms-destroy]: ./charms-destroy.md [charms-upgrading]: ./charms-upgrading.md diff --git a/src/en/clouds.md b/src/en/clouds.md index 610534137..e8c3ebb76 100644 --- a/src/en/clouds.md +++ b/src/en/clouds.md @@ -189,7 +189,7 @@ Here are some examples of manually adding a cloud: [clouds-aws]: ./help-aws.md [clouds-azure]: ./help-azure.md -[clouds-google]: ./help-google.md +[clouds-google]: ./google-gce.md [clouds-oracle]: ./help-oracle.md [clouds-rackspace]: ./help-rackspace.md [clouds-joyent]: ./help-joyent.md diff --git a/src/en/tut-charms.md b/src/en/tut-charms.md index 7f7c2b019..5f315f6e9 100644 --- a/src/en/tut-charms.md +++ b/src/en/tut-charms.md @@ -1,4 +1,4 @@ -Title: Introduction to Juju charms +Title: Working with charms and applications TODO: Add images To add (notes from PR #1093): 1. charms may be different depending on target OS @@ -9,59 +9,33 @@ TODO: Add images Should probably link to charms-exposing.md instead of repeating The Scaling back section should just reference charms-scaling.html The Removing applications section should just reference charms-destroy.html - This looks like a journey/walkthrough. Consider making a real one and modifying this page - Removing mediawiki gives the sense that we're back to square one but mariadb and haproxy are left dangling +# Working with charms and applications -# Introduction to Juju Charms - -The magic behind Juju is a collection of software components called *Charms*. -They contain all the instructions necessary for deploying and configuring -cloud-based applications. The charms publicly available in the online -[charm store](authors-charm-store.html) represent the distilled DevOps knowledge -of experts. Charms make it easy to reliably and repeatedly deploy applications, -then scale up as required with minimal effort. - -There are a variety of topics related to charms to be found in the left -navigation pane under **Charms**. The three main topics you should get to know -well are: - - - **[Deploying charms][deploy]** - which covers how to use charms to deploy - applications where and how you want them - - **[Charm relations][relations]** - which covers connecting applications - together - - **[Scaling][scaling]** - how to seamlessly scale up (or down) your deployed - applications. - - -## Walkthrough - -This section will take you through some of the common operations you will want -to perform with Juju. By no means will we be using all the features of Juju, but -you should gain an understanding of: +This page will take you through some of the common operations you will want +to perform with Juju. You should gain an understanding of: - - How to deploy a charm + - Deploying an application - Relating applications - - Exposing applications - - Scaling up applications + - Exposing an application + - Scaling up - Removing units - Removing applications - - Destroying your model -!!! Important: - These instructions assume that you have already added credentials for - your cloud. If you have not yet done this, please see - [Cloud credentials][credentials] first. You can also learn about clouds - on the central [Clouds][clouds] page. +Although you can follow along by using any backing cloud, for simplicity this +tutorial will use a local LXD cloud where the controller is named 'lxd' and the +model is named 'default'. If you are using a different cloud we'll assume +credentials have been added and that you have an empty model at your disposal. +Refer to the following resources if this is not the case: -A 'default' model is created automatically when you create a controller and -it's the model that will be used here. The controller used here is named -'gce-test' and is based on the [Google Compute Engine][clouds-gce]. + - [Clouds][clouds] + - [Credentials][credentials] + - [Models][models] We are going to set up a simple MediaWiki site, then prepare it for high traffic, before scaling it back and finally removing it altogether. -### Deploying the charms +### Deploying an application For a MediaWiki site, we will need the 'mediawiki' charm from the charm store. We can deploy that to our model like this: @@ -78,14 +52,8 @@ use MariaDB: juju deploy mariadb ``` -It may take a few minutes for Juju to actually fetch these charms from the store, -create new machines to put them on and install them, but as soon as the command -returns we are free to do other things, while Juju continues working in the -background. - -As we said at the beginning, we are going to scale up this application to cope -with a lot of traffic. To do that we will use a common TCP/HTTP load balancing -application, HAProxy, so we should also deploy a charm for that now: +We are now going to scale up this application in order to cope with a high +level of traffic. We will do so by using the HAProxy load balancer: ```bash juju deploy haproxy @@ -125,12 +93,11 @@ haproxy:peer haproxy:peer haproxy-peer peer mariadb:cluster mariadb:cluster mysql-ha peer ``` -### Adding relations +### Relating applications -The applications may now be running, but they have no idea of the existence of -each other, and aren't connected in any meaningful way. In order for MediaWiki -to make use of the MariaDB database for a backend, you need to add a -relation between them. +The applications may now be running, but they aren't connected in any +meaningful way. In order for MediaWiki to make use of the MariaDB database +a *relation* needs to be added between them. ```bash juju add-relation mediawiki:db mariadb @@ -140,33 +107,20 @@ Normally, we only need to reference the applications by name. In this case, we also need to add the interface that we would like to connect, as there are two potential ways these charms could be connected. -Behind the scenes, the charms that control these applications will now contact -each other and exchange information. In this case, the MediaWiki charm requests -a new database to be created; MariaDB obliges, and gives the MediaWiki charm the -credentials it needs to be able to access this database. - -The other relation we need to add is between MediaWiki and the HAProxy -application. - -HAProxy will provide loadbalancing for traffic to MediaWiki, but it needs to -know where the various MediaWiki applications are on the network. At this -stage there is only one, but that will change shortly. +The other relation we need to add is between MediaWiki and HAProxy: ```bash juju add-relation haproxy mediawiki ``` -Now that the relations are set up, there is one more thing to do before the -MediaWiki site is "live". +HAProxy will provide traffic load balancing to MediaWiki, but it needs to know +where the various MediaWiki applications are on the network. At this stage +there is only one, but that will change shortly. -### Exposing the site +### Exposing the application -By default, Juju is very secure. Juju itself, and the applications it deploys -can see the other applications in your cloud, but nothing and nobody else can. -This isn't much use for a web application we want users to connect to, but Juju can -easily make these applications public. With its understanding of the underlying -cloud, Juju can make whatever firewall changes are necessary to expose these -applications to the wider world: +Make HAProxy available to the world by making changes to the backing cloud's +firewall: ```bash juju expose haproxy @@ -211,33 +165,29 @@ db mariadb mediawiki regular Our MediaWiki site is now exposed via HAProxy. You can check this by pointing your browser to the IP address of HAProxy visible in the above output. In this -example, it is 35.196.126.59. A confirmation will be in the form of MediaWiki's -main page appearing, containing the message 'MediaWiki has been successfully -installed'. +example, it is 35.196.126.59. ### Scaling up -One of Juju's great strengths is that it makes it easy to scale your application -to meet fluctuations in demand. We're going to demonstrate this with with the -MediaWiki application we've just deployed. Scale is handled by adding and +Scale is handled by adding and removing units, and you can add 5 units simply with the following command: ```bash juju add-unit -n 5 mediawiki ``` -When you now check the output of the `juju status mediawiki` command, you'll see -that 5 newly provisioned machines have been deployed to run MediaWiki. However, -the load balancing is being performed by HAProxy, which is distributing any +The output to `juju status mediawiki` should now show that five newly +provisioned machines have been deployed to run MediaWiki. However, the load +balancing is still being performed by HAProxy, which is distributing any incoming connections to your cluster of MediaWiki machines, and the complexity of these added connections is being handled automatically by Juju. -### Scaling back +### Scaling down Reducing the scale of a deployment is almost as simple as increasing the scale, although you need to specify which specific units to remove. We currently have -a total of 6 units assigned to MediaWiki, for example, as can be seen in the -output of the `juju status mediawiki` command: +a total of six units assigned to MediaWiki, for example, as can be seen in the +output to `juju status mediawiki`: ```no-highlight Unit Workload Agent Machine Public address Ports Message @@ -260,59 +210,45 @@ A hidden part of the above process is that the machines the units were running on will be destroyed automatically if the machine is not a controller and not hosting other Juju managed containers. - ### Removing applications -If you no longer require MediaWiki, you can remove the entire application, along -with all the units and machines used to operate the application, with a single -command: +When an application is removed, all the units used to operate the application +are removed: ```bash juju remove-application mediawiki +juju remove-application mariadb +juju remove-application haproxy ``` -When the removal has completed, you should see no trace of 'mediawiki' in the -output of `juju status`, nor any of the units and machines that were used to -run the application. - -### Destroying the model +When the removals have completed, you should see no trace of any applications +in the output of `juju status`. The machines that were used to run these +applications should also be gone since that is the default behaviour: if there +are no other applications running on a machine then the machine itself will be +removed. -Finally, to complete this brief walkthrough, we're going to remove the model -we've used to host our applications. If this is a fresh Juju installation, you -will have been operating within the 'default' model that's automatically -generated when you bootstrap the environment. You can check which models you -have available, along with which one is active, marked by the * symbol, -with the `juju models` command. Your output should be similar to the -following: +Alternatively, you can simply remove the model with: ```bash -Controller: gce-test - -Model Cloud/Region Status Machines Cores Access Last connection -controller google/us-east1 available 1 4 admin just now -default* google/us-east1 available 2 2 admin 4 minutes ago +juju destroy-model default ``` -To remove the 'default' model we've been using for the MediaWiki deployment, -type `juju destroy-model default` and accept the warning that this step will -destroy all machines, applications, data and other resources associated with -that model. A few moments later you should find it no longer listed in the -output of the `juju models` command. +## Further reading -If you want to start again with a clean model, restoring Juju to the state it -was in before we deployed the MediaWiki charm, you can re-create the 'default' -model with: `juju add-model default`. +For more information on the subjects we've covered in this tutorial, see the +definitive documentation: -For more information on the subjects we've covered here, see our documentation -on **[deploying charms][deploy]**, **[charm relations][relations]** and -**[scaling deployed applications][scaling]**. + - [Deploying charms][charms-deploy] + - [Managing relations][charms-relations] + - [Scaling applications][charms-scaling] + - [Removing things][charms-destroy] -[deploy]: ./charms-deploying.html -[relations]: ./charms-relations.html -[scaling]: ./charms-scaling.html -[credentials]: ./credentials.html -[clouds]: ./clouds.html -[clouds-gce]: ./help-google.html +[clouds]: ./clouds.md +[credentials]: ./credentials.md +[charms-deploy]: ./charms-deploying.md +[charms-relations]: ./charms-relations.md +[charms-scaling]: ./charms-scaling.md +[charms-destroy]: ./charms-destroy.md From 1bc3e6cd5b36602062e4ee290d582ec0328770b5 Mon Sep 17 00:00:00 2001 From: Peter Matulis Date: Tue, 6 Nov 2018 23:16:08 -0500 Subject: [PATCH 2/6] dainty improvements --- src/en/tut-charms.md | 46 ++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/en/tut-charms.md b/src/en/tut-charms.md index 5f315f6e9..d4809b9de 100644 --- a/src/en/tut-charms.md +++ b/src/en/tut-charms.md @@ -1,19 +1,16 @@ -Title: Working with charms and applications -TODO: Add images - To add (notes from PR #1093): +Title: Working with charms, applications, and series +TODO: To add (notes from PR #1093): 1. charms may be different depending on target OS 2. can choose which charm to use; can deploy on a series that it doesn't claim to support 3. however, to have things 'just work', don't bother specifying anything and the charm will decide which OS/version to use - Should probably link to charms-exposing.md instead of repeating - The Scaling back section should just reference charms-scaling.html - The Removing applications section should just reference charms-destroy.html -# Working with charms and applications +# Working with charms, applications, and series -This page will take you through some of the common operations you will want -to perform with Juju. You should gain an understanding of: +In this tutorial you will apply knowledge pertaining to key Juju concepts +detailed elsewhere in this documentation. They are charms, applications, units, +and series. Specifically, you will gain experience in the following activities: - Deploying an application - Relating applications @@ -176,18 +173,18 @@ removing units, and you can add 5 units simply with the following command: juju add-unit -n 5 mediawiki ``` -The output to `juju status mediawiki` should now show that five newly -provisioned machines have been deployed to run MediaWiki. However, the load -balancing is still being performed by HAProxy, which is distributing any -incoming connections to your cluster of MediaWiki machines, and the complexity -of these added connections is being handled automatically by Juju. +There are now five newly provisioned machines that have been deployed to run +MediaWiki. However, the load balancing is still being performed by HAProxy, +which is distributing any incoming connections to your cluster of MediaWiki +machines, and the complexity of these added connections is being handled +automatically by Juju. ### Scaling down -Reducing the scale of a deployment is almost as simple as increasing the scale, -although you need to specify which specific units to remove. We currently have -a total of six units assigned to MediaWiki, for example, as can be seen in the -output to `juju status mediawiki`: +Reducing the scale of a deployment is almost as simple as increasing the scale. +When scaling down you need to specify which specific units to remove. We +currently have a total of six units assigned to MediaWiki, as can be seen in +the output to `juju status mediawiki`: ```no-highlight Unit Workload Agent Machine Public address Ports Message @@ -199,8 +196,8 @@ mediawiki/4 active idle 9 35.196.59.200 80/tcp Ready mediawiki/5 active idle 10 35.196.179.191 80/tcp Ready ``` -To scale back our deployment, use the `remove-unit` command followed by the -unit ID of each unit you'd like to remove: +To scale down a deployment, use the `remove-unit` command followed by the unit +ID of each unit you'd like to remove: ```bash juju remove-unit mediawiki/3 mediawiki/4 mediawiki/5 @@ -208,12 +205,11 @@ juju remove-unit mediawiki/3 mediawiki/4 mediawiki/5 A hidden part of the above process is that the machines the units were running on will be destroyed automatically if the machine is not a controller and not -hosting other Juju managed containers. +hosting any other application's units. ### Removing applications -When an application is removed, all the units used to operate the application -are removed: +When an application is removed, all the associated units are removed as well: ```bash juju remove-application mediawiki @@ -224,8 +220,8 @@ juju remove-application haproxy When the removals have completed, you should see no trace of any applications in the output of `juju status`. The machines that were used to run these applications should also be gone since that is the default behaviour: if there -are no other applications running on a machine then the machine itself will be -removed. +are no other application units running on a machine then the machine itself +will be removed. Alternatively, you can simply remove the model with: From 9774ccc6aded60e732d58b84f5a7d23cf6a7824a Mon Sep 17 00:00:00 2001 From: Peter Matulis Date: Wed, 7 Nov 2018 11:59:57 -0500 Subject: [PATCH 3/6] precision --- src/en/tut-charms.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/en/tut-charms.md b/src/en/tut-charms.md index d4809b9de..b502da21a 100644 --- a/src/en/tut-charms.md +++ b/src/en/tut-charms.md @@ -8,16 +8,16 @@ TODO: To add (notes from PR #1093): # Working with charms, applications, and series -In this tutorial you will apply knowledge pertaining to key Juju concepts -detailed elsewhere in this documentation. They are charms, applications, units, -and series. Specifically, you will gain experience in the following activities: +In this tutorial you will apply knowledge of key Juju concepts detailed +elsewhere in this documentation. These concepts are charms, applications, +units, and series. Specifically, you will gain experience in the following: - Deploying an application - - Relating applications + - Creating relations between applications - Exposing an application - - Scaling up - - Removing units - - Removing applications + - Scaling up an application + - Scaling down an application + - Removing applications, units, and machines Although you can follow along by using any backing cloud, for simplicity this tutorial will use a local LXD cloud where the controller is named 'lxd' and the @@ -90,7 +90,7 @@ haproxy:peer haproxy:peer haproxy-peer peer mariadb:cluster mariadb:cluster mysql-ha peer ``` -### Relating applications +### Creating relations between applications The applications may now be running, but they aren't connected in any meaningful way. In order for MediaWiki to make use of the MariaDB database @@ -114,7 +114,7 @@ HAProxy will provide traffic load balancing to MediaWiki, but it needs to know where the various MediaWiki applications are on the network. At this stage there is only one, but that will change shortly. -### Exposing the application +### Exposing an application Make HAProxy available to the world by making changes to the backing cloud's firewall: @@ -164,7 +164,7 @@ Our MediaWiki site is now exposed via HAProxy. You can check this by pointing your browser to the IP address of HAProxy visible in the above output. In this example, it is 35.196.126.59. -### Scaling up +### Scaling up an application Scale is handled by adding and removing units, and you can add 5 units simply with the following command: @@ -179,7 +179,7 @@ which is distributing any incoming connections to your cluster of MediaWiki machines, and the complexity of these added connections is being handled automatically by Juju. -### Scaling down +### Scaling down an application Reducing the scale of a deployment is almost as simple as increasing the scale. When scaling down you need to specify which specific units to remove. We @@ -207,7 +207,7 @@ A hidden part of the above process is that the machines the units were running on will be destroyed automatically if the machine is not a controller and not hosting any other application's units. -### Removing applications +### Removing applications, units, and machines When an application is removed, all the associated units are removed as well: @@ -243,6 +243,7 @@ definitive documentation: [clouds]: ./clouds.md +[models]: ./models.md [credentials]: ./credentials.md [charms-deploy]: ./charms-deploying.md [charms-relations]: ./charms-relations.md From 7c11761b6da837965aba2794eb117a2882aeb484 Mon Sep 17 00:00:00 2001 From: Peter Matulis Date: Thu, 8 Nov 2018 13:09:07 -0500 Subject: [PATCH 4/6] more precision --- src/en/tut-charms.md | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/en/tut-charms.md b/src/en/tut-charms.md index b502da21a..da0531f58 100644 --- a/src/en/tut-charms.md +++ b/src/en/tut-charms.md @@ -1,16 +1,16 @@ -Title: Working with charms, applications, and series -TODO: To add (notes from PR #1093): +Title: Working with charms and applications +TODO: To add (notes from PR #1093) in another tutorial: 1. charms may be different depending on target OS 2. can choose which charm to use; can deploy on a series that it doesn't claim to support 3. however, to have things 'just work', don't bother specifying anything and the charm will decide which OS/version to use -# Working with charms, applications, and series +# Working with charms and applications In this tutorial you will apply knowledge of key Juju concepts detailed elsewhere in this documentation. These concepts are charms, applications, -units, and series. Specifically, you will gain experience in the following: +and units. Specifically, you will gain experience in the following: - Deploying an application - Creating relations between applications @@ -19,6 +19,8 @@ units, and series. Specifically, you will gain experience in the following: - Scaling down an application - Removing applications, units, and machines +To achieve our goals we will set up a MediaWiki site. + Although you can follow along by using any backing cloud, for simplicity this tutorial will use a local LXD cloud where the controller is named 'lxd' and the model is named 'default'. If you are using a different cloud we'll assume @@ -29,40 +31,36 @@ Refer to the following resources if this is not the case: - [Credentials][credentials] - [Models][models] -We are going to set up a simple MediaWiki site, then prepare it for high -traffic, before scaling it back and finally removing it altogether. - ### Deploying an application -For a MediaWiki site, we will need the 'mediawiki' charm from the charm store. -We can deploy that to our model like this: +For MediaWiki, we will need the 'mediawiki' charm. We deploy it to the current +model like this: ```bash juju deploy mediawiki ``` -Now, the Mediawiki application needs a database to store information in. There -are several appropriate charms we could use, but for this walkthrough we will -use MariaDB: +Now, Mediawiki needs a database to store information in. There are several +appropriate charms we could use, but here we'll use MariaDB: ```bash juju deploy mariadb ``` -We are now going to scale up this application in order to cope with a high -level of traffic. We will do so by using the HAProxy load balancer: +We are now going to scale up the mediawiki application in order to cope with a +high level of traffic. We will do so by using the HAProxy load balancer: ```bash juju deploy haproxy ``` -After a while if you check what your model currently contains by running... +After a while if you check what your model currently contains by running: ```bash juju status ``` -...you should see something like this: +You should eventually see something like this: @@ -92,9 +90,9 @@ mariadb:cluster mariadb:cluster mysql-ha peer ### Creating relations between applications -The applications may now be running, but they aren't connected in any -meaningful way. In order for MediaWiki to make use of the MariaDB database -a *relation* needs to be added between them. +The three applications may now be running, but they aren't connected in any +meaningful way. In order for MediaWiki to make use of the MariaDB database a +*relation* needs to be added between them. ```bash juju add-relation mediawiki:db mariadb From 9f6688ae261a093da5de43fd773e666cf19bfa39 Mon Sep 17 00:00:00 2001 From: Peter Matulis Date: Mon, 18 Feb 2019 16:40:16 -0500 Subject: [PATCH 5/6] beating on the run command --- src/en/charms-deploying-advanced.md | 4 +-- src/en/charms-working-with-units.md | 55 ++++++++++++++++------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/en/charms-deploying-advanced.md b/src/en/charms-deploying-advanced.md index 93c645205..20627d350 100644 --- a/src/en/charms-deploying-advanced.md +++ b/src/en/charms-deploying-advanced.md @@ -118,7 +118,7 @@ Assuming a LXD cluster cloud named 'lxd-cluster' exists and has a node called juju bootstrap lxd-cluster --to node3 ``` -### deploy --to +### `deploy --to` command To deploy the 'haproxy' application to machine '2' we would do this: @@ -170,7 +170,7 @@ and added to the node. For example: juju deploy mariadb-k8s --to kubernetes.io/hostname=somehost ``` -### add-unit --to +### `add-unit --to` command To add a unit of 'rabbitmq-server' to machine '1': diff --git a/src/en/charms-working-with-units.md b/src/en/charms-working-with-units.md index d8e863cc8..54e7e45e9 100644 --- a/src/en/charms-working-with-units.md +++ b/src/en/charms-working-with-units.md @@ -66,45 +66,52 @@ juju scp -m testing foo.txt apache2/1: !!! Note: Juju cannot transfer files between two remote units because it uses public - key authentication exclusively and the native (OpenSSH) `scp` command disables - agent forwarding by default. Either the destination or the source must be local - (Juju client). + key authentication exclusively and the native (OpenSSH) `scp` command + disables agent forwarding by default. Either the destination or the source + must be local (Juju client). For more information, run the `juju help scp` command. -## The juju run command +## ??? -The `juju run` command can be used by devops or scripts to inspect or do work -on applications, units, or machines. Commands for applications or units are -executed in a hook context. Charm authors can use the run command to develop -and debug scripts that run in hooks. +The `run` command can be used to inspect or perform work on machines by +targeting applications, units, or actual machines. The command operates on a +per-model basis. -For example, to run uname on every instance: +!!! Note: + Only users with 'admin' model access can use the `run` command. + +For example, consider the Linux `uname` command in the below scenarios. + + - To target all machines in a model the `--all` option is used: ```bash -juju run "uname -a" --all +juju run 'uname' --all ``` -Or to run uptime on some instances: + - To target all units of specific applications the `--application` option is + used: ```bash -juju run "uptime" --machine=2 -juju run "uptime" --application=mysql +juju run 'uname' --application=mysql ``` -!!! Note: - When using `juju run` with the `--application` option, keep in mind - that whichever command you pass will run on *every unit* of that application. - When using `juju run` with the `--machine` option, the command is run as the - `root` user on the remote machine. - -When used in combination with certain applications you can script certain tasks. -For instance, in the 'hadoop' charm you can use `juju run` to initiate a -terasort: + - To target a single unit of a specific application the `--unit` option is + used: ```bash -juju run --unit hadoop-master/0 "sudo -u hdfs /usr/lib/hadoop/terasort.sh" +juju run 'uname' --unit=mysql/0,mysql/1 ``` -For more information see the `juju help run` command. + - To target specific machines the `--machines` option is used (command is run + as the 'root' user on the target machines). + +```bash +juju run 'uname' --machine=0,2 +``` + +!!! Positive "Pro tip": + Commands for applications or units are executed in a hook context. Charm + authors can therefore use the `run` command to develop and debug scripts + that run in hooks. From c8141aec96ce111e20fa5a1c6177122da2744cb4 Mon Sep 17 00:00:00 2001 From: Peter Matulis Date: Mon, 25 Feb 2019 10:40:44 -0500 Subject: [PATCH 6/6] ongoing --- src/en/authors-charm-metadata.md | 2 +- src/en/charms-working-with-units.md | 45 +++++++++++------------------ src/en/machine-auth.md | 6 ++++ src/en/reference-bundle.md | 6 ++-- 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/en/authors-charm-metadata.md b/src/en/authors-charm-metadata.md index ad55ffa4e..eeb1b0712 100644 --- a/src/en/authors-charm-metadata.md +++ b/src/en/authors-charm-metadata.md @@ -57,7 +57,7 @@ fields: sequence format if there are multiple people. - `tags`: A list of descriptive tags used for organisation purposes in the - Charm Store. Choose from among the following: + Charm Store. Choose from among the following common words: - analytics - big_data diff --git a/src/en/charms-working-with-units.md b/src/en/charms-working-with-units.md index 54e7e45e9..3df0d5f9e 100644 --- a/src/en/charms-working-with-units.md +++ b/src/en/charms-working-with-units.md @@ -1,33 +1,10 @@ Title: Working with units -TODO: Convert into a tutorial # Working with units -Each node that Juju manages is referred to as a "unit". Generally speaking, -when using Juju you interact with the applications at the application level. -There are times when working directly with units is useful though, particularly -for debugging purposes. Juju provides a few different commands to make this -easier. -## The juju ssh command - -The `juju ssh` command will connect you, via SSH, into a target unit. For -example: - -```bash -juju ssh mysql/3 -``` - -This will start an SSH session on the 3rd mysql unit. This is useful for -investigating things that happen on a unit, checking resources or viewing -system logs. - -It is possible to run commands via `juju ssh`, for example, `juju ssh 1 uname --a` will run the uname command on node one. This works for simple commands, -however for more complex commands we recommend using `juju run` instead. - -See also the `juju help ssh` command for more information. +## Connecting to units via SSH ## The juju scp command @@ -87,31 +64,43 @@ For example, consider the Linux `uname` command in the below scenarios. - To target all machines in a model the `--all` option is used: ```bash -juju run 'uname' --all +juju run --all uname ``` - To target all units of specific applications the `--application` option is used: ```bash -juju run 'uname' --application=mysql +juju run --application=mysql uname ``` - To target a single unit of a specific application the `--unit` option is used: ```bash -juju run 'uname' --unit=mysql/0,mysql/1 +juju run --unit=mysql/0,mysql/1 uname ``` - To target specific machines the `--machines` option is used (command is run as the 'root' user on the target machines). ```bash -juju run 'uname' --machine=0,2 +juju run --machine=0,2 uname ``` + +To pass options or arguments with the command precede it with '--'. For +example: + + ```bash +juju run --all -- hostname -f + ``` !!! Positive "Pro tip": Commands for applications or units are executed in a hook context. Charm authors can therefore use the `run` command to develop and debug scripts that run in hooks. + + + + + diff --git a/src/en/machine-auth.md b/src/en/machine-auth.md index 39affde33..1d9e32150 100644 --- a/src/en/machine-auth.md +++ b/src/en/machine-auth.md @@ -41,6 +41,12 @@ For example, to connect to a machine with an id of '0': juju ssh 0 ``` +You can also connect to a machine by specifying a unit: + +```bash +juju ssh nginx/3 +``` + An interactive pseudo-terminal (pty) is enabled by default. For the OpenSSH client, this corresponds to the `-t` option ("force pseudo-terminal allocation"). diff --git a/src/en/reference-bundle.md b/src/en/reference-bundle.md index 7466ef334..76221de46 100644 --- a/src/en/reference-bundle.md +++ b/src/en/reference-bundle.md @@ -74,9 +74,9 @@ series: bionic # # tags: # -# Sets descriptive tags. A tag is used for organisational purposes in the -# Charm Store. See https://docs.jujucharms.com/authors-charm-metadata for the -# list of valid tags. +# Sets descriptive tags. A tag is user-defined. It is used for organisational +# purposes in the Charm Store. See +# https://docs.jujucharms.com/authors-charm-metadata for examples. # tags: [monitoring]