]> git.arvados.org - arvados.git/blob - doc/install/install-api-server.html.textile.liquid
22866: Prefer `sudo arvados-client sudo diagnostics`
[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 nginx":nginx.html
32
33 h2(#database-setup). Set up database
34
35 {% assign service_role = "arvados" %}
36 {% assign service_database = "arvados_production" %}
37 {% assign use_contrib = true %}
38 {% include 'install_postgres_database' %}
39
40 h2(#update-config). Update config.yml
41
42 Starting from an "empty config.yml file,":config.html#empty add the following configuration keys.
43
44 h3. Tokens
45
46 <notextile>
47 <pre><code>    SystemRootToken: <span class="userinput">"$system_root_token"</span>
48     ManagementToken: <span class="userinput">"$management_token"</span>
49     Collections:
50       BlobSigningKey: <span class="userinput">"$blob_signing_key"</span>
51 </code></pre>
52 </notextile>
53
54 These secret tokens are used to authenticate messages between Arvados components.
55 * @SystemRootToken@ is used by Arvados system services to authenticate as the system (root) user when communicating with the API server.
56 * @ManagementToken@ is used to authenticate access to system metrics.
57 * @Collections.BlobSigningKey@ is used to control access to Keep blocks.
58
59 Each token should be a string of at least 50 alphanumeric characters. You can generate a suitable token with the following command:
60
61 <notextile>
62 <pre><code>~$ <span class="userinput">tr -dc 0-9a-zA-Z &lt;/dev/urandom | head -c50 ; echo</span>
63 </code></pre>
64 </notextile>
65
66 h3. PostgreSQL.Connection
67
68 <notextile>
69 <pre><code>    PostgreSQL:
70       Connection:
71         host: <span class="userinput">localhost</span>
72         user: <span class="userinput">arvados</span>
73         password: <span class="userinput">$postgres_password</span>
74         dbname: <span class="userinput">arvados_production</span>
75 </code></pre>
76 </notextile>
77
78 Replace the @$postgres_password@ placeholder with the password you generated during "database setup":#database-setup.
79
80 h3. Services
81
82 <notextile>
83 <pre><code>    Services:
84       Controller:
85         ExternalURL: <span class="userinput">"https://ClusterID.example.com"</span>
86         InternalURLs:
87           <span class="userinput">"http://localhost:8003": {}</span>
88       RailsAPI:
89         # Does not have an ExternalURL
90         InternalURLs:
91           <span class="userinput">"http://localhost:8004": {}</span>
92       ContainerWebServices:
93         # Does not have InternalURLs
94         ExternalURL: <span class="userinput">"https://*.containers.ClusterID.example.com"</span>
95 </code></pre>
96 </notextile>
97
98 Replace @ClusterID.example.com@ with the hostname that you previously selected for the API server.
99
100 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.
101
102 h2(#update-nginx). Update nginx configuration
103
104 Use a text editor to create a new file @/etc/nginx/conf.d/arvados-controller.conf@ with the following configuration.  Options that need attention are marked in <span class="userinput">red</span>.
105
106 <notextile>
107 <pre><code>proxy_http_version 1.1;
108
109 # When Keep clients request a list of Keep services from the API
110 # server, use the origin IP address to determine if the request came
111 # from the internal subnet or it is an external client.  This sets the
112 # $external_client variable which in turn is used to set the
113 # X-External-Client header.
114 #
115 # The API server uses this header to choose whether to respond to a
116 # "available keep services" request with either a list of internal keep
117 # servers (0) or with the keepproxy (1).
118 #
119 # <span class="userinput">Following the example here, update the 10.20.30.0/24 netmask</span>
120 # <span class="userinput">to match your private subnet.</span>
121 # <span class="userinput">Update 1.2.3.4 and add lines as necessary with the public IP</span>
122 # <span class="userinput">address of all servers that can also access the private network to</span>
123 # <span class="userinput">ensure they are not considered 'external'.</span>
124
125 geo $external_client {
126   default        1;
127   127.0.0.0/24   0;
128   <span class="userinput">10.20.30.0/24</span>  0;
129   <span class="userinput">1.2.3.4/32</span>     0;
130 }
131
132 # This is the port where nginx expects to contact arvados-controller.
133 upstream controller {
134   server     localhost:8003  fail_timeout=10s;
135 }
136
137 server {
138   # This configures the public https port that clients will actually connect to,
139   # the request is reverse proxied to the upstream 'controller'
140
141   listen       443 ssl;
142   server_name  <span class="userinput">ClusterID.example.com</span>
143                *.<span class="userinput">containers.ClusterID.example.com</span>;
144
145   ## If a wildcard name like <span class="userinput">*.containers.ClusterID.example.com</span> is not
146   ## available, and Services.ContainerWebServices.ExternalPortMin and
147   ## ExternalPortMax are configured instead, then the "listen" and
148   ## "server_name" directives should be adjusted accordingly.  Example:
149   #
150   # listen       443 ssl;
151   # listen       2000-2999 ssl;
152   # server_name  <span class="userinput">ClusterID.example.com</span>
153   #              <span class="userinput">containers.ClusterID.example.com</span>;
154   #
155   ## The number of ports in the range (1000 in this example) should be
156   ## added to the worker_connections setting in the events section of
157   ## your Nginx configuration (default 512).  If the system-supplied
158   ## RLIMIT_NOFILE value is low (some systems default to 1024), the
159   ## worker_rlimit_nofile setting in the main section should also be
160   ## increased by the same amount.
161   #
162   # events { worker_connections: 1512; }
163   # worker_rlimit_nofile: 2024;
164
165   ssl_certificate     <span class="userinput">/YOUR/PATH/TO/cert.pem</span>;
166   ssl_certificate_key <span class="userinput">/YOUR/PATH/TO/cert.key</span>;
167
168   # Refer to the comment about this setting in the passenger (arvados
169   # api server) section of your Nginx configuration.
170   client_max_body_size 128m;
171
172   location / {
173     proxy_pass               http://controller;
174     proxy_redirect           off;
175     proxy_connect_timeout    90s;
176     proxy_read_timeout       300s;
177     proxy_max_temp_file_size 0;
178     proxy_request_buffering  off;
179     proxy_buffering          off;
180     proxy_http_version       1.1;
181
182     proxy_set_header      Host              $http_host;
183     proxy_set_header      Upgrade           $http_upgrade;
184     proxy_set_header      Connection        "upgrade";
185     proxy_set_header      X-External-Client $external_client;
186     proxy_set_header      X-Forwarded-For   $proxy_add_x_forwarded_for;
187     proxy_set_header      X-Forwarded-Proto https;
188     proxy_set_header      X-Real-IP         $remote_addr;
189   }
190 }
191 </code></pre>
192 </notextile>
193
194 h2. Enable development repository
195
196 Skip to the next section if you are installing on Debian or Ubuntu.
197
198 On Red Hat, AlmaLinux, and Rocky Linux, the API server package depends on development headers available from a separate repository. The repository you need depends on which version of the distribution you're running. Run the command given for your distribution below:
199
200 |_. Distribution and version|_. Command to enable repository|
201 |Red Hat/AlmaLinux/Rocky Linux 9|@# dnf config-manager --set-enabled devel@|
202 |Red Hat/AlmaLinux/Rocky Linux 8|@# dnf config-manager --set-enabled powertools@|
203
204 {% assign arvados_component = 'arvados-api-server arvados-controller' %}
205
206 {% include 'install_packages' %}
207
208 h3(#railsapi-config). Configure Rails API server
209
210 By default, the Rails API server is configured to listen on @localhost:8004@, matching the example cluster configuration above. If you need to change this, edit the @arvados-railsapi.service@ definition to redefine the @PASSENGER_ADDRESS@ and @PASSENGER_PORT@ environment variables, like this:
211
212 <notextile>
213 <pre><code># <span class="userinput">systemctl edit arvados-railsapi.service</span>
214 ### Editing /etc/systemd/system/arvados-railsapi.service.d/override.conf
215 ### Anything between here and the comment below will become the new contents of the file
216 <span class="userinput">[Service]
217 Environment=PASSENGER_ADDRESS=<strong>0.0.0.0</strong>
218 Environment=PASSENGER_PORT=<strong>8040</strong></span>
219 ### Lines below this comment will be discarded
220 [...]
221 </code></pre>
222 </notextile>
223
224 You can similarly define other Passenger settings if desired. The "Passenger Standalone reference":https://www.phusionpassenger.com/library/config/standalone/reference/ documents all the available settings.
225
226 {% assign arvados_component = 'arvados-railsapi arvados-controller' %}
227
228 {% include 'start_service' %}
229
230 h2(#confirm-working). Confirm working installation
231
232 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.
233
234 Here are some other checks you can perform manually.
235
236 h3. Confirm working controller
237
238 <notextile><pre><code>$ curl https://<span class="userinput">ClusterID.example.com</span>/arvados/v1/config
239 </code></pre></notextile>
240
241 h3. Confirm working Rails API server
242
243 <notextile><pre><code>$ curl https://<span class="userinput">ClusterID.example.com</span>/discovery/v1/apis/arvados/v1/rest
244 </code></pre></notextile>
245
246 h3. Confirm that you can use the system root token to act as the system root user
247
248 <notextile><pre><code>$ curl -H "Authorization: Bearer $system_root_token" https://<span class="userinput">ClusterID.example.com</span>/arvados/v1/users/current
249 </code></pre></notextile>
250
251 h3. Troubleshooting
252
253 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.
254
255 Logs can be found in @/var/www/arvados-api/current/log/production.log@ and using @journalctl -u arvados-controller@. See also the admin page on "Logging":{{site.baseurl}}/admin/logging.html.