doc/user/packages/virtual_registry/_index.md
{{< details >}}
{{< /details >}}
{{< history >}}
virtual_registry_maven. Disabled by default.maven_virtual_registry in GitLab 18.1. Disabled by default. Feature flag virtual_registry_maven removed.{{< /history >}}
[!flag] The availability of this feature is controlled by a feature flag. For more information, see the history.
Use the GitLab virtual registry to proxy and cache packages from multiple upstream registries behind a single, well-known URL.
With this approach, you can configure your applications to use one virtual registry instead of multiple upstream registries.
[!note] The GitLab virtual registry is available as part of the GitLab beta program. While it is currently available on Premium and Ultimate, final availability and pricing will be announced when the virtual registry is generally available.
To configure the virtual registry:
The virtual registry is turned on by default.
Prerequisites:
To turn off the virtual registry:
The virtual registry endpoint can be used by any of following tokens:
Tokens need one of the following scopes:
apiread_virtual_registryAccess tokens and the CI/CD job token are resolved to users. The resolved user must be either:
Manage virtual registries for a top-level group.
You can create a virtual registry for any of the supported package formats.
When you create a virtual registry:
To view a virtual registry:
To edit an existing virtual registry:
To delete a virtual registry:
Manage upstream registries in a virtual registry for a top-level group.
To view upstream registries:
To edit an upstream registry:
The order of upstream registries determines the priority in which they are queried for packages.
To change the order of upstream registries:
Best practices for upstream ordering:
For more information about the order of upstreams, see Upstream prioritization.
All upstream registries have a caching system that:
This way, the virtual registry does not have to contact the upstream again when the same package is requested.
If a requested path has not been cached in any of the available upstreams:
If the requested path has been cached in any of the available upstreams:
The virtual registry returns a 404 Not Found error if it cannot find an upstream to fulfill the request.
The cache validity period sets the amount of time, in hours, that a cache entry is considered valid to fulfill a request.
Before the virtual registry pulls from an existing cache entry, it checks the cache validity period to determine if the entry must be refreshed or not.
If the entry is outside the validity period, the virtual registry checks if the upstream response is identical to the one in the cache. If:
If the virtual registry cannot connect to an upstream due to network conditions, the upstream serves the request with the available cache entry.
As long as the virtual registry has the response related to a request in the cache, that request is fulfilled, even when outside the validity period.
The cache validity period is important in the overall performance of the virtual registry to fulfill requests. Contacting external registries is a costly operation. Smaller validity periods increase the amount of checks, and longer periods decrease them.
You can turn off cache validity checks by setting it to 0.
The default value of the cache validity period is 24 hours.
You should set the cache validity period to 0 when the external registry targeted by the upstream is known to have immutable responses. This is often the case with official public registries. For more information, check your supported package format.
You configure the cache validity period when you create or edit an upstream.
To view packages that have been cached from upstream registries:
To delete cache entries:
When you delete a cache entry, the next time the virtual registry receives a request for that file, it walks the list of upstreams again to find an upstream that can fulfill the request.
Cache entries save their files in object storage in the dependency_proxy bucket.
Object storage usage counts towards the top-level group object storage usage limit.
{{< history >}}
maven_virtual_registry. Enabled by default.virtual_registry_cleanup_policies. Disabled by default.ui_for_virtual_registry_cleanup_policy. Disabled by default.virtual_registry_cleanup_policies and ui_for_virtual_registry_cleanup_policy removed.{{< /history >}}
Virtual registries cache packages from upstream registries to improve performance and availability. Over time, these cached entries can accumulate and consume significant storage space. Use cleanup policies to automatically manage cached content and reduce storage usage.
A cleanup policy is a scheduled job that removes cached entries based on configurable rules. When a cleanup policy runs, it identifies cached entries that haven't been downloaded recently and removes them from storage.
Cleanup policies are set for all virtual registries in the top-level group.
In the virtual registry, cleanup policies:
A cleanup policy affects only cached content from upstream registries. It does not affect:
Manage a cleanup policy for virtual registries in a top-level group. Each top-level group can have up to one cleanup policy that applies to all virtual registries in that group.
Create a cleanup policy and set how often it runs.
Prerequisites:
To create a cleanup policy:
7 days. Must be between 1 and 365.Edit a cleanup policy to determine how often the policy runs.
Prerequisites:
To edit a cleanup policy:
Turn off cleanup policies for a top-level group. When turned off, the cleanup policy retains its configuration but does not run. Existing cached entries are preserved.
Prerequisites:
To turn off cleanup policies:
Use the following settings to control a cleanup policy:
After a cleanup policy runs, you can view the following execution metrics:
These metrics help you understand the effectiveness of your cleanup policy so you can adjust settings as needed.
Virtual registry performance might vary based on factors like:
Virtual registries are more advanced than public registries. When you pull dependencies with a virtual registry, it might take longer than other registries, such as public, official registries.
Compared with public registries, virtual registries also support multiple upstream registries and authentication.
Upstream registries are organized in ordered lists. When a virtual registry receives a request for a package:
This system noticeably impacts the performance of a virtual registry.
When you create a virtual registry, the cache of each configured upstream is empty. Each request requires the virtual registry to walk the list of available upstream registries to fulfill a request. These initial requests take longer to fulfill.
When an upstream registry caches a request, the time to fulfill an identical request decreases. Over time, the overall performance of the virtual registry improves as more upstream registries cache more requests.
You can use caching in GitLab CI/CD so that jobs do not have to download dependencies from the virtual registry.
This method improves execution time, but also duplicates storage for each dependency (dependencies are stored in the CI/CD cache and virtual registry).