配置外部 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/ee/administration/gitaly/configure_gitaly.html#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 节点
如果您运行多个具有共享文件存储(如 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 不同的节点上,请按照以下步骤操作。
-
编辑 /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
History
- 引入于极狐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 配置添加到您的 Sidekiq 节点以及 LDAP 同步工作器。如果 LDAP 配置和 LDAP 同步工作器未应用于您的 Sidekiq 节点,用户和群组将不会自动同步。
有关配置极狐GitLab 的 LDAP 的更多信息,请参阅:
要为 Sidekiq 启用带同步工作器的 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/ee/administration/auth/ldap/ldap_synchronization.html 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 故障排除管理员指南。