Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

28.7.5. 创建持久性卷声明

  1. 作为常规用户,创建 PersistentVolumeClaim 以访问卷:

    $ oc create -f gluster-pvc.yaml -n <project_name>
  2. 定义 pod 以访问声明:

    例 28.10. Pod 定义

    apiVersion: v1
    id: gluster-S3-pvc
    kind: Pod
    metadata:
      name: gluster-nginx-priv
    spec:
      containers:
        - name: gluster-nginx-priv
          image: fedora/nginx
          volumeMounts:
            - mountPath: /mnt/gluster 1
              name: gluster-volume-claim
          securityContext:
            privileged: true
      volumes:
        - name: gluster-volume-claim
          persistentVolumeClaim:
            claimName: gluster-claim 2
    1
    pod 中的卷挂载。
    2
    gluster-claim 必须反映 PersistentVolume 的名称。
  3. 创建 pod 后,挂载目录会被创建,卷将连接到那个挂载点。

    以普通用户身份,从定义中创建 pod:

    $ oc create -f gluster-S3-pod.yaml
  4. 验证 pod 是否已成功创建:

    $ oc get pods
    NAME                 READY     STATUS    RESTARTS   AGE
    gluster-S3-pod   1/1       Running   0          36m

    创建 pod 可能需要几分钟时间。