Este tópico descreve como usar o kubectl para criar um volume persistente (PV) e uma solicitação de volume persistente (PVC). Em seguida, monte a PVC em uma aplicação em um nó RDS Custom AI ou Node Lingjun.
Precauções
Os nós RDS Custom AI e o Node Lingjun aceitam apenas AccessKeys em texto simples para montar buckets do OSS.
Etapa 1: Criar um usuário RAM com permissões de acesso ao OSS e obter um AccessKey
Primeiro, obtenha o AccessKey de um usuário do Resource Access Management (RAM) com permissão para operar em um bucket do OSS.
Criar um usuário RAM. Caso já possua um usuário RAM, ignore esta etapa.
-
Criar uma política personalizada.
Escolha a política somente leitura ou leitura e gravação abaixo conforme necessário. Substitua
mybucketpelo nome do seu bucket.-
Política de somente leitura do OSS
-
Política de leitura e gravação do OSS
-
Conceda permissões do OSS ao usuário RAM. Para mais informações, consulte Conceder permissões a um usuário RAM.
Crie um AccessKey para o usuário RAM. Para mais informações, consulte Obter um AccessKey.
Etapa 2: Criar um volume persistente (PV) estático
Execute o comando a seguir para criar um PV estático.
kubectl create -f pv-oss.yaml
O exemplo a seguir mostra o conteúdo do arquivo oss-csi-model-qwen-inner.yaml para criar um PV estático.
apiVersion: v1
kind: PersistentVolume
metadata:
name: oss-csi-model-qwen-inner # A unique name for the PV.
labels:
alicloud-pvname: oss-csi-model-qwen-inner # A custom tag that identifies the PV.
spec:
accessModes:
- ReadWriteMany # Supports multi-node read and write, a native attribute of OSS.
capacity:
storage: 63Gi # The storage capacity of the PV. This must match the OSS bucket capacity.
csi:
driver: ossplugin.csi.alibabacloud.com # The Alibaba Cloud OSS Container Storage Interface (CSI) driver.
volumeAttributes:
bucket: model-qwen # The name of the target OSS bucket.
path: /Qwen3-32B # The mount path prefix in the bucket, such as the /Qwen3-32B folder.
url: oss-cn-beijing-internal.aliyuncs.com # The internal OSS endpoint for the China (Beijing) region.
otherOpts: "-o allow_other" # Mount option: allows other users to access the volume.
akId: ****** # Your Alibaba Cloud AccessKey ID. Replace with the actual value.
akSecret: ***** # Your AccessKey secret. Replace with the actual value.
volumeHandle: oss-model-qwen-inner # A unique identifier for the volume.
persistentVolumeReclaimPolicy: Retain # Retains data when the PV is deleted. This is the default behavior.
storageClassName: oss # The name of the associated StorageClass.
volumeMode: Filesystem # Mounts the volume as a file system.
Etapa 3: Criar uma solicitação de volume persistente (PVC)
Execute o comando a seguir para criar uma PVC.
kubectl create -f pvc-oss.yaml
O exemplo a seguir mostra o conteúdo do arquivo oss-pvc-model-qwen-inner.yaml para criar uma PVC.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: oss-pvc-model-qwen-inner # The name of the PVC.
namespace: default # The namespace.
spec:
accessModes:
- ReadWriteMany # Requests the same access mode as the PV.
resources:
requests:
storage: 63Gi # The requested storage capacity. The value must be less than or equal to the PV capacity.
storageClassName: oss # The associated StorageClass.
volumeMode: Filesystem # The file system mode.
Etapa 4: Implantar um pod e montar a PVC
Execute o comando a seguir para implantar um pod e montar a PVC.
kubectl apply -f pod.yaml
O exemplo a seguir mostra o conteúdo do arquivo sglang-qwen3.yaml para implantar um pod.
apiVersion: v1
kind: Pod
metadata:
name: sglang-qwen3 # The name of the pod.
spec:
containers:
- command:
- sh
- -c
- echo hello world; sleep infinity; # A test command. Replace this with your actual business logic.
image: aliclouddb-pub-registry-vpc.cn-beijing.cr.aliyuncs.com/aliclouddb-public/des-ai-nv:25.05-sglang0.4.6.post4-pytorch2.6-cu124-20250513-serverless
imagePullPolicy: IfNotPresent # Pulls the image only if it is not already present.
name: sglang # The name of the container.
ports:
- containerPort: 8000 # The listener port of the container.
name: restful
protocol: TCP
resources:
requests:
cpu: "80"
memory: "300Gi"
nvidia.com/gpu: "8"
limits:
cpu: "80"
memory: "300Gi"
nvidia.com/gpu: "8"
volumeMounts:
- name: oss-volume # The mount name. This must match the name in the volumes section.
mountPath: "/data" # The mount path in the container. This path stores the OSS data.
volumes:
- name: oss-volume
persistentVolumeClaim:
claimName: oss-pvc-model-qwen-inner # The name of the associated PVC.
restartPolicy: Always # Restarts the pod if it fails.
nodeSelector:
alibabacloud.com/virtual-node: "true" # Schedules the pod to a virtual node.
tolerations:
- effect: NoSchedule
key: virtual-kubelet.io/provider
value: aliclouddb # The toleration for taints on virtual nodes.
Etapa 5: Verificar o pod
Execute o comando a seguir para verificar o status do pod.
kubectl get pod sglang-qwen3 -o wide