GitLab Dependency Proxy 관리
- 이슈에서 도입됨 GitLab Premium 11.11에서.
- 이슈에서 이동됨 GitLab Premium에서 GitLab Free로 13.6으로.
GitLab은 다양한 공통 패키지 관리자에 대한 의존성 프록시로 사용할 수 있습니다.
이는 관리 문서입니다. 의존성 프록시를 사용하는 방법을 알고 싶다면 사용자 가이드를 참조하세요.
GitLab 의존성 프록시:
- 기본적으로 켜져 있습니다.
- 관리자가 꺼릴 수 있습니다.
- Puma 웹 서버 가 활성화되어 있어야 합니다. Puma는 GitLab 13.0 이후로 기본적으로 활성화됩니다.
의존성 프록시 끄기
의존성 프록시는 기본적으로 활성화되어 있습니다. 관리자인 경우, 의존성 프록시를 끌 수 있습니다. 의존성 프록시를 끄려면 GitLab 설치에 해당하는 지침을 따르세요.
-
/etc/gitlab/gitlab.rb
를 편집하고 다음 줄을 추가하세요:gitlab_rails['dependency_proxy_enabled'] = false
-
파일을 저장하고 변경 사항이 적용되도록 GitLab을 다시 구성하세요.
설치가 완료된 후, 의존성 프록시를 끄기 위해 전역 appConfig
를 업데이트하세요:
global:
appConfig:
dependencyProxy:
enabled: false
bucket: gitlab-dependency-proxy
connection: {}
secret:
key:
자세한 내용은 전역을 사용하여 차트 구성을 참조하세요.
-
설치가 완료된 후,
config/gitlab.yml
에서dependency_proxy
섹션을 구성하세요. 의존성 프록시를 끄려면enabled
를false
로 설정하세요:dependency_proxy: enabled: false
-
변경 사항이 적용되도록 GitLab을 다시 시작하세요.
다중 노드 GitLab 설치
각 Web 및 Sidekiq 노드에 대해 Linux 패키지 설치 단계를 따르세요.
의존성 프록시 켜기
의존성 프록시는 기본적으로 켜져 있지만 관리자가 껄 수 있습니다. 매뉴얼으로 끄려면 의존성 프록시 끄기에서 지침을 따르세요.
저장 경로 변경
기본적으로 의존성 프록시 파일은 로컬에 저장되지만, 기본 로컬 위치를 변경하거나 객체 리포지터리를 사용할 수 있습니다.
로컬 저장 경로 변경
Linux 패키지 설치를 위한 의존성 프록시 파일은 /var/opt/gitlab/gitlab-rails/shared/dependency_proxy/
에 저장되며, 소스
설치를 위한 파일은 shared/dependency_proxy/
에 저장됩니다 (Git 홈 디렉터리 기준).
-
/etc/gitlab/gitlab.rb
를 편집하고 다음 줄을 추가하세요:gitlab_rails['dependency_proxy_storage_path'] = "/mnt/dependency_proxy"
-
파일을 저장하고 변경 사항이 적용되도록 GitLab을 다시 구성하세요.
-
config/gitlab.yml
의dependency_proxy
섹션을 편집하세요:dependency_proxy: enabled: true storage_path: shared/dependency_proxy
-
변경 사항이 적용되도록 GitLab을 다시 시작하세요.
객체 리포지터리 사용
로컬 저장에 의존하는 대신, 의존성 프록시의 블롭을 저장하기 위해 객체 리포지터리를 사용할 수 있습니다. GitLab 13.2 이상에서는 통합된 객체 리포지터리 설정을 사용해야 합니다. 이 섹션은 이전 구성 형식을 설명합니다. 마이그레이션 단계가 적용됩니다.
GitLab과 객체 리포지터리를 사용에 대해 자세히 알아보기.
-
/etc/gitlab/gitlab.rb
를 편집하고 다음 줄을 추가하세요 (필요한 곳은 주석을 해제하세요):gitlab_rails['dependency_proxy_enabled'] = true gitlab_rails['dependency_proxy_storage_path'] = "/var/opt/gitlab/gitlab-rails/shared/dependency_proxy" gitlab_rails['dependency_proxy_object_store_enabled'] = true gitlab_rails['dependency_proxy_object_store_remote_directory'] = "dependency_proxy" # The bucket name. gitlab_rails['dependency_proxy_object_store_proxy_download'] = false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage. gitlab_rails['dependency_proxy_object_store_connection'] = { ## ## If the provider is AWS S3, uncomment the following ## #'provider' => 'AWS', #'region' => 'eu-west-1', #'aws_access_key_id' => 'AWS_ACCESS_KEY_ID', #'aws_secret_access_key' => 'AWS_SECRET_ACCESS_KEY', ## ## If the provider is other than AWS (an S3-compatible one), uncomment the following ## #'host' => 's3.amazonaws.com', #'aws_signature_version' => 4 # For creation of signed URLs. Set to 2 if provider does not support v4. #'endpoint' => 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces. #'path_style' => false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'. }
-
파일을 저장하고 변경 사항이 적용되도록 GitLab을 다시 구성하세요.
-
config/gitlab.yml
의dependency_proxy
섹션을 편집하세요 (필요한 곳은 주석을 해제하세요):dependency_proxy: enabled: true ## ## 빌드 의존성 프록시가 저장되는 위치 (기본값: shared/dependency_proxy). ## # storage_path: shared/dependency_proxy object_store: enabled: false remote_directory: dependency_proxy # The bucket name. # proxy_download: false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage. connection: ## ## If the provider is AWS S3, use the following ## provider: AWS region: us-east-1 aws_access_key_id: AWS_ACCESS_KEY_ID aws_secret_access_key: AWS_SECRET_ACCESS_KEY ## ## If the provider is other than AWS (an S3-compatible one), comment out the previous 4 lines and use the following instead: ## # host: 's3.amazonaws.com' # default: s3.amazonaws.com. # aws_signature_version: 4 # For creation of signed URLs. Set to 2 if provider does not support v4. # endpoint: 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces. # path_style: false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'.
-
변경 사항이 적용되도록 GitLab을 다시 시작하세요.
로컬 의존성 프록시 블롭 및 매니페스트를 객체 리포지터리로 마이그레이션
- 소개됨 GitLab 14.8에서.
객체 리포지터리 사용 후, 기존의 의존성 프록시 블롭 및 매니페스트를 로컬 리포지터리에서 원격 리포지터리로 마이그레이션하는 다음 작업을 사용합니다. 처리는 백그라운드 워커에서 이루어지며 다운타임이 필요하지 않습니다.
-
Linux 패키지 설치의 경우:
sudo gitlab-rake "gitlab:dependency_proxy:migrate"
-
직접 컴파일한 설치의 경우:
RAILS_ENV=production sudo -u git -H bundle exec rake gitlab:dependency_proxy:migrate
선택적으로 진행 상황을 추적하고 모든 의존성 프록시 블롭과 매니페스트가 성공적으로 마이그레이션되었는지 확인하려면 PostgreSQL 콘솔을 사용할 수 있습니다:
- 버전 14.1 이전의 Linux 패키지 설치에 대해
sudo gitlab-rails dbconsole
. - 버전 14.2 이상의 Linux 패키지 설치에 대해
sudo gitlab-rails dbconsole --database main
. - 직접 컴파일한 인스턴스의 경우
sudo -u git -H psql -d gitlabhq_production
.
objectstg
(여기서 file_store = '2'
)에 각각의 쿼리에 대한 모든 의존성 프록시 블롭과 매니페스트 수가 제대로 있는지 확인하세요:
gitlabhq_production=# SELECT count(*) AS total, sum(case when file_store = '1' then 1 else 0 end) AS filesystem, sum(case when file_store = '2' then 1 else 0 end) AS objectstg FROM dependency_proxy_blobs;
total | filesystem | objectstg
------+------------+-----------
22 | 0 | 22
gitlabhq_production=# SELECT count(*) AS total, sum(case when file_store = '1' then 1 else 0 end) AS filesystem, sum(case when file_store = '2' then 1 else 0 end) AS objectstg FROM dependency_proxy_manifests;
total | filesystem | objectstg
------+------------+-----------
10 | 0 | 10
dependency_proxy
폴더에 디스크에 파일이 없는지 확인하세요:
sudo find /var/opt/gitlab/gitlab-rails/shared/dependency_proxy -type f | grep -v tmp | wc -l
JWT 만료 변경
의존성 프록시는 Docker v2 토큰 인증 흐름을 따르며
클라이언트에게 pull 요청에 사용할 JWT를 발급합니다. 토큰 만료 시간은 애플리케이션 설정 container_registry_token_expire_delay
를 사용하여 구성할 수 있습니다.
rails 콘솔에서 변경할 수 있습니다:
# JWT 만료 시간을 30분으로 업데이트
ApplicationSetting.update(container_registry_token_expire_delay: 30)
기본 만료 및 GitLab.com의 만료는 15분입니다.
프록시 뒤에 있는 의존성 프록시 사용
-
/etc/gitlab/gitlab.rb
파일을 편집하고 다음 라인을 추가합니다:gitlab_workhorse['env'] = { "http_proxy" => "http://USERNAME:PASSWORD@example.com:8080", "https_proxy" => "http://USERNAME:PASSWORD@example.com:8080"
-
파일을 저장하고 변경 사항이 적용되려면 GitLab 다시 설정을 수행하세요.