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를 채울 수 있습니다.
볼륨 채우기기를 사용하여 볼륨을 미리 채우는 방법에 대한 자세한 내용은 볼륨 채우기가 포함된 사전 예약된 볼륨 생성을 참조하십시오.