일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- 정보처리기사 실기 기출문제
- 기록으로 실력을 쌓자
- 공부
- mysql 튜닝
- 티스토리챌린지
- Pinpoint
- PETERICA
- 오블완
- 코틀린 코루틴의 정석
- AI
- 정보처리기사 실기
- aws
- Elasticsearch
- CKA
- MySQL
- kotlin querydsl
- AWS EKS
- IntelliJ
- Spring
- kotlin
- Java
- APM
- kotlin spring
- Linux
- Kubernetes
- CloudWatch
- 정보처리기사실기 기출문제
- kotlin coroutine
- CKA 기출문제
- minikube
- Today
- Total
피터의 개발이야기
[Jenkins] Docker 기반 Jenkins quick start examples 본문
ㅁ 개요
Jenkins의 다중 파이프라인 구축 공부를 하는 중에 좋은 예제가 있어서 빠르게 Jenkins 환경 테스트 환경을 구축하기 위해 Docker 기반 예제가 있어서 설치 과정을 정리하였습니다. 참조한 GitHub는 이곳입니다.
ㅁ Git clone
$ git clone https://github.com/ash-sxn/GSoC-2023-docker-based-quickstart.git 128 ↵ 10038 11:55:21
'GSoC-2023-docker-based-quickstart'에 복제합니다...
remote: Enumerating objects: 2463, done.
remote: Counting objects: 100% (1183/1183), done.
remote: Compressing objects: 100% (457/457), done.
remote: Total 2463 (delta 901), reused 812 (delta 716), pack-reused 1280
오브젝트를 받는 중: 100% (2463/2463), 442.15 KiB | 9.41 MiB/s, 완료.
델타를 알아내는 중: 100% (1408/1408), 완료.
## 폴더명을 jenkins-quickstart 변경
$ mv GSoC-2023-docker-based-quickstart jenkins-quickstart
ㅇ Jenkins quick start sample을 다운로드 하였습니다.
ㅇ 폴더명을 jenkins-quickstart 변경하였습니다.
ㅁ Docker Compose 설명
services:
sidekick_service:
# Configuration for the sidekick service
image: ${DOCKERHUB_USERNAME}/jenkinsci-tutorials:sidekick_
stdin_open: true
tty: true
entrypoint: sh -c "/usr/local/bin/keygen.sh /ssh-dir" # Runs the keygen.sh script and specifies the output directory
volumes:
- agent-ssh-dir:/ssh-dir # Mounts the agent-ssh-dir volume to the /ssh-dir path inside the container
healthcheck:
test: [ "CMD-SHELL", "[ -f /ssh-dir/conductor_ok ] || exit 1" ] # Checks if the conductor_ok file exists in the /ssh-dir path
interval: 5s
timeout: 10s
retries: 5
jenkins_controller:
image: ${DOCKERHUB_USERNAME}/jenkinsci-tutorials:simple_controller_
restart: on-failure
ports:
- "8080:8080"
volumes:
- jenkins_home:/var/jenkins_home # Mounts the jenkins_home volume to the /var/jenkins_home path inside the container
- agent-ssh-dir:/ssh-dir # Mounts the agent-ssh-dir volume to the /app path inside the container
depends_on:
sidekick_service:
condition: service_completed_successfully # Depends on the successful completion of the sidekick_service
healthcheck:
test: [ "CMD-SHELL", "[ -f /ssh-dir/conductor_ok ] || exit 1" ] # Checks if the conductor_ok file exists in the /ssh-dir path
interval: 5s
timeout: 10s
retries: 5
default_agent:
image: jenkins/ssh-agent:5.5.0-jdk17
container_name: desktop-jenkins_agent-1
depends_on:
sidekick_service:
condition: service_completed_successfully # Depends on the successful completion of the sidekick_service
jenkins_controller:
condition: service_started
healthcheck:
test: [ "CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1" ] # Checks if the authorized_keys file exists in the /home/jenkins/.ssh path
interval: 5s
timeout: 10s
retries: 5
volumes:
- agent-ssh-dir:/home/jenkins/.ssh:ro # Mounts the agent-ssh-dir volume to the /home/jenkins/.ssh path inside the container as read-only
maven:
image: ${DOCKERHUB_USERNAME}/jenkinsci-tutorials:maven_agent_
container_name: desktop-jenkins_agent-1
profiles:
- maven
depends_on:
sidekick_service:
condition: service_completed_successfully # Depends on the successful completion of the sidekick_service
jenkins_controller:
condition: service_started
healthcheck:
test: [ "CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1" ] # Checks if the authorized_keys file exists in the /home/jenkins/.ssh path
interval: 5s
timeout: 10s
retries: 5
volumes:
- agent-ssh-dir:/home/jenkins/.ssh:ro # Mounts the agent-ssh-dir volume to the /home/jenkins/.ssh path inside the container as read-only
python:
image: ${DOCKERHUB_USERNAME}/jenkinsci-tutorials:python_agent_
container_name: desktop-jenkins_agent-1
profiles:
- python
depends_on:
sidekick_service:
condition: service_completed_successfully # Depends on the successful completion of the sidekick_service
jenkins_controller:
condition: service_started
healthcheck:
test: [ "CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1" ] # Checks if the authorized_keys file exists in the /home/jenkins/.ssh path
interval: 5s
timeout: 10s
retries: 5
volumes:
- agent-ssh-dir:/home/jenkins/.ssh:ro # Mounts the agent-ssh-dir volume to the /home/jenkins/.ssh path inside the container as read-only
node:
image: ${DOCKERHUB_USERNAME}/jenkinsci-tutorials:node_agent_
environment:
- GITPOD_WORKSPACE_URL=${GITPOD_WORKSPACE_URL}
container_name: desktop-jenkins_agent-1
profiles:
- node
depends_on:
sidekick_service:
condition: service_completed_successfully # Depends on the successful completion of the sidekick_service
jenkins_controller:
condition: service_started
ports:
- "3000:3000"
healthcheck:
test: [ "CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1" ] # Checks if the authorized_keys file exists in the /home/jenkins/.ssh path
interval: 5s
timeout: 10s
retries: 5
volumes:
- agent-ssh-dir:/home/jenkins/.ssh:ro # Mounts the agent-ssh-dir volume to the /home/jenkins/.ssh path inside the container as read-only
multi_jenkins_controller:
image: ${DOCKERHUB_USERNAME}/jenkinsci-tutorials:multi_controller_
restart: on-failure
ports:
- "8080:8080"
profiles:
- multi
volumes:
- jenkins_home:/var/jenkins_home # Mounts the jenkins_home volume to the /var/jenkins_home path inside the container
- agent-ssh-dir:/ssh-dir # Mounts the agent-ssh-dir volume to the /app path inside the container
depends_on:
sidekick_service:
condition: service_completed_successfully # Depends on the successful completion of the sidekick_service
healthcheck:
test: [ "CMD-SHELL", "[ -f /ssh-dir/conductor_ok ] || exit 1" ] # Checks if the conductor_ok file exists in the /ssh-dir path
interval: 5s
timeout: 10s
retries: 5
multi:
image: ${DOCKERHUB_USERNAME}/jenkinsci-tutorials:node_agent_
environment:
- GITPOD_WORKSPACE_URL=${GITPOD_WORKSPACE_URL}
container_name: desktop-jenkins_agent-1
profiles:
- multi
depends_on:
sidekick_service:
condition: service_completed_successfully # Depends on the successful completion of the sidekick_service
multi_jenkins_controller:
condition: service_started
ports:
- "3000:3000"
- "5000:5000"
healthcheck:
test: [ "CMD-SHELL", "[ -f /home/jenkins/.ssh/authorized_keys ] || exit 1" ] # Checks if the authorized_keys file exists in the /home/jenkins/.ssh path
interval: 5s
timeout: 10s
retries: 5
volumes:
- agent-ssh-dir:/home/jenkins/.ssh:ro # Mounts the agent-ssh-dir volume to the /home/jenkins/.ssh path inside the container as read-only
volumes:
jenkins_home:
agent-ssh-dir:
name: agent-ssh-dir # Creates a named volume called agent-ssh-dir
ㅇ 위는 Git의 docker compose.yaml의 내용입니다.
ㅇ 예제는 6개의 작업 예제가 있습니다.
- 00_old_one_from_proposal
- 01_simple_controller_plus_agent
- 02_custom_docker_file_connecting_agent_and_controller
- 03_maven ㅅTutorial
- 04: Python Tutorial
- 05: NodeJS Tutorial5_nodejs
- 06: End-to-End Multibranch Pipeline Tutorial
이 예제에는 수동으로 실행하기 위한 README 파일이 포함되어 있습니다.
ㅇ docker compose up -d를 사용하여 다양한 예제를 실행하려면 다음 인수를 명령에 추가하세요.
- maven - 03_maven_tutorial => docker compose up -d maven
- python - 04_python-tutorial => docker compose up -d python
- Node노드 - 05_nodejs => docker compose up -d 노드
- multi - 06_multibranch_pipeline => docker compose up -d multi
ㅇ 인수가 사용되지 않으면(예: docker compose up -d) 최신 기본 예제가 실행됩니다.
ㅁ Docker Compose 실행
$ docker-compose -f docker-compose.yaml up -d
ㅇ Docker Compose 매니페스트를 사용하여 사전 구성된 Jenkins를 실행합니다.
ㅇ 이미지를 pull 받는 모습입니다.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9c11e0bba2d7 jenkins/ssh-agent:5.5.0-jdk17 "setup-sshd" About a minute ago Up 51 seconds (healthy) 22/tcp desktop-jenkins_agent-1
5c3fc4ca59e4 ash191245141/jenkinsci-tutorials:simple_controller_ "/usr/bin/tini -- /u…" About a minute ago Up 54 seconds (healthy) 0.0.0.0:8080->8080/tcp, 50000/tcp jenkins-quickstart-jenkins_controller-1
9b7e85f94830 gcr.io/k8s-minikube/kicbase:v0.0.30 "/usr/local/bin/entr…" 4 months ago Up 5 days 127.0.0.1:61425->22/tcp, 127.0.0.1:61426->2376/tcp, 127.0.0.1:61428->5000/tcp, 127.0.0.1:61429->8443/tcp, 127.0.0.1:61427->32443/tcp minikube-m02
bb2d3e8568ee gcr.io/k8s-minikube/kicbase:v0.0.30 "/usr/local/bin/entr…" 8 months ago Up 5 days 127.0.0.1:61385->22/tcp, 127.0.0.1:61386->2376/tcp, 127.0.0.1:61388->5000/tcp, 127.0.0.1:61389->8443/tcp, 127.0.0.1:61387->32443/tcp minikube
ㅇ 설치된 docker cotainer를 확인하였습니다.
ㅁ Jenkins 접속 테스트
ㅇ 기본 로그인 정보는 admin/admin 입니다.
ㅇ localhost:8080으로 접속하여 기본 demo job이 실행되고 있는 것을 확인하였습니다.
ㅁ 함께 보면 좋은 사이트
ㅇ 참조 GIT 소스 ash-sxn/GSoC-2023-docker-based-quickstart
'DevOps > Jenkins' 카테고리의 다른 글
[jenkins] Jenkins “Pending – Waiting for Next Executor” 해결방법 (0) | 2024.02.21 |
---|---|
[jenkins] jenkins 빌드 후 JAR 파일 복사 (1) | 2023.10.17 |
[Jenkins] jenkins 로컬시간 변경하기 (0) | 2022.10.24 |
[Jenkins] Jenkins 백업 복원 방법 (0) | 2022.10.01 |
[Jenkins] Pipeline Stage View 세팅 (0) | 2022.10.01 |