github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/doc/simplestreams-metadata.txt (about)

     1  Introduction
     2  ============
     3  
     4  When Juju bootstraps, it needs two critical pieces of information:
     5  1. The uuid of the image to use when starting new compute instances
     6  2. The URL from which to download the correct version of a tools tarball
     7  
     8  The necessary information is stored in a json metadata format called simplestreams.
     9  The simplestreams format is used to describe related items in a structural fashion.
    10  See the Launchpad project lp:simplestreams for more details.
    11  
    12  For supported public clouds like Amazon, etc., no action is required by the
    13  end user so the following information is more for those interested in what happens
    14  under the covers. Those setting up a private cloud, or who want to change how things
    15  work (eg use a different Ubuntu image), need to pay closer attention.
    16  
    17  Basic Workflow
    18  ==============
    19  
    20  Whether images or tools, Juju uses a search path to try and find suitable metadata.
    21  The path components (in order of lookup) are:
    22  
    23  1. For a running model, the Juju controller database.
    24  2. User supplied location (specified by agent-metadata-url or image-metadata-url config settings)
    25  3. Provider specific locations (eg keystone endpoint if on Openstack)
    26  4. A web location with metadata for supported public clouds (https://streams.canonical.com/juju)
    27  
    28  Metadata may be inline signed, or unsigned. We indicate a metadata file is signed by using
    29  a '.sjson' extension. Each location in the path is first searched for signed metadata, and
    30  if none is found, unsigned metadata is attempted before moving onto the next path location.
    31  
    32  Juju ships with public keys used to validate the integrity of image and tools metadata obtained
    33  from https://streams.canonical.com/juju. So out of the box, Juju will "Just Work" with any supported
    34  public cloud, using signed metadata. Setting up metadata for a private (eg Openstack) cloud requires
    35  metadata to be generated using tools which ship with Juju (more below).
    36  
    37  Image Metadata Contents
    38  =======================
    39  
    40  Image metadata uses a simplestreams content type of "image-ids".
    41  The product id is formed as follows:
    42  "com.ubuntu.cloud:server:<series_version>:<arch>"
    43  eg
    44  "com.ubuntu.cloud:server:13.10:amd64"
    45  
    46  Non-released images (eg beta, daily etc) have product ids like:
    47  "com.ubuntu.cloud.daily:server:13.10:amd64"
    48  
    49  The metadata index and product files are required to be in the following directory tree
    50  (relative to the URL associated with each path component):
    51  
    52  <path_url>
    53    |-streams
    54        |-v1
    55           |-index.(s)json
    56           |-product-foo.(s)json
    57           |-product-bar.(s)json
    58  
    59  The index file must be called "index.(s)json" (sjson for signed). The various product files are
    60  named according to the Path values contained in the index file.
    61  
    62  Tools Metadata Contents
    63  =======================
    64  
    65  Tools metadata uses a simplestreams content type of "content-download".
    66  The product id is formed as follows:
    67  "com.ubuntu.juju:<series_version>:<arch>"
    68  eg
    69  "com.ubuntu.juju:12.04:amd64"
    70  
    71  The metadata index and product files are required to be in the following directory tree
    72  (relative to the URL associated with each path component). In addition, tools tarballs
    73  which Juju needs to download are also expected. The tarballs reside in a directory named
    74  after the stream to which they belong.
    75  
    76  <path_url>
    77    |-streams
    78    |   |-v1
    79    |      |-index.(s)json
    80    |      |-product-foo.(s)json
    81    |      |-product-bar.(s)json
    82    |
    83    |-<stream>
    84        |-tools-abc.tar.gz
    85        |-tools-def.tar.gz
    86        |-tools-xyz.tar.gz
    87  
    88  The index file must be called "index.(s)json" (sjson for signed). The product file and
    89  tools tarball name(s) match whatever is in the index/product files.
    90  
    91  Configuration
    92  =============
    93  
    94  For supported public clouds, no extra configuration is required; things work out-of-the-box.
    95  However, for testing purposes, or for non-supported cloud deployments, Juju needs to know
    96  where to find the tools and which image to run. Even for supported public clouds where all
    97  required metadata is available, the user can put their own metadata in the search path to
    98  override what is provided by the cloud.
    99  
   100  1. Bootstrap metadata
   101  
   102  The first location in the tools search path is the Juju controller database. When Juju bootstraps,
   103  it can optionally read tools and image metadata from a local directory and upload those to the database so
   104  that the tools are cached and available when needed.
   105  
   106  The --metadata-source bootstrap argument specifies a top level directory, the structure of which is as follows:
   107  
   108  <metadata-source-directory>
   109    |-tools
   110    |   |-streams
   111    |       |-v1
   112    |   |-released
   113    |   |-proposed
   114    |   |-testing
   115    |   |-devel
   116    |
   117    |-images
   118        |-streams
   119            |-v1
   120  
   121  Of course, if only custom image metadata is required, the tools directory will not be required,
   122  and vice versa.
   123  
   124  2. User specified URLs
   125  
   126  These are initially specified in the environments.yaml file (and then subsequently copied to the
   127  jenv file when the model is bootstrapped). For images, use "image-metadata-url"; for tools,
   128  use "agent-metadata-url". The URLs can point to a world readable container/bucket in the cloud,
   129  an address served by a http server, or even a shared directory accessible by all node instances
   130  running in the cloud.
   131  
   132  eg assume an Apache http server with base URL https://juju-metadata, providing access to
   133  information at <base>/images and <base>/tools. The Juju model yaml file could have
   134  the following entries (one or both):
   135  
   136  agent-metadata-url: https://juju-metadata/tools
   137  image-metadata-url: https://juju-metadata/images
   138  
   139  The required files in each location is as per the directory layout described earlier.
   140  For a shared directory, use a URL of the form "file:///sharedpath".
   141  
   142  3. Provider specific storage
   143  
   144  Providers may allow additional locations to search for metadata and tools. For Openstack, keystone
   145  endpoints may be created by the cloud administrator. These are defined as follows:
   146  
   147  juju-tools      : the <path_url> value as described above in Tools Metadata Contents
   148  product-streams : the <path_url> value as described above in Image Metadata Contents
   149  
   150  4. Central web location (https://streams.canonical.com/juju)
   151  
   152  This is the default location used to search for image and tools metadata and is used if no matches
   153  are found earlier in any of the above locations. No user configuration is required.
   154  
   155  Deploying Private Clouds
   156  ========================
   157  
   158  There are two main issues when deploying a private cloud:
   159  1. Images ids will be specific to the cloud
   160  2. Often, outside internet access is blocked
   161  
   162  Issue 1 means that image id metadata needs to be generated and made available.
   163  Issue 2 means that tools need to be mirrored locally to make them accessible.
   164  
   165  Juju tools exist to help with generating and validating image and tools metadata.
   166  For tools, it is often easiest to just mirror https://streams.canonical.com/juju/tools.
   167  However image metadata cannot be simply mirrored because the image ids are taken
   168  from the cloud storage provider, so this need to be generated and validated using
   169  the commands described below.
   170  
   171  The available Juju metadata tools can be seen by using the help command:
   172    juju help metadata
   173  
   174  A summary of the overall workflow is (more detail next):
   175  - create a local directory in which to store image and tools metadata
   176  - generate image metadata to local directory
   177  - optionally download tools to local directory/tools
   178  Then either
   179  - juju bootstrap --metadata-source <local_directory>
   180  or
   181  - optionally, copy image metadata to somewhere in the metadata search path
   182  - optionally, mirror tools to somewhere in the metadata search path
   183  - optionally, configure agent-metadata-url and/or image-metadata-url
   184  
   185  If the bootstrap --metadata-source directory option is used, any image metadata and tools found
   186  in the specified directory will be uploaded automatically to the cloud storage for that deployment.
   187  This is useful for situations where image and tools metadata do not need to be shared amongst several
   188  users, since each Juju model will upload its own separate copy of the required files.
   189  
   190  Using the image-metadata-url and agent-metadata-url to point to publicly accessible locations is useful
   191  when several Juju models are to be deployed on a private cloud and the metadata should be shared.
   192  
   193  1. Image metadata
   194  
   195  Generate image metadata using
   196    juju metadata generate-image -d <metadata_dir>
   197  
   198  As a minimum, the above command needs to know the image id to use and a directory in which to write the files.
   199  Other required parameters like region, series, architecture etc are taken from the current Juju model (or
   200  a model specified with the -m option). These parameters can also be overridden on the command line.
   201  
   202  The image metadata command can be run multiple times with different regions, series, architecture, and
   203  it will keep adding to the metadata files. Once all required image ids have been added, the index and product
   204  json files are ready to use. These can be uploaded to a location in the Juju metadata search path or the bootstrap
   205  --metadata-source option may be used.
   206  
   207  Examples:
   208  1. image-metadata-url
   209   - upload contents of <metadata_dir> to http://somelocation
   210   - set image-metadata-url to http://somelocation/images
   211  2. bootstrap option
   212   - juju bootstrap --metadata-source <metadata_dir>
   213  
   214  To ensure that the image metadata has been generated and uploaded correctly, use the validation command to
   215  ensure an image id can be discovered for a given scenario (region series, arch):
   216    juju metadata validate-images
   217  
   218  If run without parameters, the validation command will take all required details from the current Juju
   219  model (or as specified by -m) and print the image id it would use to spin up an instance.
   220  Alternatively, series, region, architecture etc can be specified on the command line to override values
   221  in the model config.
   222  
   223  2. Tools metadata
   224  
   225  Generally, tools and related metadata is mirrored from https://streams.canonical.com/juju/tools. However,
   226  it is possible to manually generate metadata for a custom built tools tarball using:
   227    juju generate-tools -d <metadata_dir> --stream <stream>
   228  
   229  where the required tools tarballs are first placed in a directory <metadata_dir>/tools/<stream>.
   230  If unspecified, <stream> defaults to "released".
   231  Then, the contents of <metadata_dir> can be uploaded to a location in the Juju metadata search path or the
   232  bootstrap --metadata-source option may be used.
   233  
   234  Examples:
   235  1. agent-metadata-url
   236   - upload contents of <metadata_dir> to http://somelocation
   237   - set agent-metadata-url to http://somelocation/tools
   238  2. bootstrap option
   239   - juju bootstrap --metadata-source <tools_dir>
   240  
   241  Note that image and tools metadata are generally written into the same local directory and the bootstrap
   242  --metadata-source option will upload both types of metadata.
   243  
   244  As with image metadata, the validation command is used to ensure tools are available for Juju to use:
   245    juju metadata validate-tools
   246  
   247  The same comments apply. Run the validation tool without parameters to use details from the Juju
   248  model, or override values as required on the command line. See juju help metadata validate-tools
   249  for more details.