6.6. 볼륨 팝업기


볼륨 채우기를 사용하면 빈 볼륨을 프로비저닝하는 대신 동적 프로비저닝 중에 데이터를 볼륨에 사전 로드할 수 있습니다.

6.6.1. 볼륨 팝업 개요

OpenShift Container Platform 버전 4.12에서 4.19까지의 PVC(영구 볼륨 클레임) 사양의 dataSource 필드는 볼륨 팝업 기능을 제공합니다. 그러나 볼륨 채우기를 위해 PVC 및 스냅샷만 데이터 소스로 사용하는 것으로 제한됩니다.

OpenShift Container Platform 버전 4.20부터 dataSourceRef 필드가 대신 사용됩니다. dataSourceRef 필드를 사용하여 적절한 CR(사용자 정의 리소스)을 데이터 소스로 사용하여 새 볼륨을 사전 채울 수 있습니다.

참고

dataSource 필드를 사용하는 볼륨 팝업 기능은 향후 버전에서 더 이상 사용되지 않습니다. 이 필드를 사용하여 볼륨 팝업기를 생성한 경우 향후 문제를 방지하기 위해 dataSourceRef 필드를 사용하도록 볼륨 팝업기를 다시 생성하는 것이 좋습니다.

볼륨 채우기는 기본적으로 활성화되어 있으며 OpenShift Container Platform에는 설치된 volume-data-source-validator 컨트롤러가 포함되어 있습니다. 그러나 OpenShift Container Platform에는 볼륨 팝업기가 제공되지 않습니다.

6.6.2. 볼륨 팝업기 생성

볼륨 팝업기를 생성하고 사용하려면 다음을 수행합니다.

  1. 볼륨 팝업을 위한 CRD(사용자 정의 리소스 정의)를 생성합니다.
  2. 볼륨 팝업기를 사용하여 미리 채워진 볼륨을 만듭니다.

6.6.2.1. 볼륨 팝업기를 위한 CRD 생성

다음 절차에서는 볼륨 팝업기에 대한 예제 "hello, world" CRD(사용자 정의 리소스 정의)를 생성하는 방법을 설명합니다.

그런 다음 사용자는 이 CRD의 인스턴스를 생성하여 PVC(영구 볼륨 클레임)를 채울 수 있습니다.

사전 요구 사항

  • OpenShift Container Platform 웹 콘솔에 액세스합니다.
  • cluster-admin 권한으로 클러스터에 액세스합니다.

