tsuru Installer

tsuru Installer provides a way to install tsuru API and its required componentslocally or on remote hosts.

Note

tsuru Installer is distributed inside the tsuru client. To use it, you mustfirst install the client. Check the tsuru client documentation for a fullreference, including how to install it: https://tsuru-client.readthedocs.org.

Note

Other methods of installation like tsuru Nowand tsuru-bootstrap are deprecated.

To install tsuru locally, one can simply run(requires VirtualBox):

  1. $ tsuru install-create

This command accepts custom configurations, as we’ll see in a later section. Withoutparameters, it uses the default configurations, which means creating a new VMwith VirtualBox.After a couple of minutes you will have a full tsuru installation, inside a localVirtualBox VM, where you can start deploying your applications and experience thetsuru workflow.

How it works

tsuru installer uses docker machineto provision docker hosts, this means that it’s possible to use any of the core or3rd party docker machine drivers on the installation.

It will create a directory inside your ~/.tsuru/installs, with every file createdand needed by docker machine to manage and provision your hosts: certificates,configuration files, your CA file etc.

After provisioning the hosts, the installer will install and start every tsurucomponent as a swarm service on the hosts.

Docker Machine drivers

Docker Machine drivers are responsible for provisioning docker hosts on differentiaas’. The installer comes bundled with all docker machine core driversand also supports the 3rd party ones; just make sure they are available in your $PATH.

For a list of 3rd party plugins supported by the communitycheck here.

Swarm Mode

tsuru installer provisions docker hosts with docker v1.12 and uses docker swarm modeto orchestrate its core components in the docker node cluster. This means that it’seasy to scale up and down every service and swarm is also responsible for recoveringa service if one of its tasks is lost.

Hosts

The installer provision and manages two kinds of hosts: core hosts and apps hosts.

Core hosts are Swarm nodes and are responsible for running tsuru core components asswarm services (orchestrated by Swarm).

Apps hosts are docker hosts registered as docker nodes to tsuru. These are responsiblefor running tsuru apps (orchestrated by tsuru).

By default, core hosts are reused as apps hosts (this can be configured by the hosts:apps:dedicated config).

What is installed

Currently, the installer installs the following components:

  • MongoDB
  • Redis
  • PlanB router
  • Docker Registry
  • tsuru API
    After all basic components are installed, it will:

  • Create a root user on tsurud

  • Point your tsuru client to the newly created api using tsuru target-set
  • Configure a docker node to run your applications
  • Create and deploy a tsuru-dashboard

Security

The installer needs to issue commands to the tsuru api during the installation and,to do so, it uses the —<driver-name>-open-port 8080/tcp driver flag, configuring the hostto have the 8080/tcp port opened to the internet. This is probably not recommended and should be changed as soon as possible afterthe installation. For drivers that do not support this parameter, the port needs to be opened manually orthe corresponding driver flag must be set on the installation configuration file.

It is also recommended to change the root user login and password that the installeruses to bootstrap the installation.

Customizing the installation

The install command accepts two configuration files as parameters to customize theinstallation. To generate these files with the default values, run this command:

  1. $ tsuru install-config-init

This will generate two files in the current directory: install-config.yml andinstall-compose.yml. In the first one you can set the docker-machine driverand configurations like the machine CPU and memory, and tsuru specific configurations,like the default provisioner, HTTP/HTTPS ports, users quotas and enable or disablethe dashboard. The second file includes configurations for each tsuru component,like redis and gandalf. You can change configurations like version, port and mountsfor each one.

After customizing the config files, run this command to start the installer:

  1. $ tsuru install-create -c install-config.yml -e install-compose.yml

For example, to install tsuru on amazon ec2, one could create the following file:

  1. driver:
  2. name: amazonec2
  3. options:
  4. amazonec2-access-key: myAmazonAccessKey
  5. amazonec2-secret-key: myAmazonSecretKey
  6. amazonec2-vpc-id: vpc-abc1234
  7. amazonec2-subnet-id: subnet-abc1234

And pass it to the install command as:

  1. $ tsuru install-create -c config.yml

Examples

This section covers some examples to show some of the capabilities of the installer.

Multi-host provisioning and installation on AWS

