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. 볼륨 팝업기 생성 링크 복사링크가 클립보드에 복사되었습니다!
볼륨 팝업기를 생성하고 사용하려면 다음을 수행합니다.
- 볼륨 팝업을 위한 CRD(사용자 정의 리소스 정의)를 생성합니다.
- 볼륨 팝업기를 사용하여 미리 채워진 볼륨을 만듭니다.
6.6.2.1. 볼륨 팝업기를 위한 CRD 생성 링크 복사링크가 클립보드에 복사되었습니다!
다음 절차에서는 볼륨 팝업기에 대한 예제 "hello, world" CRD(사용자 정의 리소스 정의)를 생성하는 방법을 설명합니다.
그런 다음 사용자는 이 CRD의 인스턴스를 생성하여 PVC(영구 볼륨 클레임)를 채울 수 있습니다.
사전 요구 사항
- OpenShift Container Platform 웹 콘솔에 액세스합니다.
- cluster-admin 권한으로 클러스터에 액세스합니다.
프로세스
다음 예제 YAML 파일을 사용하여 팝업기 및 관련 리소스의 논리 그룹화 및 작업에 대한 네임스페이스를 생성합니다.
네임스페이스 YAML 파일의 예
apiVersion: v1 kind: Namespace metadata: name: hello다음 예제 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: trueServiceAccount, ClusterRole ,,ClusterRoleBinderingDeployment를 생성하여 컨트롤러를 배포하여 채우기를 구현하는 논리를 실행합니다.다음 예제 YAML 파일을 사용하여 팝업기에 대한 서비스 계정을 생성합니다.
서비스 계정 YAML 파일의 예
apiVersion: v1 kind: ServiceAccount metadata: name: hello-account namespace: hello1 - 1
- 이전에 생성한 네임스페이스를 참조합니다.
다음 예제 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]다음 예제 YAML 파일을 사용하여 클러스터 역할 바인딩을 생성합니다.
클러스터 역할 바인딩 YAML 파일의 예
kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: name: hello-binding1 subjects: - kind: ServiceAccount name: hello-account2 namespace: hello3 roleRef: kind: ClusterRole name: hello-role4 apiGroup: rbac.authorization.k8s.io다음 예제 YAML 파일을 사용하여 팝업기에 대한 배포를 생성합니다.
배포 YAML 파일의 예
kind: Deployment apiVersion: apps/v1 metadata: name: hello-populator namespace: hello1 spec: selector: matchLabels: app: hello template: metadata: labels: app: hello spec: serviceAccount: hello-account2 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
다음 예제 YAML 파일을 사용하여
kind:Hello리소스를 볼륨의 유효한 데이터 소스로 등록할 볼륨 채우기를 생성합니다.볼륨 채우기기 YAML 파일의 예
kind: VolumePopulator apiVersion: populator.storage.k8s.io/v1beta1 metadata: name: hello-populator1 sourceKind: group: hello.example.com kind: Hello- 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은 볼륨 팝업과 함께 제공되지 않습니다. 자체 볼륨 팝업기를 생성해야 합니다.
프로세스
다음 명령을 실행하여
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다음 예제 파일과 유사한 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-hello2 volumeMode: Filesystem
검증
몇 분 후에 다음 명령을 실행하여 PVC가 생성되고
Bound상태에서 있는지 확인합니다.$ oc get pvc example-pvc -n hello1 - 1
- 이 예에서 PVC 이름은
example-pvc입니다.
출력 예
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE example-pvc Bound my-pv 10Mi ReadWriteOnce gp3-csi <unset> 14sPVC에서 읽는 작업을 생성하여 다음 예제 파일을 사용하여 데이터 소스 정보가 적용되었는지 확인합니다.
작업 YAML 파일의 예
apiVersion: batch/v1 kind: Job metadata: name: example-job spec: template: spec: containers: - name: example-container image: busybox:latest command: - cat - /mnt/example.txt1 volumeMounts: - name: vol mountPath: /mnt restartPolicy: Never volumes: - name: vol persistentVolumeClaim: claimName: example-pvc2 다음 명령을 실행하여 작업을 시작합니다.
$ oc run example-job --image=busybox --command -- sleep 30 --restart=OnFailure출력 예
pod/example-job created다음 명령을 실행하여 작업 및 모든 종속 항목이 완료될 때까지 기다립니다.
$ oc wait --for=condition=Complete pod/example-job다음 명령을 실행하여 작업에서 수집한 콘텐츠를 확인합니다.
$ oc logs job/example-job예상 출력
Hello, world!
6.6.2.3. 볼륨 팝업 설치 제거 링크 복사링크가 클립보드에 복사되었습니다!
다음 절차에서는 볼륨 팝업을 제거하는 방법을 설명합니다.
사전 요구 사항
- OpenShift Container Platform 웹 콘솔에 액세스합니다.
- cluster-admin 권한으로 클러스터에 액세스합니다.
프로세스
볼륨 팝업기를 제거하려면 아래 절차에 설치된 모든 오브젝트를 역순으로 삭제합니다.
- 섹션 볼륨 팝업기를 사용하여 미리 채워진 볼륨 생성.
섹션 볼륨 팝업을 위한 CRD 생성.
VolumePopulator인스턴스를 제거해야 합니다.