본문 바로가기

DevOps/Jenkins

Jenkins Master-Slave with AWS

Jenkins Slave Instance 띄우기

AWS instance 띄우는거 참고


Jenkins Master에 slave-node 등록하기




  1. Jenkins > 
  2. New Node
  3. SSH 접속을 위한 계정 생성
    1. Jenkins > Credentials 
    2. global 선택
    3. Add Credentails
      • SSH Username with private key
      • private key - enter directly ( 이제 private key 를 만들러 가보자 )
        • 아까 생성한 AWS instance에 접속
        • jenkins-slave user 생성
          • sudo -s
          • cd /home
          • mkdir jenkins-slave-1
          • useradd jenkins-slave-1
          • chown jenkins-slave-1:jenkins-slave-1 jenkins-slave-1
          • ll ( 잘 만들어졌는지, group user 설정은 잘 됐는지 확인 )
        • jenkins-slave-1의 ssh key 생성
          • sudo -s
          • su jenkins-slave-1
          • ssh-keygen
        • 이대로 생성하면 private-key를 믿을수 없다고 나옴 ( Server rejected the 1 private key(s) for )
      • cat id_rsa.pub > ~/.ssh/authorized_keys ( SSH 기본 공부하자 ) (c )
  4. slave instance에 JDK 설치
    • sudo -s
    • vim /etc/sudoers -> userid ALL=(ALL:ALL) ALL
    • su userid -> sudo apt-get install default-jdk

GitLab <-> Jenkins 연동하기

처음에 jenkins에서 git checkout을 해보면 다음과 같은 에러 확인 가능


stderr: Host key verification failed.
08:38:14 fatal: Could not read from remote repository.
08:38:14 
08:38:14 Please make sure you have the correct access rights
08:38:14 and the repository exists.


  • GitLab > User Settings > SSH Keys
    • jenkins-slave-1 ( jenkins-slave ) 의 public_key ( .ssh/id_rsa.pub ) 를 입력하면 됨


Jenkins Slave Instance에 Docker 설치 및 권한 부여

09:52:54 + docker build -t 프로젝트 이름 -f ./Dockerfile . 09:52:54 time="2018-07-02T09:52:49Z" level=error msg="failed to dial gRPC: cannot connect to the Docker daemon. Is 'docker daemon' running on this host?: dial unix /var/run/docker.sock: connect: permission denied" 09:52:54 context canceled

  •  sudo usermod -aG docker jenkins-slave-1
  • su jenkins-slave-1 
  • group ( docker가 출력되는 것을 확인 )

Harbor 연동하기 ( Public 주소로 )

10:11:37 Running shell script 10:11:37 + docker push 'HARBOR의 private IP'/project명:76 10:11:37 The push refers to repository ['HARBOR의 private IP'/project명] 10:11:37 Get https://'HARBOR의 private IP'/v2/: dial tcp 'HARBOR의 private IP':443: getsockopt: connection refused

    • Slave -> Harbor 접근할 수 있게 해줘야 함
      • Security Group 추가하기
        • Slave의 Public IP ( 80, 443 ) 추가 


06:15:28 80ec7fd9b2b5: Pushed
06:15:28 5d63025b1db7: Pushed
06:15:28 error parsing HTTP 413 response body: invalid character '<' looking for beginning of value: "<html>\r\n<head><title>413 Request Entity Too Large</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>413 Request Entity Too Large</h1></center>\r\n<hr><center>nginx/1.10.3 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n"
    • NGINX 설정 (  /etc/nginx/nginx.conf ) 용량 설정 수정

Harbor 연동하기 ( Private IP로 )

10:11:37 Get https://'HARBOR의 private IP'/v2/: dial tcp 'HARBOR의 private IP':443: getsockopt: connection refused
  • SSL 등록 가즈아


'DevOps > Jenkins' 카테고리의 다른 글

Jenkins Master-Slave with AWS  (0) 2018.07.02