프로세스

  1. 다음 예제 YAML 파일을 사용하여 팝업기 및 관련 리소스의 논리 그룹화 및 작업에 대한 네임스페이스를 생성합니다.

    네임스페이스 YAML 파일의 예

    apiVersion: v1
    kind: Namespace
    metadata:
      name: hello
    Copy to Clipboard Toggle word wrap

  2. 다음 예제 YAML 파일을 사용하여 데이터 소스에 대한 CRD를 생성합니다.

    CRD YAML 파일의 예

    apiVersion: apiextensions.k8s.io/v1
    kind: CustomResourceDefinition
    metadata:
      name: hellos.hello.example.com
    spec:
      group: hello.example.com
      names:
        kind: Hello
        listKind: HelloList
        plural: hellos
        singular: hello
      scope: Namespaced
      versions:
      - name: v1alpha1
        schema:
          openAPIV3Schema:
            description: Hello is a specification for a Hello resource
            properties:
              apiVersion:
                description: 'APIVersion defines the versioned schema of this representation
                  of an object. Servers should convert recognized schemas to the latest
                  internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
                type: string
              kind:
                description: 'Kind is a string value representing the REST resource this
                  object represents. Servers may infer this from the endpoint the client
                  submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
                type: string
              spec:
                description: HelloSpec is the spec for a Hello resource
                properties:
                  fileContents:
                    type: string
                  fileName:
                    type: string
                required:
                - fileContents
                - fileName
                type: object
            required:
            - spec
            type: object
        served: true
        storage: true
    Copy to Clipboard Toggle word wrap

  3. ServiceAccount, ClusterRole ,ClusterRole Bindering, Deployment 를 생성하여 컨트롤러를 배포하여 채우기를 구현하는 논리를 실행합니다.

    1. 다음 예제 YAML 파일을 사용하여 팝업기에 대한 서비스 계정을 생성합니다.

      서비스 계정 YAML 파일의 예

      apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: hello-account
        namespace: hello 
      1
      Copy to Clipboard Toggle word wrap

      1
      이전에 생성한 네임스페이스를 참조합니다.
    2. 다음 예제 YAML 파일을 사용하여 팝업기에 대한 클러스터 역할을 생성합니다.

      클러스터 역할 YAML 파일의 예

      kind: ClusterRole
      apiVersion: rbac.authorization.k8s.io/v1
      metadata:
        name: hello-role
      rules:
        - apiGroups: [hello.example.com]
          resources: [hellos]
          verbs: [get, list, watch]
      Copy to Clipboard Toggle word wrap

    3. 다음 예제 YAML 파일을 사용하여 클러스터 역할 바인딩을 생성합니다.

      클러스터 역할 바인딩 YAML 파일의 예

      kind: ClusterRoleBinding
      apiVersion: rbac.authorization.k8s.io/v1
      metadata:
        name: hello-binding 
      1
      
      subjects:
        - kind: ServiceAccount
          name: hello-account 
      2
      
          namespace: hello 
      3
      
      roleRef:
        kind: ClusterRole
        name: hello-role 
      4
      
        apiGroup: rbac.authorization.k8s.io
      Copy to Clipboard Toggle word wrap

      1
      역할 바인딩 이름입니다.
      2
      이전에 생성한 서비스 계정의 이름을 참조합니다.
      3
      이전에 생성한 서비스 계정의 네임스페이스 이름을 참조합니다.
      4
      이전에 생성한 클러스터 역할을 참조합니다.
    4. 다음 예제 YAML 파일을 사용하여 팝업기에 대한 배포를 생성합니다.

      배포 YAML 파일의 예

      kind: Deployment
      apiVersion: apps/v1
      metadata:
        name: hello-populator
        namespace: hello 
      1
      
      spec:
        selector:
          matchLabels:
            app: hello
        template:
          metadata:
            labels:
              app: hello
          spec:
            serviceAccount: hello-account 
      2
      
            containers:
              - name: hello
                image: registry.k8s.io/sig-storage/hello-populator:v1.0.1
                imagePullPolicy: IfNotPresent
                args:
                  - --mode=controller
                  - --image-name=registry.k8s.io/sig-storage/hello-populator:v1.0.1
                  - --http-endpoint=:8080
                ports:
                  - containerPort: 8080
                    name: http-endpoint
                    protocol: TCP
      Copy to Clipboard Toggle word wrap

      1
      이전에 생성한 네임스페이스를 참조합니다.
      2
      이전에 생성한 서비스 계정을 참조합니다.
  4. 다음 예제 YAML 파일을 사용하여 kind:Hello 리소스를 볼륨의 유효한 데이터 소스로 등록할 볼륨 채우기를 생성합니다.

    볼륨 채우기기 YAML 파일의 예

    kind: VolumePopulator
    apiVersion: populator.storage.k8s.io/v1beta1
    metadata:
      name: hello-populator 
    1
    
    sourceKind:
      group: hello.example.com
      kind: Hello
    Copy to Clipboard Toggle word wrap

    1
    볼륨 팝업 이름.

    등록되지 않은 팝업을 사용하는 PVC는 "이 PVC의 데이터 소스가 알 수 없음(등록되지 않은) 팝업기를 사용하므로 PVC가 프로비저닝되지 않을 수 있음을 나타내는 등록된 VolumePopulator와 일치하지 않습니다.

다음 단계

  • 이제 이 CRD의 CR 인스턴스를 생성하여 PVC를 채울 수 있습니다.

볼륨 채우기기를 사용하여 볼륨을 미리 채우는 방법에 대한 자세한 내용은 볼륨 채우기가 포함된 사전 예약된 볼륨 생성을 참조하십시오.

6.6.2.2. 볼륨 팝업기를 사용하여 미리 채워진 볼륨 생성

다음 절차에서는 이전에 생성한 hellos.hello.example.com CRD(Custom Resource Definition) 예제를 사용하여 미리 채워진 PVC(영구 볼륨 클레임)를 생성하는 방법을 설명합니다.

이 예제에서는 실제 데이터 소스를 사용하는 대신 볼륨의 루트 디렉터리에 "Hello, world!" 문자열이 포함된 "example.txt"라는 파일을 생성합니다. 실제 구현을 위해서는 자체 볼륨 팝업기를 생성해야 합니다.

