Merge branch '21722-remove-chokidar' into main. Closes #21722
[arvados.git] / doc / install / install-api-server.html.textile.liquid
1 ---
2 layout: default
3 navsection: installguide
4 title: Install API server and Controller
5 ...
6 {% comment %}
7 Copyright (C) The Arvados Authors. All rights reserved.
8
9 SPDX-License-Identifier: CC-BY-SA-3.0
10 {% endcomment %}
11
12 # "Introduction":#introduction
13 # "Install dependencies":#dependencies
14 # "Set up database":#database-setup
15 # "Update config.yml":#update-config
16 # "Update nginx configuration":#update-nginx
17 # "Install arvados-api-server and arvados-controller":#install-packages
18 # "Confirm working installation":#confirm-working
19
20 h2(#introduction). Introduction
21
22 The Arvados core API server consists of four services: PostgreSQL, Arvados Rails API, Arvados Controller, and Nginx.
23
24 Here is a simplified diagram showing the relationship between the core services.  Client requests arrive at the public-facing Nginx reverse proxy.  The request is forwarded to Arvados controller.  The controller is able handle some requests itself, the rest are forwarded to the Arvados Rails API.  The Rails API server implements the majority of business logic, communicating with the PostgreSQL database to fetch data and make transactional updates.  All services are stateless, except the PostgreSQL database.  This guide assumes all of these services will be installed on the same node, but it is possible to install these services across multiple nodes.
25
26 !(full-width){{site.baseurl}}/images/proxy-chain.svg!
27
28 h2(#dependencies). Install dependencies
29
30 # "Install PostgreSQL":install-postgresql.html
31 # "Install Ruby and Bundler":ruby.html
32 # "Install nginx":nginx.html
33 # "Install Phusion Passenger":https://www.phusionpassenger.com/docs/tutorials/deploy_to_production/installations/oss/ownserver/ruby/nginx/
34
35 h2(#database-setup). Set up database
36
37 {% assign service_role = "arvados" %}
38 {% assign service_database = "arvados_production" %}
39 {% assign use_contrib = true %}
40 {% include 'install_postgres_database' %}
41
42 h2(#update-config). Update config.yml
43
44 Starting from an "empty config.yml file,":config.html#empty add the following configuration keys.
45
46 h3. Tokens
47
48 <notextile>
49 <pre><code>    SystemRootToken: <span class="userinput">"$system_root_token"</span>
50     ManagementToken: <span class="userinput">"$management_token"</span>
51     Collections:
52       BlobSigningKey: <span class="userinput">"$blob_signing_key"</span>
53 </code></pre>
54 </notextile>
55
56 These secret tokens are used to authenticate messages between Arvados components.
57 * @SystemRootToken@ is used by Arvados system services to authenticate as the system (root) user when communicating with the API server.
58 * @ManagementToken@ is used to authenticate access to system metrics.
59 * @Collections.BlobSigningKey@ is used to control access to Keep blocks.
60
61 Each token should be a string of at least 50 alphanumeric characters. You can generate a suitable token with the following command:
62
63 <notextile>
64 <pre><code>~$ <span class="userinput">tr -dc 0-9a-zA-Z &lt;/dev/urandom | head -c50 ; echo</span>
65 </code></pre>
66 </notextile>
67
68 h3. PostgreSQL.Connection
69
70 <notextile>
71 <pre><code>    PostgreSQL:
72       Connection:
73         host: <span class="userinput">localhost</span>
74         user: <span class="userinput">arvados</span>
75         password: <span class="userinput">$postgres_password</span>
76         dbname: <span class="userinput">arvados_production</span>
77 </code></pre>
78 </notextile>
79
80 Replace the @$postgres_password@ placeholder with the password you generated during "database setup":#database-setup .
81
82 h3. Services
83
84 <notextile>
85 <pre><code>    Services:
86       Controller:
87         ExternalURL: <span class="userinput">"https://ClusterID.example.com"</span>
88         InternalURLs:
89           <span class="userinput">"http://localhost:8003": {}</span>
90       RailsAPI:
91         # Does not have an ExternalURL
92         InternalURLs:
93           <span class="userinput">"http://localhost:8004": {}</span>
94 </code></pre>
95 </notextile>
96
97 Replace @ClusterID.example.com@ with the hostname that you previously selected for the API server.
98
99 The @Services@ section of the configuration helps Arvados components contact one another (service discovery).  Each service has one or more @InternalURLs@ and an @ExternalURL@.  The @InternalURLs@ describe where the service runs, and how the Nginx reverse proxy will connect to it.  The @ExternalURL@ is how external clients contact the service.
100
101 h2(#update-nginx). Update nginx configuration
102
103 Use a text editor to create a new file @/etc/nginx/conf.d/arvados-api-and-controller.conf@ with the following configuration.  Options that need attention are marked in <span class="userinput">red</span>.
104
105 <notextile>
106 <pre><code>proxy_http_version 1.1;
107
108 # When Keep clients request a list of Keep services from the API
109 # server, use the origin IP address to determine if the request came
110 # from the internal subnet or it is an external client.  This sets the
111 # $external_client variable which in turn is used to set the
112 # X-External-Client header.
113 #
114 # The API server uses this header to choose whether to respond to a
115 # "available keep services" request with either a list of internal keep
116 # servers (0) or with the keepproxy (1).
117 #
118 # <span class="userinput">Following the example here, update the 10.20.30.0/24 netmask</span>
119 # <span class="userinput">to match your private subnet.</span>
120 # <span class="userinput">Update 1.2.3.4 and add lines as necessary with the public IP</span>
121 # <span class="userinput">address of all servers that can also access the private network to</span>
122 # <span class="userinput">ensure they are not considered 'external'.</span>
123
124 geo $external_client {
125   default        1;
126   127.0.0.0/24   0;
127   <span class="userinput">10.20.30.0/24</span>  0;
128   <span class="userinput">1.2.3.4/32</span>     0;
129 }
130
131 # This is the port where nginx expects to contact arvados-controller.
132 upstream controller {
133   server     localhost:8003  fail_timeout=10s;
134 }
135
136 server {
137   # This configures the public https port that clients will actually connect to,
138   # the request is reverse proxied to the upstream 'controller'
139
140   listen       443 ssl;
141   server_name  <span class="userinput">ClusterID.example.com</span>;
142
143   ssl_certificate     <span class="userinput">/YOUR/PATH/TO/cert.pem</span>;
144   ssl_certificate_key <span class="userinput">/YOUR/PATH/TO/cert.key</span>;
145
146   # Refer to the comment about this setting in the passenger (arvados
147   # api server) section of your Nginx configuration.
148   client_max_body_size 128m;
149
150   location / {
151     proxy_pass               http://controller;
152     proxy_redirect           off;
153     proxy_connect_timeout    90s;
154     proxy_read_timeout       300s;
155     proxy_max_temp_file_size 0;
156     proxy_request_buffering  off;
157     proxy_buffering          off;
158     proxy_http_version       1.1;
159
160     proxy_set_header      Host              $http_host;
161     proxy_set_header      Upgrade           $http_upgrade;
162     proxy_set_header      Connection        "upgrade";
163     proxy_set_header      X-External-Client $external_client;
164     proxy_set_header      X-Forwarded-For   $proxy_add_x_forwarded_for;
165     proxy_set_header      X-Forwarded-Proto https;
166     proxy_set_header      X-Real-IP         $remote_addr;
167   }
168 }
169
170 server {
171   # This configures the Arvados API server.  It is written using Ruby
172   # on Rails and uses the Passenger application server.
173
174   listen <span class="userinput">localhost:8004</span>;
175   server_name localhost-api;
176
177   root /var/www/arvados-api/current/public;
178   index  index.html index.htm index.php;
179
180   passenger_enabled on;
181   passenger_preload_bundler on;
182
183   # <span class="userinput">If you are using RVM, uncomment the line below.</span>
184   # <span class="userinput">If you're using system ruby, leave it commented out.</span>
185   #passenger_ruby /usr/local/rvm/wrappers/default/ruby;
186
187   # This value effectively limits the size of API objects users can
188   # create, especially collections.  If you change this, you should
189   # also ensure the following settings match it:
190   # * `client_max_body_size` in the previous server section
191   # * `API.MaxRequestSize` in config.yml
192   client_max_body_size 128m;
193 }
194 </code></pre>
195 </notextile>
196
197 {% assign arvados_component = 'arvados-api-server arvados-controller' %}
198
199 {% include 'install_packages' %}
200
201 {% assign arvados_component = 'arvados-controller' %}
202
203 {% include 'start_service' %}
204
205 h2(#confirm-working). Confirm working installation
206
207 We recommend using the "Cluster diagnostics tool.":diagnostics.html  The first few tests (10, 20, 30) will succeed if you have a working API server and controller.  Of course, tests for services that you have not yet installed and configured will fail.
208
209 Here are some other checks you can perform manually.
210
211 h3. Confirm working controller
212
213 <notextile><pre><code>$ curl https://<span class="userinput">ClusterID.example.com</span>/arvados/v1/config
214 </code></pre></notextile>
215
216 h3. Confirm working Rails API server
217
218 <notextile><pre><code>$ curl https://<span class="userinput">ClusterID.example.com</span>/discovery/v1/apis/arvados/v1/rest
219 </code></pre></notextile>
220
221 h3. Confirm that you can use the system root token to act as the system root user
222
223 <notextile><pre><code>$ curl -H "Authorization: Bearer $system_root_token" https://<span class="userinput">ClusterID.example.com</span>/arvados/v1/users/current
224 </code></pre></notextile>
225
226 h3. Troubleshooting
227
228 If you are getting TLS errors, make sure the @ssl_certificate@ directive in your nginx configuration has the "full certificate chain":http://nginx.org/en/docs/http/configuring_https_servers.html#chains
229
230 Logs can be found in @/var/www/arvados-api/current/log/production.log@ and using @journalctl -u arvados-controller@.
231
232 See also the admin page on "Logging":{{site.baseurl}}/admin/logging.html .