Installing GitLab on Google Cloud Platform

原文:https://docs.gitlab.com/ee/install/google_cloud_platform/

Installing GitLab on Google Cloud Platform

本指南将帮助您在Google Cloud Platform(GCP)实例上安装 GitLab.

替代安装方法: Google 提供了一份白皮书,用于在 Google Kubernetes Engine 上部署可投入生产的 GitLab ,包括所有步骤和外部资源配置. 这些是使用 GCP VM 的替代方法,并使用Cloud native GitLab Helm chart .

Prerequisites

在 GCP 上安装 GitLab 的前提条件只有两个:

  1. 您需要有一个 Google 帐户.
  2. 您需要注册 GCP 计划. 如果您是第一次,Google 会为您提供$ 300 的信用额,可在 60 天内免费使用.

完成这两个步骤后,就可以创建 VM 了 .

Creating the VM

要在 GCP 上部署 GitLab,您首先需要创建一个虚拟机:

  1. 转到https://console.cloud.google.com/compute/instances并使用您的 Google 凭据登录.
  2. 点击创建

    Search for GitLab

  3. On the next page, you can select the type of VM as well as the estimated costs. Provide the name of the instance, desired datacenter, and machine type. Note our hardware requirements for different user base sizes.

    Launch on Compute Engine

  4. 要选择大小,类型和所需的操作系统 ,请在” Boot disk 下单击” 更改 “. 完成后单击” 选择” .

  5. 最后,允许 HTTP 和 HTTPS 通信,然后点击创建 . 该过程将在几秒钟内完成.

Installing GitLab

几秒钟后,实例将被创建并可以登录.下一步是将 GitLab 安装到实例上.

Deploy settings

  1. 记下实例的 IP 地址,因为在后续步骤中将需要使用该 IP 地址.
  2. 单击 SSH 按钮以连接到实例.
  3. 登录到实例后,将出现一个新窗口.

    GitLab first sign in

  4. 接下来,在https://about.gitlab.com/install/上按照说明为您选择的操作系统安装 GitLab. 您可以将上述步骤中的 IP 地址用作主机名.

  5. 恭喜你! GitLab 现在已安装,您可以通过浏览器访问它. 要完成安装,请在浏览器中打开 URL 并提供初始管理员密码. 该帐户的用户名是root .

    GitLab first sign in

Next steps

这些是首次安装 GitLab 之后要执行的最重要的后续步骤.

Assigning a static IP

默认情况下,Google 会为您的实例分配一个临时 IP. 如果您要在生产中使用 GitLab 并使用域名,则强烈建议分配一个静态 IP,如下所示.

阅读 Google 有关如何提升临时 IP 地址的文档.

Using a domain name

假设您拥有一个域名,并且已正确设置 DNS 以指向在上一步中配置的静态 IP,则可以通过以下方法配置 GitLab 以了解更改:

  1. SSH 进入虚拟机. 您可以轻松使用 Google 控制台中的SSH按钮,然后会弹出一个新窗口.

    SSH button

    将来,您可能想设置使用 SSH 密钥的连接 .

  2. 使用您喜欢的文本编辑器编辑 Omnibus GitLab 的配置文件:

    1. sudo vim /etc/gitlab/gitlab.rb
  3. external_url值设置为您希望 GitLab 在不使用 https 情况下拥有的域名:

    1. external_url 'http://gitlab.example.com'

    我们将在下一步中设置 HTTPS,而现在无需这样做.

  4. 重新配置 GitLab,以使更改生效:

    1. sudo gitlab-ctl reconfigure
  5. 您现在可以使用域名访问 GitLab.

Configuring HTTPS with the domain name

尽管不需要,但强烈建议使用 TLS 证书保护 GitLab. 请遵循Omnibus 文档中的步骤.

Configuring the email SMTP settings

您需要正确配置电子邮件 SMTP 设置,否则 GitLab 将无法发送通知电子邮件,例如注释和密码更改. 检查Omnibus 文档的操作方法.

Further reading

可以将 GitLab 配置为与其他 OAuth 提供程序,LDAP,SAML,Kerberos 等进行身份验证.以下是您可能感兴趣阅读的一些文档: