Skip to content

UbuntuにGitLabインストール

1. インストール

bash
sudo su -
apt update

# gitlabリポジトリ有効化
curl -fsSL https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | bash

# インストール
EXTERNAL_URL="http://localhost" apt install -y gitlab-ce

EXTERNAL_URLはローカルで動作確認後に変更する。

インストール後に確認

bash
# ステータス確認
gitlab-ctl status

# パスワード確認
cat /etc/gitlab/initial_root_password
Password: sO28OfveeXQTvyb3g92dwb7v6CUWDA7Vfqk0NDXNf/Y=

ヘルスチェックも確認

bash
root@ip-10-0-10-105:~# curl http://localhost/-/health
GitLab OK

root@ip-10-0-10-105:~# curl http://10.0.10.105/-/health
Not Found

EC2のIPアドレスで指定するとNotFoundとなるのは、現時点ではEXTERNAL_URL="http://localhost"で起動しているためである。

EXTERNAL_URLを外部アクセス用に変更

bash
# 設定ファイルを開く
vi /etc/gitlab/gitlab.rb

該当箇所を以下に変更する

rb
external_url "https://pc2029gitlab.noimk.com"

nginx['listen_port'] = 80
nginx['listen_https'] = false
gitlab_rails['monitoring_whitelist'] = ['127.0.0.0/8', '10.0.0.0/16']

反映

bash
gitlab-ctl reconfigure

SSMにて疎通確認

bash
root@ip-10-0-10-105:~# curl http://localhost/-/health
GitLab OK

root@ip-10-0-10-105:~# curl http://10.0.10.105/-/health
GitLab OK

2. ALBからもHealtyになっているか確認

EC2(GitLabサーバ)単体での起動状態は正常となったため、ALBから見てもHealty状態か確認する。ALBから見てターゲットグループがUnhealtyの場合にはそもそも相互認証(mTLS)すらされず、503 Service Unavailable 状態となり、ブラウザでアクセスしてもダンマリ状態となる。