You can use Server Message Block (SMB) file systems of Apsara File Storage NAS (NAS) as the storage resources for Windows containers that run in a Container Service for Kubernetes (ACK) cluster. This topic describes how to mount SMB file systems to Windows containers.
- Create a node pool that runs Windows.
- Use kubectl to connect to an ACK cluster.
- In the NAS console, create an SMB file system in the virtual private cloud (VPC) where the ACK cluster is deployed, and create a mount target for the SMB file system. For more information, see Mount an SMB file system on Windows.
Step 1: Deploy the FlexVolume plug-in
For more information, see the "Deploy the FlexVolume plug-in in the ACK cluster" section of the Mount Alibaba Cloud disks to Windows containers topic.
Step 2: Create a PV and a PVC
- Use the following YAML template to create a persistent volume (PV) and a persistent
volume claim (PVC).
apiVersion: v1 kind: PersistentVolume metadata: labels: alicloud-pvname: pv-smb name: pv-smb spec: accessModes: - ReadWriteMany capacity: storage: 5Gi flexVolume: driver: alicloud/smb.exe options: path: \myshare\test server: 25f3f4819c-eak52.cn-shenzhen.nas.aliyuncs.com user: workshop\administrator password: *** persistentVolumeReclaimPolicy: Retain
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-smb spec: accessModes: - ReadWriteMany resources: requests: storage: 5Gi selector: matchLabels: alicloud-pvname: pv-smbThe following table describes the required parameters in the PV template.
Parameter Description driver The driver that is used to mount the SMB file system. Set the value to alicloud/smb.exe. server The domain name of the mount target for the SMB file system. The mount target must be in the same VPC as the ACK cluster. path The path where the SMB file system is mounted. Set the value to \myshare or a subdirectory that starts with \myshare. user The username that is used to log on to a node. We recommend that you use workshop\administrator. password The password that is used to log on to a node.
- Run the
kubectl get pvc |grep pvc-smbcommand to view the newly created PVC.The following output is returned:
pvc-smb Bound pv-smb 5Gi RWX 24h
Step 3: Create an application
- Use the following YAML template to create an application.
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx-smb namespace: default spec: selector: matchLabels: app: nginx-smb template: metadata: labels: app: nginx-smb spec: replicas: 2 tolerations: - effect: NoSchedule key: os operator: Equal value: windows containers: - args: - -Command - start-sleep 10000 command: - pwsh.exe image: registry.cn-hangzhou.aliyuncs.com/acs/flexvolume:v220.127.116.11be0fa0-windows1809 imagePullPolicy: IfNotPresent name: nginx volumeMounts: - mountPath: /data name: pvc-nas restartPolicy: Always volumes: - name: pvc-nas persistentVolumeClaim: claimName: pvc-smb
- Run the
kubectl get podcommand to view the state of the application.The following output is returned:
NAME READY STATUS RESTARTS AGE nginx-smb-965fb4597-jz6fv 1/1 Running 0 95s nginx-smb-965fb4597-zvbhk 1/1 Running 0 42sIf the application is in the Running state, the application is created.