728x90
반응형
EC2에 gitlab-ce 버전 띄우기
기존 회사 gitlab 버전때문에 cicd 가 되지 않아 버전업을 알아보다가
새로 띄워서 옮기기로 했다.
EC2 띄우기
- arm64
- instance type : r6g.large (기존 서버 cpu/ram 동일하게 맞추려고 선택, ram이 두배 높지만 시간당 가격 비슷)
- storage : gp3 200GB (기존 gp2 200GB)
- pem키 사용
- 보안 그룹 : 인바운드 (22/8081) / 아웃바운드 (전체)
- 퍼블릭 ip 할당 안받고 프라이빗으로 설정 후 점프서버로 로컬포워딩 접속예정
gitlab-ce 15.1.2 버전 설치
- ec2에 접속
$ vim ~/.ssh/ssh_config
Host gitlab.test
User ec2-user
HostName 10.0.x.x
$ ssh gitlab.test
- yum update
[ec2-user@ip-10-0-x-x ~] sudo yum update -y
- gitlab-ce package 설치
[ec2-user@ip-10-0-x-x ~] curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
- gitlab-ce install
(https://packages.gitlab.com/gitlab/gitlab-ce/packages/amazon/2/gitlab-ce-15.1.2-ce.0.amazon2.aarch64.rpm)
[ec2-user@ip-10-0-x-x ~] sudo yum install gitlab-ce-15.1.2-ce.0.amazon2.aarch64
하지만 에러가 떴다...
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
No package gitlab-ce-15.1.2-ce.0.amazon2.aarch64 available.
Error: Nothing to do
- wget 으로 rpm 설치
[ec2-user@ip-10-0-x-x ~] wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/amazon/2/gitlab-ce-15.1.2-ce.0.amazon2.aarch64.rpm/download.rpm
- rpm install
[ec2-user@ip-10-0-x-x ~]$ sudo rpm -ivh gitlab-ce-15.1.2-ce.0.amazon2.aarch64.rpm
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
gitlab.rb 설정
- gitlab.rb 에 external_url을 변경 해줘야 한다.
[ec2-user@ip-10-0-x-x ~]$ sudo cat /etc/gitlab/gitlab.rb | grep external_url
##! For more details on configuring external_url see:
external_url 'http://gitlab.example.com'
# registry_external_url 'https://registry.example.com'
# pages_external_url "http://pages.example.com/"
# gitlab_pages['artifacts_server_url'] = nil # Defaults to external_url + '/api/v4'
# gitlab_pages['auth_redirect_uri'] = nil # Defaults to projects subdomain of pages_external_url and + '/auth'
# gitlab_pages['gitlab_server'] = nil # Defaults to external_url
# gitlab_rails['gitlab_kas_external_url'] = 'ws://gitlab.example.com/-/kubernetes-agent/'
# mattermost_external_url 'http://mattermost.example.com'
# When the registry is automatically enabled using the same domain as `external_url`,
# For example, if external_url is the same for two secondaries, you must specify
# If it is blank, it defaults to external_url.
위 명령어를 쳐보면 external_url 'http://gitlab.example.com' 이 라인에 example url을 변경해줘야한다.
- gitlab.rb - external_url 변경
# vim으로 external_url 변경
# 나는 localhost test 기때문에 localhost 이고 다른 url이 있다면 그 url로 설정하면 된다.
ex) external_url 'http://gitlab.test.com:8081'
[ec2-user@ip-10-0-x-x ~]$ sudo vim /etc/gitlab/gitlab.rb
external_url 'http://localhost.com:8081'
# 설정 저장
[ec2-user@ip-10-0-x-x ~]$ sudo gitlab-ctl reconfigure
...
gitlab Reconfigured!
[ec2-user@ip-10-0-x-x ~]$ sudo gitlab-ctl restart
접속
- ssh local forward
$ vim ~/.ssh/ssh_config
Host x_jump
HostName x.x.x.x
User ec2-user
IdentityFile ~/.ssh/test.pem
# gitlab
LocalForward 9714 10.0.x.x:8081
$ ssh -f -N x_jump
- http://localhost.com:9714 주소창에 입력
admin id/password
- ec2 접속
[ec2-user@ip-10-0-x-x ~] sudo gitlab-rails console -e production
# 1번째 id 확인
irb(main):001:0> user=User.where(id:1).first
=> #<User id:1 @root>
# password 설정
irb(main):002:0> user.password='test1234'
=> "test1234"
irb(main):003:0> user.password_confirmation='test1234'
=> "test1234"
# 저장
irb(main):004:0> user.save
=> true
irb(main):005:0> exit
login
- url 접속 후 위에서 설정했던 root / test1234 로 접속하면 admin 으로 로그인이 가능하다.
pull / push test
- test 할때 기본 command line 을 보면 localhost:8081 로 되어있는데 로컬포워딩때 입력한 포트로 변경해준다.
# 기존
git clone http://localhost:8081/gitlab/Monitoring.git
git remote add origin http://localhost:8081/gitlab/Monitoring.git
# localForward 9714
git clone http://localhost:9714/gitlab/Monitoring.git
git remote add origin http://localhost:9714/gitlab/Monitoring.git
마치며
기존에 작업했던 사수들이 퇴사한지라 구글링 열심히 하며 테스트 해보았다.
이제 유저 / 기존 레포 옮겨야 하는데 mirror 해야할지 import 해야할지 고민해봐야겠다.
일단 유저부터 옮겨보자.
버전업도 생각했는데 기존 깃 버전이 8버전이다.
지금 나온 15버전까지 올리려면 방법이 깃랩은 메이저 버전이 올라가면
이전버전 라스트 한번 메이저버전 한번 이렇게 해야한다더라
예) 8.x 마지막버전 -> 9.x 신규버전 -> 9.x 마지막버전 -> 10.x 신규버전
728x90
반응형
'개발 > AWS' 카테고리의 다른 글
AWS stepfunction ECS 실행 (1) | 2022.12.09 |
---|---|
AWS aws-vault (0) | 2022.05.20 |
AWS Lambda SQS Trigger (0) | 2022.05.19 |
AWS DMS VPC 보조 CIDR (0) | 2022.05.19 |
AWS Lambda serverless v3 version up (0) | 2022.05.12 |