검색

2.3. 단계 리소스 정의

download PDF

빌드 전략의 모든 단계에 대한 CPU, 메모리, 디스크 사용량과 같은 리소스 정의를 포함할 수 있습니다. 여러 단계가 있는 전략의 경우 다른 단계보다 많은 리소스가 필요할 수 있습니다. 전략 관리자는 각 단계에 적합한 리소스 값을 정의할 수 있습니다.

예를 들어 동일한 단계를 사용하여 전략을 설치할 수 있지만 클러스터에 다른 이름과 단계 리소스를 설치하여 사용자가 더 작거나 큰 리소스 요구 사항을 사용하여 빌드를 생성할 수 있습니다.

2.3.1. 다양한 리소스가 있는 전략

리소스에 대한 다양한 제한으로 동일한 전략의 여러 유형을 정의합니다. 다음 예제에서는 리소스에 정의된 소규모 및 중간 제한과 동일한 buildah 전략을 사용합니다. 이 예제에서는 전략 관리자가 단계 리소스 정의를 보다 효과적으로 제어할 수 있도록 제공합니다.

2.3.1.1. 작은 제한이 있는 Buildah 전략

다음 예와 같이 buildah 전략에 대한 작은 리소스 제한을 사용하여 spec.steps[].resources 필드를 정의합니다.

예: 작은 제한이 있는 buildah 전략

apiVersion: shipwright.io/v1beta1
kind: ClusterBuildStrategy
metadata:
  name: buildah-small
spec:
  steps:
    - name: build-and-push
      image: quay.io/containers/buildah:v1.31.0
      workingDir: $(params.shp-source-root)
      securityContext:
        capabilities:
          add:
          - "SETFCAP"
      command:
        - /bin/bash
      args:
        - -c
        - |
          set -euo pipefail
          # Parse parameters
        # ...
        # That's the separator between the shell script and its args
        - --
        - --context
        - $(params.shp-source-context)
        - --dockerfile
        - $(build.dockerfile)
        - --image
        - $(params.shp-output-image)
        - --build-args
        - $(params.build-args[*])
        - --registries-block
        - $(params.registries-block[*])
        - --registries-insecure
        - $(params.registries-insecure[*])
        - --registries-search
        - $(params.registries-search[*])
      resources:
        limits:
          cpu: 250m
          memory: 65Mi
        requests:
          cpu: 250m
          memory: 65Mi
  parameters:
    - name: build-args
      description: "The values for the args in the Dockerfile. Values must be in the format KEY=VALUE."
      type: array
      defaults: []
    # ...

2.3.1.2. 중간 제한이 있는 Buildah 전략

다음 예와 같이 buildah 전략에 대한 중간 리소스 제한을 사용하여 spec.steps[].resources 필드를 정의합니다.

예: 중간 제한이 있는 buildah 전략

apiVersion: shipwright.io/v1beta1
kind: ClusterBuildStrategy
metadata:
  name: buildah-medium
spec:
  steps:
    - name: build-and-push
      image: quay.io/containers/buildah:v1.31.0
      workingDir: $(params.shp-source-root)
      securityContext:
        capabilities:
          add:
          - "SETFCAP"
      command:
        - /bin/bash
      args:
        - -c
        - |
          set -euo pipefail
          # Parse parameters
        # ...
        # That's the separator between the shell script and its args
        - --
        - --context
        - $(params.shp-source-context)
        - --dockerfile
        - $(build.dockerfile)
        - --image
        - $(params.shp-output-image)
        - --build-args
        - $(params.build-args[*])
        - --registries-block
        - $(params.registries-block[*])
        - --registries-insecure
        - $(params.registries-insecure[*])
        - --registries-search
        - $(params.registries-search[*])
      resources:
        limits:
          cpu: 500m
          memory: 1Gi
        requests:
          cpu: 500m
          memory: 1Gi
  parameters:
    - name: build-args
      description: "The values for the args in the Dockerfile. Values must be in the format KEY=VALUE."
      type: array
      defaults: []
    # ...

전략에 대한 리소스 정의를 구성한 후 다음 예와 같이 Build CR의 전략을 참조해야 합니다.

apiVersion: shipwright.io/v1beta1
kind: Build
metadata:
  name: buildah-medium
spec:
  source:
    git:
      url: https://github.com/shipwright-io/sample-go
    contextDir: docker-build
  strategy:
    name: buildah-medium
    kind: ClusterBuildStrategy
  # ...

2.3.2. Tekton 파이프라인의 리소스 관리

빌드 컨트롤러는 전략 단계를 실행하기 위해 Pod를 예약할 수 있도록 Tekton 파이프라인 컨트롤러에서 작동합니다. 런타임 시 빌드 컨트롤러에서 Tekton TaskRun 리소스를 생성하고 TaskRun 리소스는 특정 네임스페이스에 새 Pod를 생성합니다. 그런 다음 이 Pod는 모든 전략 단계를 순차적으로 실행하여 이미지를 빌드합니다.

Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.