配置外部 Sidekiq 实例
Tier: 基础版,专业版,旗舰版
Offering: 私有化部署
您可以使用极狐GitLab 软件包中内置的 Sidekiq 来配置外部 Sidekiq 实例。Sidekiq 需要连接到 Redis、PostgreSQL 和 Gitaly 实例。
在极狐GitLab 实例上为 PostgreSQL、Gitaly 和 Redis 配置 TCP 访问
默认情况下,极狐GitLab 使用 UNIX 套接字,未设置为通过 TCP 通信。要进行更改:
-
配置软件包内置的 PostgreSQL 服务器以监听 TCP/IP,将 Sidekiq 服务器 IP 地址添加到 postgresql['md5_auth_cidr_addresses']
-
在极狐GitLab 实例上编辑 /etc/gitlab/gitlab.rb 文件,并添加以下内容:
ruby1## Gitaly 2gitaly['configuration'] = { 3 # ... 4 # 5 # Make Gitaly accept connections on all network interfaces 6 listen_addr: '0.0.0.0:8075', 7 auth: { 8 ## Set up the Gitaly token as a form of authentication because you are accessing Gitaly over the network 9 ## https://docs.gitlab.com/administration/gitaly/configure_gitaly/#about-the-gitaly-token 10 token: 'abc123secret', 11 }, 12} 13 14gitlab_rails['gitaly_token'] = 'abc123secret' 15 16# Password to Authenticate Redis 17gitlab_rails['redis_password'] = 'redis-password-goes-here' -
运行 reconfigure:
shellsudo gitlab-ctl reconfigure -
重启 PostgreSQL 服务器:
shellsudo gitlab-ctl restart postgresql
设置 Sidekiq 实例
找到您的参考架构,并按照 Sidekiq 实例设置详情进行操作。
使用共享存储配置多个 Sidekiq 节点
如果您使用共享文件存储(如 NFS)运行多个 Sidekiq 节点,则必须指定 UID 和 GID,以确保它们在服务器之间保持一致。指定 UID 和 GID 可防止文件系统中的权限问题。此建议与 Geo 设置的建议类似。
要设置多个 Sidekiq 节点:
-
编辑 /etc/gitlab/gitlab.rb:
ruby1user['uid'] = 9000 2user['gid'] = 9000 3web_server['uid'] = 9001 4web_server['gid'] = 9001 5registry['uid'] = 9002 6registry['gid'] = 9002 -
重新配置极狐GitLab:
shellsudo gitlab-ctl reconfigure
使用外部 Sidekiq 时配置容器镜像仓库
如果您使用容器镜像仓库,并且它运行在与 Sidekiq 不同的节点上,请按照以下步骤操作。
- 启用镜像仓库:
rubygitlab_rails['registry_enabled'] = true
- 配置镜像仓库 URL:
rubygitlab_rails['registry_api_url'] = "https://registry.example.com"
- 重新配置极狐GitLab:
shellsudo gitlab-ctl reconfigure
- 在托管容器镜像仓库的实例中,将 registry.key 文件复制到 Sidekiq 节点。
配置 Sidekiq 指标服务器
如果您想收集 Sidekiq 指标,请启用 Sidekiq 指标服务器。指标可从 localhost:8082/metrics 获取。
要配置指标服务器:
-
编辑 /etc/gitlab/gitlab.rb:
ruby1sidekiq['metrics_enabled'] = true 2sidekiq['listen_address'] = "localhost" 3sidekiq['listen_port'] = 8082 4 5# Optionally log all the metrics server logs to log/sidekiq_exporter.log 6sidekiq['exporter_log_enabled'] = true -
重新配置极狐GitLab:
shellsudo gitlab-ctl reconfigure
启用 HTTPS
要通过 HTTPS 而非 HTTP 提供指标,请在导出器设置中启用 TLS:
-
编辑 /etc/gitlab/gitlab.rb,添加(或找到并取消注释)以下行:
rubysidekiq['exporter_tls_enabled'] = true sidekiq['exporter_tls_cert_path'] = "/path/to/certificate.pem" sidekiq['exporter_tls_key_path'] = "/path/to/private-key.pem" -
保存文件并重新配置极狐GitLab 以使更改生效。
启用 TLS 后,将使用与前面所述相同的 port 和 address。指标服务器无法同时提供 HTTP 和 HTTPS。
配置健康检查
如果您使用健康检查探针来观察 Sidekiq,请启用 Sidekiq 健康检查服务器。要使健康检查可从 localhost:8092 获取:
-
编辑 /etc/gitlab/gitlab.rb:
rubysidekiq['health_checks_enabled'] = true sidekiq['health_checks_listen_address'] = "localhost" sidekiq['health_checks_listen_port'] = 8092 -
重新配置极狐GitLab:
shellsudo gitlab-ctl reconfigure
有关健康检查的更多信息,请参阅 Sidekiq 健康检查页面。
配置 LDAP 和用户或群组同步
如果您使用 LDAP 进行用户和群组管理,则必须将 LDAP 配置以及 LDAP 同步 worker 添加到您的 Sidekiq 节点。如果 LDAP 配置和 LDAP 同步 worker 未应用到您的 Sidekiq 节点, 则用户和群组不会自动同步。
有关为极狐GitLab 配置 LDAP 的更多信息,请参阅:
要为 Sidekiq 启用带同步 worker 的 LDAP:
-
编辑 /etc/gitlab/gitlab.rb:
ruby1gitlab_rails['ldap_enabled'] = true 2gitlab_rails['prevent_ldap_sign_in'] = false 3gitlab_rails['ldap_servers'] = { 4'main' => { 5'label' => 'LDAP', 6'host' => 'ldap.mydomain.com', 7'port' => 389, 8'uid' => 'sAMAccountName', 9'encryption' => 'simple_tls', 10'verify_certificates' => true, 11'bind_dn' => '_the_full_dn_of_the_user_you_will_bind_with', 12'password' => '_the_password_of_the_bind_user', 13'tls_options' => { 14 'ca_file' => '', 15 'ssl_version' => '', 16 'ciphers' => '', 17 'cert' => '', 18 'key' => '' 19}, 20'timeout' => 10, 21'active_directory' => true, 22'allow_username_or_email_login' => false, 23'block_auto_created_users' => false, 24'base' => 'dc=example,dc=com', 25'user_filter' => '', 26'attributes' => { 27 'username' => ['uid', 'userid', 'sAMAccountName'], 28 'email' => ['mail', 'email', 'userPrincipalName'], 29 'name' => 'cn', 30 'first_name' => 'givenName', 31 'last_name' => 'sn' 32}, 33'lowercase_usernames' => false, 34 35# Enterprise Edition only 36# https://docs.gitlab.com/administration/auth/ldap/ldap_synchronization/ 37'group_base' => '', 38'admin_group' => '', 39'external_groups' => [], 40'sync_ssh_keys' => false 41} 42} 43gitlab_rails['ldap_sync_worker_cron'] = "0 */12 * * *" -
重新配置极狐GitLab:
shellsudo gitlab-ctl reconfigure
为 SAML 群组同步配置 SAML 群组
如果您使用 SAML 群组同步,则必须在所有 Sidekiq 节点上配置 SAML 群组。
故障排除
请参阅 Sidekiq 故障排除管理员指南。