다음을 통해 공유


자습서: 로컬 공유 에지 볼륨 구성(미리 보기)

이 자습서에서는 로컬 공유 에지 볼륨을 구성하는 방법에 대해 알아봅니다. 이 볼륨 형식은 Kubernetes 클러스터에 로컬로 읽기-쓰기-다중 스토리지를 제공합니다. 이 공유 스토리지 유형은 클라우드 인프라와 독립적으로 유지되므로 클라우드 대상에 적합하지 않은 스크래치 공간, 임시 스토리지 및 로컬 영구 데이터에 적합합니다. 데이터가 적극적으로 작업, 변경 또는 처리되는 엣지 환경에서도 좋은 저장 장소입니다.

이 자습서에서는 다음 작업을 다룹니다.

  • 로컬 공유 에지 볼륨 PVC 만들기
  • 예제 배포 만들기
  • Pod에 연동하다
  • 샘플 파일 작성

필수 조건

로컬 공유 에지 볼륨 PVC 만들기

이 섹션에서는 로컬 공유 볼륨에 사용할 영구 볼륨 클레임(PVC)을 만듭니다. 이 볼륨에 프로비전할 공간을 지정합니다.

다음 내용이 포함된 localSharedPVC.yaml(이)라는 파일을 만듭니다. 영구 볼륨 클레임의 이름으로 metadata.name 값을 수정합니다. 그런 다음 8번째 줄에서 의도한 사용 대상 Pod와 일치하는 네임스페이스를 지정합니다. 값은 metadata.name 다음 단계의 deploymentExample.yaml 마지막 줄에서 참조됩니다. 매개 변수는 spec.resources.requests.storage 영구 볼륨의 크기를 결정합니다. 이 예제에서는 2GB이지만 필요에 맞게 수정할 수 있습니다.

비고

소문자와 대시만 사용합니다. 자세한 내용은 Kubernetes 개체 명명 설명서를 참조하세요.

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  ### Create a name for your PVC ###
  name: <create-a-pvc-name-here>
  ### Use a namespace that matches your intended consuming pod, or "default" ###
  namespace: <intended-consuming-pod-or-default-here>
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 2Gi
  storageClassName: unbacked-sc

그런 다음, 이 명령을 실행하여 YAML 파일을 적용하고 PVC를 만듭니다.

kubectl apply -f "localSharedPVC.yaml"

예제 배포를 만들거나 사용자 고유의 배포 사용

배포할 애플리케이션이 이미 있는 경우 여기에서 사용할 수 있습니다. 간단히 시작하고 시작하기 위해 여기에 예제 배포가 포함됩니다. 예제 구성을 사용하여 배포를 만들려면 다음 내용이 포함된 deploymentExample.yaml 이라는 파일을 만듭니다. containers.namevolumes.persistentVolumeClaim.claimName의 값을 추가합니다. spec.replicas 매개변수는 생성할 레플리카 팟의 수를 결정합니다. 이 예제에서는 2이지만 필요에 맞게 수정할 수 있습니다.

비고

소문자와 대시만 사용합니다. 자세한 내용은 Kubernetes 개체 명명 설명서를 참조하세요.

apiVersion: apps/v1 
kind: Deployment 
metadata: 
  name: localsharededgevol-deployment ### This will need to be unique for every volume you choose to create 

spec: 
  replicas: 2 
  selector: 
    matchLabels: 
      name: wyvern-testclientdeployment 
  template: 
    metadata: 
      name: wyvern-testclientdeployment 
      labels: 
        name: wyvern-testclientdeployment 
    spec: 
      affinity: 
        podAntiAffinity: 
          requiredDuringSchedulingIgnoredDuringExecution: 
            - labelSelector: 
                matchExpressions: 
                  - key: app 
                    operator: In 
                    values: 
                      - wyvern-testclientdeployment 
              topologyKey: kubernetes.io/hostname 
      containers: 

        ### Specify the container in which to launch the busy box. ### 
        - name: <create-a-container-name-here> 
          image: 'mcr.microsoft.com/mirror/docker/library/busybox:1.35' 
          command: 
            - "/bin/sh" 
            - "-c" 
            - "dd if=/dev/urandom of=/data/acsalocalsharedtestfile count=16 bs=1M && while true; do ls /data &>/dev/null || break; sleep 1; done" 
          volumeMounts: 

            ### This name must match the following volumes::name attribute ### 
            - name: wyvern-volume 

              ### This mountPath is where the PVC will be attached to the pod's filesystem ### 
              mountPath: /data 
      volumes: 

        ### User-defined name that is used to link the volumeMounts. This name must match volumeMounts::name as previously specified. ### 
        - name: wyvern-volume 
          persistentVolumeClaim: 

            ### This claimName must refer to your PVC metadata::name from lsevPVC.yaml. 
            claimName: <your-pvc-metadata-name-from-line-5-of-pvc-yaml>

그런 다음, 이 명령을 실행하여 YAML 파일을 적용하고 배포를 만듭니다.

kubectl apply -f "deploymentExample.yaml"

Pod에 연동하다

kubectl get pods을(를) 실행하여 파드의 이름을 찾습니다. 다음 단계에서 필요하므로 이 이름을 복사합니다.

비고

deploymentExample.yaml에서 2로 지정되었으므로 를 사용하여 두 개의 포드가 나타납니다. 다음 단계에서는 Pod 이름 중 하나를 사용할 수 있습니다.

다음 명령을 실행하고 POD_NAME_HERE을(를) 이전 단계에서 복사한 값으로 바꿉니다.

kubectl exec -it POD_NAME_HERE -- sh 

/data 지정된 대로 디렉터리를 탑재 경로로 변경합니다.

예제 파일 작성

이제 Pod 및 탑재 경로에 연결되었으므로 여기서 작성하는 모든 파일이 볼륨에 표시됩니다.

예를 들어, file1.txt라는 이름의 파일을 만들고 echo "Hello World" > file1.txt를 사용하여 이 파일에 씁니다.

이제 작성한 파일이 디렉터리에 있는 것을 볼 수 있습니다.

다음 단계

이러한 단계를 완료한 후 Azure Monitor 및 Kubernetes 모니터링을 사용하여 배포 모니터링을 시작하거나 Prometheus 및 Grafana를 사용하여 타사 모니터링을 시작합니다.