配置外部 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 # 让 Gitaly 在所有网络接口上接受连接 6 listen_addr: '0.0.0.0:8075', 7 auth: { 8 ## 设置 Gitaly 令牌作为身份验证形式,因为你是通过网络访问 Gitaly 9 ## https://gitlab.cn/docs/administration/gitaly/configure_gitaly/#about-the-gitaly-token 10 token: 'abc123secret', 11 }, 12} 13 14gitlab_rails['gitaly_token'] = 'abc123secret' 15 16# 用于验证 Redis 的密码 17gitlab_rails['redis_password'] = 'redis-password-goes-here' -
运行 reconfigure:
shellsudo gitlab-ctl reconfigure -
重启 PostgreSQL 服务器:
shellsudo gitlab-ctl restart postgresql
设置 Sidekiq 实例
查找你的参考架构,并遵循 Sidekiq 实例设置详情。
配置使用共享存储的多个 Sidekiq 节点
如果你运行多个 Sidekiq 节点并使用共享文件存储(例如 NFS),你必须指定 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 不同的节点上,请按照以下步骤操作。
-
编辑 /etc/gitlab/gitlab.rb,并配置镜像仓库 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# 可选择将所有指标服务器日志记录到 log/sidekiq_exporter.log 6sidekiq['exporter_log_enabled'] = true -
重新配置极狐GitLab:
shellsudo gitlab-ctl reconfigure
启用 HTTPS
版本历史
- 在极狐GitLab 15.2 中引入。
要通过 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# 仅限企业版 36# https://gitlab.cn/docs/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 故障排除管理员指南。