The following configuration will provision 3 virtual machines on AWS to run tsurucore components and other 3 machines to host tsuru applications. Additionally,it will use an external mongoDB instead of installing it.

  1. components:
  2. mongo: mongoDB.my-server.com:27017
  3. hosts:
  4. core:
  5. size: 3
  6. driver:
  7. options:
  8. amazonec2-zone: ["a", "b", "c"]
  9. amazonec2-instance-type: "t2.medium"
  10. apps:
  11. size: 3
  12. dedicated: true
  13. driver:
  14. options:
  15. amazonec2-zone: ["a", "b", "c"]
  16. amazonec2-instance-type: "t2.small"
  17. driver:
  18. name: amazonec2
  19. options:
  20. amazonec2-access-key: myAmazonAccessKey
  21. amazonec2-secret-key: myAmazonSecretKey
  22. amazonec2-vpc-id: vpc-abc1234

Each core/apps host will be created in a different availability zone, “t2.medium” instanceswill be provisioned for core hosts and “t2.small” for apps hosts.

Installing on already provisioned (or physical) hosts

Docker machine provides a generic driverthat can be used to install docker to already provisioned virtual or physical machines using ssh.The following configuration example will connect to machine-1 and machine-2 using ssh,install docker, install and start all tsuru core components on those two machines.Machine 3 will be registered as an application node to be used by tsuru applications,including the dashboard.

  1. hosts:
  2. core:
  3. size: 2
  4. driver:
  5. options:
  6. generic-ip-address: ["machine-1-IP", "machine-2-IP"]
  7. generic-ssh-key: ["~/keys/machine-1", "~/keys/machine-2"]
  8. apps:
  9. size: 1
  10. dedicated: true
  11. driver:
  12. options:
  13. generic-ip-address: ["machine-3-IP"]
  14. generic-ssh-key: ["~/keys/machine-3"]
  15. driver:
  16. name: generic
  17. options:
  18. generic-ssh-port: 2222
  19. generic-ssh-user: ubuntu

DigitalOcean basic configuration

For example, to install tsuru on DigitalOcean, one could create the following file:

  1. driver:
  2. name: digitalocean
  3. options:
  4. digitalocean-access-token: your-token
  5. digitalocean-image: ubuntu-15-10-x64
  6. digitalocean-region: nyc3
  7. digitalocean-size: 512mb
  8. digitalocean-ipv6: false
  9. digitalocean-private-networking: false
  10. digitalocean-backups: false
  11. digitalocean-ssh-user: root
  12. digitalocean-ssh-port: 22
  13. digitalocean-ssh-key-fingerprint: the-ssh-key-fingerprint

Configuration reference

Note

tsuru uses a colon to represent nesting in YAML. So, whenever this document sayssomething like key1:key2, it refers to the value of the key2 that isnested in the block that is the value of key1. For example,database:url means:

  1. database:
  2. url: <value>

name

The name of the installation, e.g, tsuru-ec2, tsuru-local. This will be the nameof the directory created inside ~/.tsuru/installs and the tsuru target namefor the api.

components:<component>

This configuration can be used to disable the installation of a core component,by setting the component address. For example, by setting:

  1. components:
  2. mongo: my-mongo.example.com:27017

The installer won’t install the mongo component and instead will check the connectionto my-mongo.example.com:27017 before continuing with the installation.The following components can be configured to be used as an external resource: mongo,redis, registry and planb.

hosts:core:size

Number of machines to be used as hosts for tsuru core components. Default 1.

hosts:core:driver:options

Under this namespace every driver parameters can be set. These are going to beused only for core hosts and each parameter accepts a list or a single value.If the number of values is less than the number of hosts, some values will bereused across the core hosts.

hosts:apps:size

Number of machines to be registered as docker nodes to host tsuru apps. Default 1.

hosts:apps:dedicated

Boolean flag to indicate if apps hosts are dedicated or if they can be usedto run tsuru core components. Defaults to true.

hosts:apps:driver:options

Under this namespace every driver parameters can be set. These are going to beused only for app hosts and each parameter accepts a list or a single value.If the number of values is less than the number of hosts, some values will bereused across the apps hosts.

docker-hub-mirror

Url of a docker hub mirror used to fetch the components docker images. The defaultis to use no mirror.

ca-path

A path to a directory containing a ca.pem and ca-key.pem files that are going tobe used to sign certificates used by docker and docker registry. If not set,one will be created.

driver:name

Name of the driver to be used by the installer. This can be any core or 3rd partydriver supported by docker machine. If a 3rd party driver name is used, it’s binarymust be available on the user path. The default is to use virtualbox.

driver:options

Under this namespace every driver parameters can be set. Refer to the driverconfiguration for more information on what parameter are available. For example,the AWS docker machine driver accepts the —amazonec2-secret-key argument andthis can be set using driver:options:amazonec2-secret-key entry.

原文: https://docs.tsuru.io/1.6/installing/using-tsuru-installer.html