사전 요구 사항

  • 실행 중인 OpenShift Container Platform 클러스터에 로그인되어 있습니다.
  • 볼륨 팝업을 위한 기존 CRD(사용자 정의 리소스 정의)가 있습니다.
  • OpenShift Container Platform은 볼륨 팝업과 함께 제공되지 않습니다. 자체 볼륨 팝업기를 생성해야 합니다.

프로세스

  1. 다음 명령을 실행하여 fileContents 매개변수로 전달된 텍스트 " Hello, World!"를 사용하여 Hello CRD의 CR(사용자 정의 리소스) 인스턴스를 생성합니다.

    $ oc apply -f  - <<EOF
    apiVersion: hello.example.com/v1alpha1
    kind: Hello
    metadata:
      name: example-hello
    spec:
      fileName: example.txt
      fileContents: Hello, world!
    EOF
    Copy to Clipboard Toggle word wrap
  2. 다음 예제 파일과 유사한 Hello CR을 참조하는 PVC를 생성합니다.

    PVC YAML 파일의 예

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: example-pvc
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 10Mi
      dataSourceRef: 
    1
    
        apiGroup: hello.example.com
        kind: Hello
        name: example-hello 
    2
    
      volumeMode: Filesystem
    Copy to Clipboard Toggle word wrap

    1
    dataSourceRef 필드는 PVC의 데이터 소스를 지정합니다.
    2
    데이터 소스로 사용하는 CR의 이름입니다. 예에서는 'example-hello'입니다.

검증

  1. 몇 분 후에 다음 명령을 실행하여 PVC가 생성되고 Bound 상태에서 있는지 확인합니다.

    $ oc get pvc example-pvc -n hello 
    1
    Copy to Clipboard Toggle word wrap
    1
    이 예에서 PVC 이름은 example-pvc 입니다.

    출력 예

    NAME          STATUS    VOLUME        CAPACITY   ACCESS MODES   STORAGECLASS   VOLUMEATTRIBUTESCLASS   AGE
    example-pvc   Bound     my-pv         10Mi       ReadWriteOnce  gp3-csi        <unset>                 14s
    Copy to Clipboard Toggle word wrap

  2. PVC에서 읽는 작업을 생성하여 다음 예제 파일을 사용하여 데이터 소스 정보가 적용되었는지 확인합니다.

    작업 YAML 파일의 예

    apiVersion: batch/v1
    kind: Job
    metadata:
      name: example-job
    spec:
      template:
        spec:
          containers:
            - name: example-container
              image: busybox:latest
              command:
                - cat
                - /mnt/example.txt 
    1
    
              volumeMounts:
                - name: vol
                  mountPath: /mnt
          restartPolicy: Never
          volumes:
            - name: vol
              persistentVolumeClaim:
                claimName: example-pvc 
    2
    Copy to Clipboard Toggle word wrap

    1
    "Hello, world!" 텍스트가 포함된 파일의 위치와 이름입니다.
    2
    2단계에서 생성한 PVC의 이름입니다. 예에서는 example-pvc.
  3. 다음 명령을 실행하여 작업을 시작합니다.

    $ oc run example-job --image=busybox --command -- sleep 30 --restart=OnFailure
    Copy to Clipboard Toggle word wrap

    출력 예

    pod/example-job created
    Copy to Clipboard Toggle word wrap

  4. 다음 명령을 실행하여 작업 및 모든 종속 항목이 완료될 때까지 기다립니다.

    $ oc wait --for=condition=Complete pod/example-job
    Copy to Clipboard Toggle word wrap
  5. 다음 명령을 실행하여 작업에서 수집한 콘텐츠를 확인합니다.

    $ oc logs job/example-job
    Copy to Clipboard Toggle word wrap

    예상 출력

    Hello, world!
    Copy to Clipboard Toggle word wrap

6.6.2.3. 볼륨 팝업 설치 제거

다음 절차에서는 볼륨 팝업을 제거하는 방법을 설명합니다.

사전 요구 사항

  • OpenShift Container Platform 웹 콘솔에 액세스합니다.
  • cluster-admin 권한으로 클러스터에 액세스합니다.

프로세스

볼륨 팝업기를 제거하려면 아래 절차에 설치된 모든 오브젝트를 역순으로 삭제합니다.

  1. 섹션 볼륨 팝업기를 사용하여 미리 채워진 볼륨 생성.
  2. 섹션 볼륨 팝업을 위한 CRD 생성.

    VolumePopulator 인스턴스를 제거해야 합니다.

맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

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

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

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

Red Hat 소개

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

Theme

© 2025 Red Hat