devops/CICD

GitLab + ArgoCD를 활용한 CI/CD (GitLab 세팅 후 배포준비) <1>

Hoony.Song 2023. 6. 2. 13:08
반응형
vm.hostname os cpu hard memory ip
master ubuntu 20.04 4 30GB 16 192.168.42.100
worker1 ubuntu 20.04 4 30GB 4 192.168.42.101
worker2 ubuntu 20.04 4 30GB 4 192.168.42.102
NFS ubuntu 20.04 4 30GB 4 192.168.42.200

 

kubernetes cluster 를 구성 한 뒤 진행 해야 합니다 
  • GitLab-CE repository를 추가 합니다. 
curl -sS <https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh> | sudo bash

 

  • gitlab-ce를 설치 합니다
apt-get update apt-get install -y gitlab-ce # 이렇게 설치하면 ip 설정 후 재시작 해야 함 재시작 필요 없음

  • gitlab external_url 을 변경 후 GitLab을 재시작 합니다
sudo vi /etc/gitlab/gitlab.rb

# external_url 을 ip:port 로 변경 합니다
 external_url 'http://192.168.42.100:8081'

 sudo gitlab-ctl reconfigure

 

  • gitlab install 시 ip를 지정 할 수 있습니다
sudo EXTERNAL_URL="192.168.42.100:8888" apt-get install -y gitlab-ce # 이렇게 하면 설치시 ip 설정

 

  • 초기 비밀번호를 출력 합니다
cat /etc/gitlab/initial_root_password

root@master:/home/user# cat /etc/gitlab/initial_root_password
# WARNING: This value is valid only in the following conditions
#          1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
#          2. Password hasn't been changed manually, either via UI or via command line.
#
#          If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.

Password: uh4884fRkQKlM/Itls4QLN05LjQcmB9cGbeU0kFz+Cw=

 

  • 접속 후 로그인
    • 초기 id = root
    • 초기 패스워드 = 위에 출력된 Password

 

  • 깃랩 설치 후 깃랩에 접속 및 로그인 후 → new group → create group 을 차례로 클릭 합니다

 

  • 그룹 생성 화면에서
    • Groupname = dev
    • Visibility level = public
    • 그리고 생성 버튼을 누릅니다

 

  • 생성한 dev 그룹 안에서 Create Project → Create Blank Project 차례로 클릭 후
    • Project name = test
    • Visibility Level = public
    • 그리고 생성버튼 클릭 합니다

 

  • 윈도우에 Git 설치 후 바탕화면에 폴더를 하나 생성 한 뒤 Git bash here 를 클릭 합니다

 

  • git repository 생성
    • git init -> git 준비
    • echo "Hello world" > test.html -> 깃랩에 올릴 파일 생성
    • git config --global user.email "@naver.com" 깃 로그인
    • git config --global user.name "SRE" 깃 이름 설정
    • git remote add origin <http://192.168.42.100:8888/dev/test.git> → 깃랩 원격 저장소 추가
    • git add . -> 깃랩에 현재 디렉토리에 있는 파일 추가
    • git commit -m "test.html 추가" -> 깃 커밋 로그 작성
    • git push origin master -> master 브랜치에 푸시

 

  • gitlab 새로고침 후 repository → file → branches(master) 에 test파일 등록을 확인 합니다

 

Gitlab 준비 끝 

반응형