Azure Kubernetes Service에 대한 Azure NetApp Files 이중 프로토콜 볼륨 프로비전
이 문서의 내용
Azure Kubernetes Service용 Azure NetApp Files를 구성 한 후 Azure Kubernetes Service에 대한 Azure NetApp Files 볼륨을 프로비전할 수 있습니다.
Azure NetApp Files에서는 NFS (NFSv3 또는 NFSv4.1), SMB 및 이중 프로토콜(NFSv3과 SMB 또는 NFSv4.1과 SMB)을 사용하여 볼륨을 만들 수 있습니다.
이 문서에서는 NFS 또는 SMB를 사용하여 이중 프로토콜 액세스를 위해 볼륨을 정적으로 프로비전하는 방법을 보여 줍니다.
시작하기 전에
Azure Kubernetes Service에서 이중 프로토콜 볼륨 프로비전
이 섹션에서는 Azure NetApp Files 이중 프로토콜 볼륨을 Kubernetes에 정적으로 노출하는 방법을 설명합니다. SMB 및 NFS 프로토콜 모두에 대한 지침이 제공됩니다. SMB를 통해 Windows 작업자 노드에, NFS를 통해 Linux 작업자 노드에 동일한 볼륨을 노출할 수 있습니다.
NFS에 대한 영구 볼륨 만들기
나중에 사용할 변수를 정의합니다. myresourcegroup , myaccountname , mypool1 , myvolname 을 이중 프로토콜 볼륨의 적절한 값으로 바꿉니다.
RESOURCE_GROUP="myresourcegroup"
ANF_ACCOUNT_NAME="myaccountname"
POOL_NAME="mypool1"
VOLUME_NAME="myvolname"
명령을 사용하여 볼륨의 세부 정보를 나열합니다 az netappfiles volume show
.
az netappfiles volume show \
--resource-group $RESOURCE_GROUP \
--account-name $ANF_ACCOUNT_NAME \
--pool-name $POOL_NAME \
--volume-name $VOLUME_NAME -o JSON
다음 출력은 실제 값으로 실행된 위 명령의 예입니다.
{
...
"creationToken": "myfilepath2",
...
"mountTargets": [
{
...
"ipAddress": "10.0.0.4",
...
}
],
...
}
파일 pv-nfs.yaml
을 만들고 다음 YAML에 복사합니다. 서버가 이전 단계의 출력 IP 주소와 일치하고 경로가 위 creationToken
의 출력과 일치하는지 확인합니다. 용량은 2단계의 볼륨 크기와도 일치해야 합니다.
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-nfs
spec:
capacity:
storage: 100Gi
accessModes:
- ReadWriteMany
mountOptions:
- vers=3
nfs:
server: 10.0.0.4
path: /myfilepath2
kubectl apply
명령을 사용하여 영구 볼륨을 만듭니다.
kubectl apply -f pv-nfs.yaml
kubectl describe
명령을 사용하여 영구 볼륨의 상태가 Available 인지 확인합니다.
kubectl describe pv pv-nfs
NFS에 대한 영구 볼륨 클레임 만들기
파일 pvc-nfs.yaml
을 만들고 다음 YAML에 복사합니다. 이 매니페스트는 사용자가 만든 PV와 일치하는 100Gi 스토리지 및 ReadWriteMany
액세스 모드에 대해 pvc-nfs
라는 PVC를 만들고 사용자가 만든 PV와 일치하는지 확인합니다.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-nfs
spec:
accessModes:
- ReadWriteMany
storageClassName: ""
resources:
requests:
storage: 100Gi
kubectl apply
명령을 사용하여 영구 볼륨 클레임을 만듭니다.
kubectl apply -f pvc-nfs.yaml
명령을 사용하여 영구 볼륨 클레임의 상태가 Boundkubectl describe
인지 확인합니다.
kubectl describe pvc pvc-nfs
NFS를 사용하여 Pod 내에 탑재
파일 nginx-nfs.yaml
을 만들고 다음 YAML에 복사합니다. 이 매니페스트는 영구 볼륨 클레임을 사용하는 nginx
Pod를 정의합니다.
kind: Pod
apiVersion: v1
metadata:
name: nginx-nfs
spec:
containers:
- image: mcr.microsoft.com/oss/nginx/nginx:1.15.5-alpine
name: nginx-nfs
command:
- "/bin/sh"
- "-c"
- while true; do echo $(date) >> /mnt/azure/outfile; sleep 1; done
volumeMounts:
- name: disk01
mountPath: /mnt/azure
volumes:
- name: disk01
persistentVolumeClaim:
claimName: pvc-nfs
kubectl-apply 명령을 사용하여 kubectl apply
Pod를 만듭니다.
kubectl apply -f nginx-nfs.yaml
kubectl apply
명령을 사용하여 Pod가 Running 인지 확인합니다.
kubectl describe pod nginx-nfs
Pod에 연결하기 위해 kubectl exec
를 사용하여 볼륨이 Pod에 탑재되었는지 확인한 다음, df -h
를 사용하여 볼륨이 탑재되었는지 확인합니다.
kubectl exec -it nginx-nfs -- sh
/ # df -h
Filesystem Size Used Avail Use% Mounted on
...
10.0.0.4:/myfilepath2 100T 384K 100T 1% /mnt/azure
...
도메인 자격 증명을 사용하여 비밀 만들기
kubectl create secret
명령을 사용하여 AD 서버에 액세스하기 위해 AKS 클러스터에 비밀을 만듭니다. 이 비밀은 Kubernetes 영구 볼륨에서 Azure NetApp Files SMB 볼륨에 액세스하는 데 사용됩니다. 다음 명령을 사용하여 비밀을 만들고 사용자 이름, PASSWORD
암호 및 DOMAIN_NAME
Active Directory do기본 이름으로 바꿉 USERNAME
니다.
kubectl create secret generic smbcreds --from-literal=username=USERNAME --from-literal=password="PASSWORD" --from-literal=domain='DOMAIN_NAME'
비밀이 만들어졌는지 확인하려면 명령을 실행합니다 kubectl get
.
kubectl get secret
NAME TYPE DATA AGE
smbcreds Opaque 2 20h
SMB CSI 드라이버 설치
Kubernetes SMB PersistentVolume
을 만들려면 CSI(Container Storage Interface) 드라이버를 설치해야 합니다.
helm을 사용하여 클러스터에 SMB CSI 드라이버를 설치합니다. windows.enabled
옵션을 true
로 설정해야 합니다.
helm repo add csi-driver-smb https://raw.githubusercontent.com/kubernetes-csi/csi-driver-smb/master/charts
helm install csi-driver-smb csi-driver-smb/csi-driver-smb --namespace kube-system --version v1.10.0 –-set windows.enabled=true
SMB CSI 드라이버를 설치하는 다른 방법은 Kubernetes 클러스터에 SMB CSI 드라이버 마스터 버전 설치 를 참조하세요.
컨트롤러 Pod가 csi-smb
실행 중이고 각 작업자 노드에 다음 명령을 사용하여 실행되는 Pod가 kubectl get pods
있는지 확인합니다.
kubectl get pods -n kube-system | grep csi-smb
csi-smb-controller-68df7b4758-xf2m9 3/3 Running 0 3m46s
csi-smb-node-s6clj 3/3 Running 0 3m47s
csi-smb-node-win-tfxvk 3/3 Running 0 3m47s
SMB에 대한 영구 볼륨 만들기
나중에 사용할 변수를 정의합니다. myresourcegroup , myaccountname , mypool1 , myvolname 을 이중 프로토콜 볼륨의 적절한 값으로 바꿉니다.
RESOURCE_GROUP="myresourcegroup"
ANF_ACCOUNT_NAME="myaccountname"
POOL_NAME="mypool1"
VOLUME_NAME="myvolname"
az netappfiles volume show
명령을 사용하여 볼륨의 세부 정보를 나열합니다.
az netappfiles volume show \
--resource-group $RESOURCE_GROUP \
--account-name $ANF_ACCOUNT_NAME \
--pool-name $POOL_NAME \
--volume-name "$VOLUME_NAME -o JSON
다음 출력은 실제 값으로 실행된 위 명령의 예입니다.
{
...
"creationToken": "myvolname",
...
"mountTargets": [
{
...
"
"smbServerFqdn": "ANF-1be3.contoso.com",
...
}
],
...
}
파일 pv-smb.yaml
을 만들고 다음 YAML에 복사합니다. 필요한 경우 myvolname
을 이전 단계의 creationToken
으로, ANF-1be3.contoso.com\myvolname
을 smbServerFqdn
값으로 바꿉니다. 이전 단계에서 만든 네임스페이스와 함께 AD 자격 증명 비밀을 포함해야 합니다.
apiVersion: v1
kind: PersistentVolume
metadata:
name: anf-pv-smb
spec:
storageClassName: ""
capacity:
storage: 100Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
mountOptions:
- dir_mode=0777
- file_mode=0777
- vers=3.0
csi:
driver: smb.csi.k8s.io
readOnly: false
volumeHandle: myvolname # make sure it's a unique name in the cluster
volumeAttributes:
source: \\ANF-1be3.contoso.com\myvolname
nodeStageSecretRef:
name: smbcreds
namespace: default
kubectl apply
명령을 사용하여 영구 볼륨을 만듭니다.
kubectl apply -f pv-smb.yaml
kubectl describe 명령을 사용하여 영구 볼륨의 상태를 kubectl describe
할 수 있는지 확인합니다.
kubectl describe pv anf-pv-smb
SMB에 대한 영구 볼륨 클레임 만들기
파일 이름 pvc-smb.yaml
을 만들고 다음 YAML에 복사합니다.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: anf-pvc-smb
spec:
accessModes:
- ReadWriteMany
volumeName: anf-pv-smb
storageClassName: ""
resources:
requests:
storage: 100Gi
kubectl apply
명령을 사용하여 영구 볼륨 클레임을 만듭니다.
kubectl apply -f pvc-smb.yaml
kubectl describe
명령을 사용하여 영구 볼륨 클레임의 상태가 Bound 인지 확인합니다.
kubectl describe pvc anf-pvc-smb
SMB를 사용하여 Pod 내에 탑재
파일 iis-smb.yaml
을 만들고 다음 YAML에 복사합니다. 이 파일은 경로 /inetpub/wwwroot
에 볼륨을 탑재하는 인터넷 정보 서비스 Pod를 만드는 데 사용됩니다.
apiVersion: v1
kind: Pod
metadata:
name: iis-pod
labels:
app: web
spec:
nodeSelector:
"kubernetes.io/os": windows
volumes:
- name: smb
persistentVolumeClaim:
claimName: anf-pvc-smb
containers:
- name: web
image: mcr.microsoft.com/windows/servercore/iis:windowsservercore
resources:
limits:
cpu: 1
memory: 800M
ports:
- containerPort: 80
volumeMounts:
- name: smb
mountPath: "/inetpub/wwwroot"
readOnly: false
kubectl apply 명령을 사용하여 Pod를 만듭니다.
kubectl apply -f iis-smb.yaml
kubectl describe
명령을 사용하여 Pod가 Running 이고 /inetpub/wwwroot
가 SMB에서 탑재되었는지 확인합니다.
kubectl describe pod iis-pod
명령의 출력은 다음 예제와 유사합니다.
Name: iis-pod
Namespace: default
Priority: 0
Node: akswin000001/10.225.5.246
Start Time: Fri, 05 May 2023 09:34:41 -0400
Labels: app=web
Annotations: <none>
Status: Running
IP: 10.225.5.248
IPs:
IP: 10.225.5.248
Containers:
web:
Container ID: containerd://39a1659b6a2b6db298df630237b2b7d959d1b1722edc81ce9b1bc7f06237850c
Image: mcr.microsoft.com/windows/servercore/iis:windowsservercore
Image ID: mcr.microsoft.com/windows/servercore/iis@sha256:0f0114d0f6c6ee569e1494953efdecb76465998df5eba951dc760ac5812c7409
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Fri, 05 May 2023 09:34:55 -0400
Ready: True
Restart Count: 0
Limits:
cpu: 1
memory: 800M
Requests:
cpu: 1
memory: 800M
Environment: <none>
Mounts:
/inetpub/wwwroot from smb (rw)
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-mbnv8 (ro)
...
kubectl exec 명령을 사용하여 Pod에 연결하여 볼륨이 Pod에 탑재되었는지 확인합니다. 그런 다음 올바른 디렉터리의 명령을 사용하여 dir
볼륨이 탑재되고 크기가 프로비전한 볼륨의 크기와 일치하는지 검사.
kubectl exec -it iis-pod –- cmd.exe
명령의 출력은 다음 예제와 유사합니다.
Microsoft Windows [Version 10.0.20348.1668]
(c) Microsoft Corporation. All rights reserved.
C:\>cd /inetpub/wwwroot
C:\inetpub\wwwroot>dir
Volume in drive C has no label.
Volume Serial Number is 86BB-AA55
Directory of C:\inetpub\wwwroot
05/04/2023 08:15 PM <DIR> .
05/04/2023 08:15 PM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 107,373,838,336 bytes free
다음 단계
Astra Trident는 Azure NetApp Files를 통해 많은 기능을 지원합니다. 자세한 내용은 다음을 참조하세요.