github.com/Cloud-Foundations/Dominator@v0.3.4/user-guide/getting-started.md (about)

     1  # Getting Started
     2  How to get started with the **Dominator**. For a more in-depth understanding of
     3  the system, please read the
     4  [design document](../design-docs/Dominator/README.md).
     5  
     6  ## Overview
     7  The **Dominator** is a system for pushing machine images (kernel, operating
     8  system and application stack) to large numbers of machines and continuously
     9  keeping them in compliance with their *required image*. The system is comprised
    10  of several components:
    11  
    12  - [dominator](../cmd/dominator/README.md): a daemon which constantly polls the
    13    file-system state of each machine in the fleet
    14  - [filegen-server](../cmd/filegen-server/README.md): a daemon which computes
    15    file data on request from the [dominator](../cmd/dominator/README.md) (this is
    16    typically used to provide machine-specific files such as certificates and
    17    configuration files)
    18  - [imageserver](../cmd/imageserver/README.md): a daemon which hosts the images
    19    registered with the system and responds to management and data requests
    20  - [imagetool](../cmd/imagetool/README.md): a utility to manage images hosted on
    21    an [imageserver](../cmd/imageserver/README.md) (i.e. add image, delete image)
    22  - [mdbd](../cmd/mdbd/README.md): a companion daemon for the
    23    [dominator](../cmd/dominator/README.md) which interfaces to different
    24    implementations of a Machine Data Base, providing the
    25    [dominator](../cmd/dominator/README.md) with a manifest of machines in the
    26    fleet and their corresponding *RequiredImage* data
    27  - [subd](../cmd/subd/README.md): a daemon which runs on every machine in the
    28    fleet which constantly scans the local root file-system and responds to
    29    requests from the [dominator](../cmd/dominator/README.md) to poll the state of
    30    the file-system, fetch files from the
    31    [imageserver](../cmd/imageserver/README.md) and perform updates of the
    32    file-system
    33  
    34  ## Building from source code
    35  The software was developed for and tested with Linux. Most of the code should
    36  also compile with MacOS, except [subd](../cmd/subd/README.md), which depends on
    37  the advanced namespace management that is unique to Linux.
    38  
    39  First, grab a copy of the source code, using the following command:
    40  
    41  ```
    42  git clone https://github.com/Cloud-Foundations/Dominator.git
    43  ```
    44  
    45  This will create a sub-directory called `Dominator` containing the source code.
    46  You will also need some other repositories. You can use `go get` or run the
    47  following commands:
    48  
    49  ```
    50  git clone https://github.com/Cloud-Foundations/tricorder.git
    51  git clone https://github.com/golang/exp.git
    52  git clone https://github.com/aws/aws-sdk-go.git
    53  git clone https://gopkg.in/fsnotify/fsnotify.v0
    54  ```
    55  
    56  You can update the local copies of these repositories to the latest version of
    57  the source code by using the following command in each:
    58  
    59  ```
    60  git pull
    61  ```
    62  
    63  You will need [go1.7](https://golang.org/dl/) or newer to to compile the
    64  **Dominator** software. Create the `$HOME/go/bin` directory and set the `GOPATH`
    65  environment variable to `$HOME/go`. The following command will compile the
    66  software:
    67  
    68  ```
    69  make
    70  ```
    71  
    72  The compiled binaries will be available in `$HOME/go/bin`.
    73  
    74  ## Making certificates
    75  In order for the various components of the **Dominator** to communicate, each
    76  component will need SSL certificate+key pairs and/or Certificate Authority (CA)
    77  files, so that trust relationships can be established. This is commonly known as
    78  *TLS client authentication and authorisation*. Clients present a certificate to
    79  servers (endpoints) which proves their identity (authentication) and lists the
    80  RPC methods which they are permitted to call (authorisation). These certificates
    81  give unrestricted access to the listed RPC methods.
    82  
    83  This is necessary for operational security, so that you can control and audit
    84  who creates images and who can issue update requests to the *subs*.
    85  
    86  ### Creating a root CA
    87  You will need to create a CA which will be used as the root of trust for all the
    88  components. It is recommended that you do not use a commercial CA, since the CA
    89  can issue certificates that effectively give root-level access to your machines.
    90  Additionally, the trust relationships between the **Dominator** components are
    91  only needed within your infrastructure, so there is no benefit to a public
    92  (commercial) CA.
    93  
    94  Below are sample commands which would produce a CA with 3 year expiration:
    95  
    96  ```
    97  openssl genpkey -algorithm RSA -out root.key.pem -pkeyopt rsa_keygen_bits:4096
    98  openssl req -new -key root.key.pem -days 1096 -extensions v3_ca -batch -out root.csr -utf8 -subj '/CN=Dominator'
    99  openssl x509 -req -sha256 -days 1096 -in root.csr -signkey root.key.pem -set_serial 1 -out root.pem
   100  chmod a+r root.pem
   101  ```
   102  
   103  This root CA will be used to sign all the other certificate+key pairs. In
   104  addition, the `root.pem` file that is created should be copied to
   105  `/etc/ssl/CA.pem` on every machine which runs a daemon component of the
   106  **Dominator** ([dominator](../cmd/dominator/README.md),
   107  [filegen-server](../cmd/filegen-server/README.md),
   108  [imageserver](../cmd/imageserver/README.md) and [subd](../cmd/subd/README.md)).
   109  The simplest approach is to copy this file to all machines and/or including it
   110  in the installation image that every machine is booted with.
   111  
   112  ### Identity-only certificates
   113  Some components (endpoints) permit access to selected RPC methods based on
   114  identity only (these are "public" RPC methods). The same root CA may be used to
   115  sign these identity-only certificates if needed, however this requires you to
   116  build a certificate issuing system for users. An alternate *Identity CA* is
   117  supported. The *[Keymaster](https://github.com/Symantec/keymaster)* is a good
   118  choice for issuing these certificates. This root CA should be placed in
   119  `/etc/ssl/IdentityCA.pem` and will be trusted for identity only (not for
   120  granting unlimited access to RPC methods).
   121  
   122  ### Creating a certificate+key for [subd](../cmd/subd/README.md)
   123  Using the previously created root certificate+key, you can create and sign a
   124  certificate and key pair for [subd](../cmd/subd/README.md) using the
   125  [make-cert](../scripts/make-cert) utility provided in the source repository.
   126  Use the following command to generate the certificate and key pair:
   127  
   128  ```
   129  make-cert root subd AUTO subd cmd/subd/required-methods
   130  ```
   131  
   132  This will create the `subd.pem` and `subd.key.pem` files. These should be copied
   133  to the files `/etc/ssl/subd/cert.pem` and `/etc/ssl/subd/key.pem` respectively
   134  on all machines. As with the CA file, this should also be included in the
   135  installation image that every machine is booted with.
   136  
   137  Note how [subd](../cmd/subd/README.md) is given access to a single RPC method:
   138  `ObjectServer.GetObjects`. This is required to allow it to fetch objects.
   139  
   140  ### Adding [subd](../cmd/subd/README.md) to all your machines and boot image
   141  Before moving onto making other certificates, let's finish off the steps to get
   142  [subd](../cmd/subd/README.md) onto all your machines and into your boot image,
   143  so that it will run everywhere. You will need to copy `$HOME/go/bin/subd` and
   144  `$HOME/go/bin/run-in-mntns` to your machines. The recommended location is
   145  `/usr/local/sbin`. You will also need to copy the appropriate boot script from
   146  the [init scripts](../init.d) directory, and run the OS-specific command to
   147  install or activate the boot script.
   148  
   149  ### Creating a certificate+key for [dominator](../cmd/dominator/README.md)
   150  Run the following command:
   151  
   152  ```
   153  make-cert root Dominator AUTO dominator cmd/dominator/required-methods
   154  ```
   155  
   156  This will create the `Dominator.pem` and `Dominator.key.pem` files. These should
   157  be copied to the files `/etc/ssl/dominator/cert.pem` and
   158  `/etc/ssl/dominator/key.pem` on the machine where
   159  [dominator](../cmd/dominator/README.md) will run.
   160  
   161  Note how (in addition to access to some other RPC methods) the
   162  [dominator](../cmd/dominator/README.md) is given access to call all
   163  [subd](../cmd/subd/README.md) RPC methods. Thus, this is a high value key, as it
   164  gives root level access to your fleet, so you should restrict access to it.
   165  
   166  ### Creating a certificate+key for [imageserver](../cmd/imageserver/README.md)
   167  Run the following command:
   168  
   169  ```
   170  make-cert root imageserver AUTO imageserver cmd/imageserver/required-methods
   171  ```
   172  
   173  This will create the `imageserver.pem` and `imageserver.key.pem` files. These
   174  should be copied to the files `/etc/ssl/imageserver/cert.pem` and
   175  `/etc/ssl/imageserver/key.pem` on the machine where
   176  [imageserver](../cmd/imageserver/README.md) will run.
   177  
   178  Note that the list of RPC methods given above allows
   179  [imageserver](../cmd/imageserver/README.md) to replicate images from another
   180  [imageserver](../cmd/imageserver/README.md). If you never plan to enable image
   181  replication (that would be unwise), you could provide an empty list of methods.
   182  
   183  ### Creating a certificate+key for [imaginator](../cmd/imaginator/README.md)
   184  Run the following command:
   185  
   186  ```
   187  make-cert root imaginator AUTO imaginator cmd/imaginator/required-methods
   188  ```
   189  
   190  This will create the `imaginator.pem` and `imaginator.key.pem` files. These
   191  should be copied to the files `/etc/ssl/imaginator/cert.pem` and
   192  `/etc/ssl/imaginator/key.pem` on the machine where
   193  [imaginator](../cmd/imaginator/README.md) will run.
   194  
   195  ### Creating a certificate+key for [filegen-server](../cmd/filegen-server/README.md)
   196  Run the following command:
   197  
   198  ```
   199  make-cert root filegen-server AUTO filegen-server ''
   200  ```
   201  
   202  This will create the `filegen-server.pem` and `filegen-server.key.pem` files.
   203  These should be copied to the files `/etc/ssl/filegen-server/cert.pem` and
   204  `/etc/ssl/filegen-server/key.pem` on the machine where
   205  [filegen-server](../cmd/filegen-server/README.md) will run.
   206  
   207  Note how an empty list of RPC methods is specified. This is because
   208  [filegen-server](../cmd/filegen-server/README.md) does not initiate any RPC
   209  connections: it only responds to RPC requests. Thus, it does not need permission
   210  to access any methods. The certificate+key pair is a standard requirement for
   211  every TLS server.
   212  
   213  ### Creating a certificate+key for [mdbd](../cmd/mdbd/README.md)
   214  Run the following command:
   215  
   216  ```
   217  make-cert root mdbd AUTO mdbd cmd/mdbd/required-methods
   218  ```
   219  This will create the `mdbd.pem` and `mdbd.key.pem` files. These
   220  should be copied to the files `/etc/ssl/mdbd/cert.pem` and
   221  `/etc/ssl/mdbd/key.pem` on the machine where
   222  [mdbd](../cmd/mdbd/README.md) will run.
   223  
   224  
   225  ### Creating a certificate+key pair for a user
   226  Unlike daemons, which require access to a specific set of methods, users require
   227  access to a variety of methods depending on their level of access and your
   228  security policy, so this section will discuss creating these certificate+key
   229  pairs in general terms. To create, run the following command:
   230  
   231  ```
   232  make-cert root "$LOGNAME" AUTO "$LOGNAME" '$methods'
   233  ```
   234  
   235  This will create the `$LOGNAME.pem` and `$LOGNAME.key.pem` files.
   236  These should be copied to the `$HOME/.ssl` directory for the user, with matched
   237  `$file.cert` and `$file.key` names. A common convention is to use the names
   238  `$LOGNAME.cert` and `$LOGNAME.key`. The command-line tools such as
   239  [domtool](../cmd/domtool/README.md) and [imagetool](../cmd/imagetool/README.md)
   240  will read all certificate+key pairs from the `$HOME/.ssl` directory.
   241  
   242  The forth parameter to `make-cert` is the username that the certificate+key pair
   243  is issued to. This username will be recorded in logs for certain RPC methods and
   244  will be recorded in image metadata when images are created. The entity creating
   245  the certificate+key pairs must therefore be trusted.
   246  
   247  The final parameter specifies the list of methods that the user may access. This
   248  may either be a filename containing method names separated by newlines or a
   249  comma separated list. The sections below discuss how to determine the list of
   250  methods if there isn't a `required-methods` file to provide.
   251  
   252  #### Discovering methods
   253  The [list-methods](../scripts/list-methods) utility provided in the source
   254  repository will connect to a running server and show the list of methods that
   255  the server supports. To find the list of methods that a server supports, run the
   256  following command:
   257  
   258  ```
   259  list-methods host:port
   260  ```
   261  
   262  These are the assigned port numbers:
   263  
   264  - [dominator](../cmd/dominator/README.md): 6970
   265  - [filegen-server](../cmd/filegen-server/README.md): 6972
   266  - [imageserver](../cmd/imageserver/README.md): 6971
   267  - [subd](../cmd/subd/README.md): 6969
   268  
   269  By knowing the list of methods that servers (daemons) support, you can make an
   270  informed choice about which methods to grant users access to.
   271  
   272  #### Common method lists
   273  In this section some common roles are listed, with the corresponding method
   274  lists that are required to perform these roles. When creating certificate+key
   275  pairs the list of methods most be comma separated. The method lists are split
   276  out below for readability:
   277  
   278  - Simple image creator (for use in an image build pipeline):
   279    ```
   280    ImageServer.AddImage
   281    ImageServer.CheckImage
   282    ObjectServer.AddObjects
   283    ```
   284  - Image creator (can also create derivative images and snapshot machines):
   285    ```
   286    ImageServer.AddImage
   287    ImageServer.CheckImage
   288    ImageServer.GetImage
   289    ObjectServer.AddObjects
   290    ObjectServer.CheckObjects
   291    Subd.Poll
   292    ```
   293  - Image administrator (i.e. can delete images, create directories and change
   294    directory access):
   295    ```
   296    ImageServer.*
   297    ```
   298  - [dominator](../cmd/dominator/README.md) administrator:
   299    ```
   300    Dominator.*
   301    ```
   302  - All-powerful user (full control over all **Dominator** components and
   303    root-level access to all *subs*):
   304    ```
   305    *.*
   306    ```