2019-10-01 15:06:05 +00:00
|
|
|
# Praefect
|
|
|
|
|
|
|
|
NOTE: **Note:** Praefect is an experimental service, and for testing purposes only at
|
|
|
|
this time.
|
|
|
|
|
2019-10-14 18:06:24 +00:00
|
|
|
Praefect is an optional reverse-proxy for [Gitaly](../index.md) to manage a
|
|
|
|
cluster of Gitaly nodes for high availability through replication.
|
|
|
|
If a Gitaly node becomes unavailable, it will be possible to fail over to a
|
|
|
|
warm Gitaly replica.
|
|
|
|
|
|
|
|
The first minimal version will support:
|
|
|
|
|
|
|
|
- Eventual consistency of the secondary replicas.
|
|
|
|
- Manual fail over from the primary to the secondary.
|
|
|
|
|
|
|
|
Follow the [HA Gitaly epic](https://gitlab.com/groups/gitlab-org/-/epics/1489)
|
|
|
|
for updates and roadmap.
|
|
|
|
|
2019-10-01 15:06:05 +00:00
|
|
|
## Omnibus
|
|
|
|
|
|
|
|
### Architecture
|
|
|
|
|
|
|
|
For this document, the following network topology is assumed:
|
|
|
|
|
|
|
|
```mermaid
|
|
|
|
graph TB
|
|
|
|
GitLab --> Gitaly;
|
|
|
|
GitLab --> Praefect;
|
|
|
|
Praefect --> Preafect-Git-1;
|
|
|
|
Praefect --> Preafect-Git-2;
|
|
|
|
Praefect --> Preafect-Git-3;
|
|
|
|
```
|
|
|
|
|
|
|
|
Where `GitLab` is the collection of clients that can request Git operations.
|
|
|
|
`Gitaly` is a Gitaly server before using Praefect. The Praefect node has two
|
2019-10-14 00:06:38 +00:00
|
|
|
storage nodes attached. Praefect itself doesn't store data, but connects to
|
2019-10-01 15:06:05 +00:00
|
|
|
three Gitaly nodes, `Praefect-Git-1`, `Praefect-Git-2`, and `Praefect-Git-3`.
|
|
|
|
There should be no knowledge other than with Praefect about the existence of
|
|
|
|
the `Praefect-Git-X` nodes.
|
|
|
|
|
2019-10-11 15:06:41 +00:00
|
|
|
### Setup
|
2019-10-01 15:06:05 +00:00
|
|
|
|
2019-10-11 15:06:41 +00:00
|
|
|
In this setup guide, the Gitaly node will be added first, then Praefect, and
|
|
|
|
lastly we update the GitLab configuration.
|
2019-10-01 15:06:05 +00:00
|
|
|
|
2019-10-11 15:06:41 +00:00
|
|
|
#### Gitaly
|
2019-10-01 15:06:05 +00:00
|
|
|
|
2019-10-11 15:06:41 +00:00
|
|
|
In their own machine, configure the Gitaly server as described in the
|
|
|
|
[gitaly documentation](index.md#3-gitaly-server-configuration).
|
2019-10-01 15:06:05 +00:00
|
|
|
|
2019-10-11 15:06:41 +00:00
|
|
|
#### Praefect
|
2019-10-01 15:06:05 +00:00
|
|
|
|
2019-11-01 12:06:26 +00:00
|
|
|
Next, Praefect has to be enabled on its own node.
|
|
|
|
|
|
|
|
##### Disable other services
|
2019-10-01 15:06:05 +00:00
|
|
|
|
|
|
|
```ruby
|
2019-10-11 15:06:41 +00:00
|
|
|
# /etc/gitlab/gitlab.rb
|
|
|
|
|
|
|
|
# Avoid running unnecessary services on the Gitaly server
|
|
|
|
postgresql['enable'] = false
|
|
|
|
redis['enable'] = false
|
|
|
|
nginx['enable'] = false
|
|
|
|
prometheus['enable'] = false
|
|
|
|
unicorn['enable'] = false
|
|
|
|
sidekiq['enable'] = false
|
|
|
|
gitlab_workhorse['enable'] = false
|
|
|
|
gitaly['enable'] = false
|
2019-11-01 12:06:26 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
##### Set up Praefect and its Gitaly nodes
|
|
|
|
|
|
|
|
In the example below, the Gitaly nodes are named `praefect-git-X`. Note that one node is designated as
|
|
|
|
primary, by setting the primary to `true`:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
# /etc/gitlab/gitlab.rb
|
2019-10-11 15:06:41 +00:00
|
|
|
|
2019-10-17 12:07:33 +00:00
|
|
|
# virtual_storage_name must match the same storage name given to praefect in git_data_dirs
|
|
|
|
praefect['virtual_storage_name'] = 'praefect'
|
2019-11-01 12:06:26 +00:00
|
|
|
praefect['auth_token'] = 'abc123secret'
|
2019-10-11 15:06:41 +00:00
|
|
|
praefect['enable'] = true
|
2019-10-01 15:06:05 +00:00
|
|
|
praefect['storage_nodes'] = [
|
|
|
|
{
|
|
|
|
'storage' => 'praefect-git-1',
|
|
|
|
'address' => 'tcp://praefect-git-1.internal',
|
2019-11-01 12:06:26 +00:00
|
|
|
'token' => 'xyz123secret',
|
2019-10-01 15:06:05 +00:00
|
|
|
'primary' => true
|
2019-10-11 15:06:41 +00:00
|
|
|
},
|
2019-10-01 15:06:05 +00:00
|
|
|
{
|
|
|
|
'storage' => 'praefect-git-2',
|
2019-10-17 12:07:33 +00:00
|
|
|
'address' => 'tcp://praefect-git-2.internal',
|
2019-11-01 12:06:26 +00:00
|
|
|
'token' => 'xyz456secret',
|
2019-10-01 15:06:05 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
'storage' => 'praefect-git-3',
|
2019-10-17 12:07:33 +00:00
|
|
|
'address' => 'tcp://praefect-git-3.internal',
|
2019-11-01 12:06:26 +00:00
|
|
|
'token' => 'xyz789secret',
|
2019-10-01 15:06:05 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2019-10-11 15:06:41 +00:00
|
|
|
Save the file and [reconfigure Praefect](../restart_gitlab.md#omnibus-gitlab-reconfigure).
|
2019-10-01 15:06:05 +00:00
|
|
|
|
2019-10-11 15:06:41 +00:00
|
|
|
#### GitLab
|
2019-10-01 15:06:05 +00:00
|
|
|
|
|
|
|
When Praefect is running, it should be exposed as a storage to GitLab. This
|
2019-11-01 12:06:26 +00:00
|
|
|
is done through setting the `git_data_dirs`.
|
|
|
|
|
|
|
|
##### On a fresh GitLab installation
|
|
|
|
|
|
|
|
On a fresh Gitlab installation, set up the `default` storage to point to praefect:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
git_data_dirs({
|
|
|
|
"default" => {
|
|
|
|
"gitaly_address" => "tcp://praefect.internal:2305"
|
|
|
|
},
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
##### On an existing GitLab instance
|
|
|
|
|
|
|
|
On an existing GitLab instance, the `default` storage is already being served by a
|
|
|
|
Gitaly node, so an additional storage can be added. `praefect` is chosen in the example
|
|
|
|
below, but it can be any name as long as it matches the `virtual_storage_name` in the
|
|
|
|
praefect attributes above.
|
|
|
|
|
|
|
|
Assuming the default storage
|
2019-10-01 15:06:05 +00:00
|
|
|
configuration is used, there would be two storages available to GitLab:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
git_data_dirs({
|
|
|
|
"default" => {
|
|
|
|
"gitaly_address" => "tcp://gitaly.internal"
|
|
|
|
},
|
|
|
|
"praefect" => {
|
|
|
|
"gitaly_address" => "tcp://praefect.internal:2305"
|
|
|
|
}
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
Restart GitLab using `gitlab-ctl restart` on the GitLab node.
|