The files of the instance — CI artifacts, LFS objects, uploads, packages and the rest — are stored on the disk of the node by default. With an object storage, they are stored in an S3-compatible storage and no longer stay on the local disk. The block below is added to /etc/gitlab/gitlab.rb on every node.
Configuration
The object storage takes the files of the listed types. Without the storage, they lie on the disk of the node under /var/opt/gitlab/gitlab-rails:
Key in objects | What it stores | Path without the storage |
|---|---|---|
artifacts | CI artifacts, archived job logs included | shared/artifacts |
external_diffs | Merge request diffs kept outside the database; the type is switched on with gitlab_rails['external_diffs_enabled'] | shared/external-diffs |
lfs | Git LFS objects | shared/lfs-objects |
uploads | Uploaded files: avatars, attachments, images in Markdown | uploads |
packages | Packages of the package registry | shared/packages |
dependency_proxy | Dependency Proxy cache | shared/dependency_proxy |
terraform_state | Terraform state files | shared/terraform_state |
ci_secure_files | CI secure files | shared/ci_secure_files |
ci_catalog_bundles | CI/CD component bundles | shared/ci_catalog_bundles |
pages | GitLab Pages sites; the type applies with GitLab Pages turned on | shared/pages |
The container registry is connected through the separate registry['storage']['s3'] setting and stays outside the consolidated block.
Add the block to /etc/gitlab/gitlab.rb on every node — the block is the same everywhere:
gitlab_rails['object_store']['enabled'] = true
gitlab_rails['object_store']['proxy_download'] = true
gitlab_rails['object_store']['connection'] = {
'provider' => 'AWS',
'region' => '<S3_REGION>',
'aws_access_key_id' => '<S3_ACCESS_KEY_ID>',
'aws_secret_access_key' => '<S3_SECRET_ACCESS_KEY>',
'endpoint' => 'https://<S3_ENDPOINT_URL>',
'path_style' => true,
'aws_signature_version' => 4
}
gitlab_rails['object_store']['objects']['artifacts']['bucket'] = '<ARTIFACTS_BUCKET>'
# Uncomment with external merge request diffs enabled:
# gitlab_rails['object_store']['objects']['external_diffs']['bucket'] = '<EXTERNAL_DIFFS_BUCKET>'
gitlab_rails['object_store']['objects']['lfs']['bucket'] = '<LFS_BUCKET>'
gitlab_rails['object_store']['objects']['uploads']['bucket'] = '<UPLOADS_BUCKET>'
gitlab_rails['object_store']['objects']['packages']['bucket'] = '<PACKAGES_BUCKET>'
gitlab_rails['object_store']['objects']['dependency_proxy']['bucket'] = '<DEPENDENCY_PROXY_BUCKET>'
gitlab_rails['object_store']['objects']['terraform_state']['bucket'] = '<TERRAFORM_STATE_BUCKET>'
gitlab_rails['object_store']['objects']['ci_secure_files']['bucket'] = '<CI_SECURE_FILES_BUCKET>'
gitlab_rails['object_store']['objects']['ci_catalog_bundles']['bucket'] = '<CI_CATALOG_BUNDLES_BUCKET>'
# Uncomment with GitLab Pages enabled:
# gitlab_rails['object_store']['objects']['pages']['bucket'] = '<PAGES_BUCKET>'The connection (connection) is one for all types: <S3_ENDPOINT_URL> is the address of the S3-compatible storage, <S3_REGION> is its region, <S3_ACCESS_KEY_ID> and <S3_SECRET_ACCESS_KEY> are the access key ID and the secret access key for it. For <ARTIFACTS_BUCKET> and every other placeholder ending in _BUCKET, substitute the name of your bucket for that type. path_style: true is for storages that address the bucket in the URL path, as <endpoint>/<bucket>/<object>; the default false addresses the bucket in the host name, as <bucket>.<endpoint>. aws_signature_version is the request signing version; if the storage does not support version 4, set 2.
The block turns on the storage for every object type, and every type has its own bucket. If an enabled type has no bucket, the application reports Object storage for <object type> must have a bucket specified at startup; for pages, ci_secure_files and ci_catalog_bundles a warning is written to the log instead, and they stay on the disk. A type that must stay on the disk is switched off with gitlab_rails['object_store']['objects']['<type>']['enabled'] = false.
gitlab_rails['object_store']['proxy_download'] sets how files are served. With true, Workhorse serves the file to the client, and only the nodes of the instance need network access to the storage. With false, the client receives a redirect to the object and downloads it from the storage directly, so the storage address must be reachable for the clients as well.
The per-type storage settings — a separate enablement and a separate connection for each type — must not be combined with the block above. Server-side encryption is set with the server_side_encryption and server_side_encryption_kms_key_id keys of gitlab_rails['object_store']['storage_options'].
Apply the change on every node:
sudo gitlab-ctl reconfigureIn a multi-node instance, job logs can be lost: a log is written to the disk of the node that receives it from the runner, and is archived by a Sidekiq job on another node.
Turn on incremental logging: select “Admin” → “Settings” → “CI/CD”, in the job logs section, in the “Incremental logging configuration” group select the “Turn on incremental logging” checkbox, then select “Save changes”. With incremental logging, the log is stored in Redis and moved to the object storage when the job finishes, so the storage for artifacts is set up before it is turned on.
Moving existing files
The storage does not move existing files: the files written before it was enabled stay on the node disks. Move every type once for the instance — the Rake tasks run on one node:
sudo gitlab-rake gitlab:artifacts:migrate
sudo gitlab-rake gitlab:lfs:migrate
sudo gitlab-rake "gitlab:uploads:migrate:all"
sudo gitlab-rake "gitlab:packages:migrate"
sudo gitlab-rake "gitlab:dependency_proxy:migrate"
sudo gitlab-rake gitlab:terraform_states:migrate
sudo gitlab-rake gitlab:ci_secure_files:migrateThere are no migration commands for the CI/CD component bundles.