빌드 정보
빌드 소개
초록
1장. 빌드 개요
빌드는 shipwright 프로젝트를 기반으로 하는 확장 가능한 빌드 프레임워크로, OpenShift Container Platform 클러스터에서 컨테이너 이미지를 빌드하는 데 사용할 수 있습니다. S2I(Source-to-Image) 및 Buildah
와 같은 이미지 빌드 툴을 사용하여 소스 코드 및 Dockerfile에서 컨테이너 이미지를 빌드할 수 있습니다. 빌드 리소스를 생성 및 적용하고, 빌드 실행 로그를 확인하며, OpenShift Container Platform 네임스페이스에서 빌드를 관리할 수 있습니다.
빌드의 주요 기능
- 소스 코드 및 Dockerfile에서 컨테이너 이미지를 빌드하는 표준 Kubernetes 네이티브 API 제공
-
S2I(Source-to-Image) 및
Buildah
빌드 전략 지원 - 사용자 정의 빌드 전략을 통해 확장 가능
- 로컬 디렉터리의 소스 코드에서 빌드 실행 가능
- Shipwright CLI를 사용하여 빌드 생성, 로그 확인 및 클러스터 내 빌드 관리 가능
- OpenShift Container Platform 웹 콘솔의 개발자 보기와 통합된 사용자 경험 제공
빌드는 다음 사용자 정의 리소스(CR)로 구성됩니다.
-
Build
-
BuildStrategy
및ClusterBuildStrategy
-
BuildRun
1.1. 빌드 리소스
Build
리소스는 애플리케이션의 소스 코드와 애플리케이션 이미지를 내보낼 위치를 정의합니다. 다음 예제에서는 Git 소스, 빌드 전략 및 출력 이미지로 구성된 간단한 빌드를 보여줍니다.
apiVersion: shipwright.io/v1beta1 kind: Build metadata: name: buildah-golang-build spec: source: git: url: https://github.com/username/taxi strategy: name: buildah kind: ClusterBuildStrategy output: image: registry.mycompany.com/my-org/taxi-app:latest
apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
name: buildah-golang-build
spec:
source:
git:
url: https://github.com/username/taxi
strategy:
name: buildah
kind: ClusterBuildStrategy
output:
image: registry.mycompany.com/my-org/taxi-app:latest
Build
리소스를 확장하여 이미지를 프라이빗 레지스트리로 내보내거나 Dockerfile을 사용할 수도 있습니다.
1.2. BuildStrategy 및 ClusterBuildStrategy 리소스
BuildStrategy
및 ClusterBuildStrategy
리소스는 애플리케이션을 어셈블하기 위한 일련의 단계를 정의합니다. 네임스페이스 및 클러스터 내의 Cluster
리소스 내에서 BuildStrategy 리소스를 사용할 수 있습니다.
BuildStrategy
BuildStrategy
또는 ClusterBuildStrategy
리소스의 사양은 steps
오브젝트로 구성됩니다. 다음 예제에서는 buildah
클러스터 빌드 전략의 사양을 보여줍니다.
apiVersion: shipwright.io/v1beta1 kind: ClusterBuildStrategy metadata: name: buildah spec: steps: - name: build-and-push image: quay.io/containers/buildah:v1.31.0 workingDir: $(params.shp-source-root) command: - /bin/bash # ... # ...
apiVersion: shipwright.io/v1beta1
kind: ClusterBuildStrategy
metadata:
name: buildah
spec:
steps:
- name: build-and-push
image: quay.io/containers/buildah:v1.31.0
workingDir: $(params.shp-source-root)
command:
- /bin/bash
# ...
# ...
1.3. buildrun 리소스
BuildRun
리소스는 클러스터 작업 또는 Tekton 작업 실행과 유사하게 클러스터에서 빌드를 호출합니다. BuildRun
리소스는 클러스터의 워크로드를 표시하여 실행 중인 Pod를 생성합니다. BuildRun
은 실행 중인 빌드 인스턴스입니다. 클러스터에서 특정 매개변수를 사용하여 실행할 빌드를 인스턴스화합니다.
BuildRun
리소스는 다음 요소를 정의하는 데 도움이 됩니다.
-
빌드 상태를 모니터링할 고유한
BuildRun
이름 -
빌드 중 사용할 참조된
Build
인스턴스 - 빌드의 모든 보안을 호스팅하는 서비스 계정
각 BuildRun
리소스는 네임스페이스 내에서 사용할 수 있습니다.
1.4. 빌드 컨트롤러
빌드 컨트롤러는 Build
리소스의 업데이트를 모니터링하고 다음 작업을 수행합니다.
-
참조된
Strategy
오브젝트가Build
리소스에 있는지 확인합니다. -
Build
CR에서 지정된 매개변수가 참조된 빌드 전략에 있는지 확인합니다. 매개변수 이름이 예약된 이름과 충돌하는지도 확인합니다. -
Build
리소스에 컨테이너 레지스트리 출력 시크릿이 있는지 확인합니다. -
참조된
spec.source.git.url
끝점 URL이Build
리소스에 있는지 확인합니다.
빌드 실행 컨트롤러는 Build
또는 TaskRun
리소스의 업데이트를 모니터링하고 다음 작업을 수행합니다.
-
기존
TaskRun
리소스를 검색하고 상위BuildRun
리소스 상태를 업데이트합니다. -
지정된 서비스 계정을 검색하고
Build
리소스의 출력 보안과 함께 설정합니다. -
TaskRun
리소스가 없는 경우 컨트롤러는 새 TektonTaskRun
리소스를 생성하고TaskRun
리소스에 대한 참조를 설정합니다. -
TaskRun
리소스의 후속 업데이트의 경우 컨트롤러는 상위BuildRun
리소스를 업데이트합니다.
1.4.1. 빌드 검증
잘못된 종속성 또는 구성 설정으로 인해 실패하는 BuildRun
리소스를 트리거하지 않으려면 빌드 컨트롤러에서 미리 유효성을 검사합니다. 모든 검증이 성공하면 Succeeded
라는 status.reason
필드를 볼 수 있습니다. 그러나 검증이 실패하는 경우 status.reason
및 status.message
필드를 확인하여 근본 원인을 파악해야 합니다.
status.reason 필드 | 설명 |
---|---|
| 네임스페이스 수준에서 참조된 전략이 존재하지 않습니다. |
| 클러스터 수준에서 참조된 전략이 존재하지 않습니다. |
|
|
| Git에 인증하는 데 사용되는 시크릿은 존재하지 않습니다. |
| 컨테이너 레지스트리에 인증하는 데 사용되는 시크릿은 존재하지 않습니다. |
| 컨테이너 레지스트리에 인증하는 데 사용되는 시크릿은 존재하지 않습니다. |
| 인증에 사용되는 여러 보안이 누락되어 있습니다. |
|
하나 이상의 정의된 |
|
매개변수는 참조된 전략에 정의되지 않습니다. 해당 매개변수를 전략의 |
|
정의된 |
|
|
| 사용자 제공 환경 변수의 이름이 비어 있음을 나타냅니다. |
| 사용자 제공 환경 변수의 값이 비어 있음을 나타냅니다. |
1.5. 추가 리소스
2장. 빌드 전략
OpenShift Container Platform 클러스터에서 선별된 빌드 전략 세트 또는 클러스터 빌드 전략을 사용할 수 있습니다. Red Hat OpenShift Operator 빌드는 사용할 이러한 전략을 자동으로 설치합니다. 이 자동화된 전략 설치는 신속하게 빌드를 시작하는 데 도움이 됩니다.
빌드에서는 다음 클러스터 빌드 전략을 지원합니다.
-
Buildah
: 모든 플랫폼에서 지원 -
S2I(Source-to-Image
) : linux/amd64 플랫폼에서 지원
buildpacks
빌드 전략은 현재 개발자 프리뷰 에 있습니다. 자세한 내용은 buildpacks 예제 를 참조하십시오.
2.1. Buildah
buildah
클러스터 빌드 전략에서는 Dockerfile을 사용하여 컨테이너 이미지를 빌드하고 대상 레지스트리로 푸시합니다. Build
CR의 spec.paramValues
필드에 Dockerfile을 지정해야 합니다.
Red Hat OpenShift Operator 빌드가 클러스터 수준에서 buildah
전략을 설치하기 때문에 클러스터 내의 다른 네임스페이스에서 buildah
전략을 공유할 수 있습니다.
buildah
전략에 대해 다음 매개변수를 구성할 수 있습니다.
이름 | 유형 | 설명 | 기본 |
---|---|---|---|
| array | 빌드 중 사용되는 Dockerfile에 필요한 인수의 키-값 쌍 | [] |
| array | 차단해야 하는 레지스트리 목록 | [] |
| array | FQDN(정규화된 도메인 이름)이 있는 비보안 레지스트리 목록 | [] |
| array | 짧은 이름 이미지를 검색할 레지스트리 목록 | ["registry.redhat.io", "quay.io"] |
| string | 빌드 중 사용되는 Dockerfile의 경로 | "Dockerfile" |
| string |
| "vfs" |
자세한 내용은 추가 리소스 섹션의 빌드 전략 구성 을 참조하십시오.
2.2. S2I(Source-to-Image)
이 빌드 전략은 S2I(Source -to-Image
) 및 buildah
로 구성됩니다. 이 전략을 사용하여 컨테이너 파일을 생성하고 빌더 이미지로 빌드할 애플리케이션을 준비할 수 있습니다. Build
CR의 spec.paramValues
필드에 빌더 이미지를 지정해야 합니다.
Red Hat OpenShift Operator 빌드가 클러스터 수준에서 S2I(Source -to-Image
) 전략을 설치하기 때문에 클러스터 내의 여러 네임스페이스에서 S2I(Source -to-Image
) 전략을 공유할 수 있습니다.
S2I(Source -to-Image
) 전략에 대해 다음 매개변수를 구성할 수 있습니다.
이름 | 유형 | 설명 | 기본 |
---|---|---|---|
| array | 차단해야 하는 레지스트리 목록 | [] |
| array | FQDN이 있는 비보안 레지스트리 목록 | [] |
| array | 짧은 이름 이미지를 검색할 레지스트리 목록 | ["registry.redhat.io", "quay.io"] |
| string | 빌드 중 사용되는 빌더 이미지의 위치 | 해당 없음 |
| string |
오버레이 또는 vfs와 같이 S | "vfs" |
2.3. 추가 리소스
Legal Notice
Copyright © 2024 Red Hat, Inc.
OpenShift documentation is licensed under the Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0).
Modified versions must remove all Red Hat trademarks.
Portions adapted from https://github.com/kubernetes-incubator/service-catalog/ with modifications by Red Hat.
Red Hat, Red Hat Enterprise Linux, the Red Hat logo, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation’s permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.