搜索

4.4. 使用 S3 协议在旧应用程序与云原生应用程序间共享

download PDF

许多传统应用程序会使用文件系统共享数据集。您可以使用 S3 操作访问和共享文件系统中的传统数据。要共享您需要的数据,请执行以下操作:

  • 导出预先存在的文件系统数据集,即 RWX 卷,如 Ceph FileSystem(CephFS),或使用 S3 协议创建新的文件系统数据集。
  • 从文件系统和 S3 协议访问文件系统数据集。
  • 配置 S3 帐户,并将它们映射到现有文件系统唯一标识符(UID)和组标识符(GID)。

4.4.1. 创建 NamespaceStore 来使用文件系统

先决条件

  • 安装了带有 OpenShift Data Foundation operator 的 OpenShift Container Platform。
  • 访问多云对象网关(MCG)。

流程

  1. 登录 OpenShift Web 控制台。
  2. Storage Object Storage
  3. NamespaceStore 标签来创建在命名空间存储桶中使用的 NamespaceStore 资源。
  4. Create namespacestore
  5. 为 NamespaceStore 输入一个名称。
  6. 选择 Filesystem 作为供应商。
  7. 选择持久性卷声明。
  8. 输入文件夹名称。

    如果文件夹名称已存在,则该文件夹会用于创建 NamespaceStore,如果不存在则创建新的文件夹。

  9. Create
  10. 验证 NamespaceStore 是否处于 Ready 状态。

4.4.2. 使用 NamespaceStore 文件系统配置创建帐户

您可以使用 NamespaceStore 文件系统配置创建新帐户,或通过编辑 YAML 将现有的普通帐户转换为 NamespaceStore 文件系统帐户。

注意

您无法从帐户中删除 NamespaceStore 文件系统配置。

先决条件

  • 下载 Multicloud 对象网关 (MCG) 命令行界面:

    # subscription-manager repos --enable=rh-odf-4-for-rhel-8-x86_64-rpms
    # yum install mcg

流程

  • 使用 MCG 命令行界面使用 NamespaceStore 文件系统配置创建新帐户。

    $ noobaa account create <noobaa-account-name> [flags]

    例如:

    $ noobaa account create testaccount --full_permission --nsfs_account_config --gid 10001 --uid 10001 –default_resource fs_namespacestore

    allow_bucket_create

    指明是否允许帐户创建新存储桶。支持的值是 truefalse。默认值为 true

    allowed_buckets

    以逗号分隔的存储桶名称列表,用户被允许具有访问权限和管理权限。

    --default_resource

    使用 S3 CreateBucket 操作时,将在其上创建新的存储桶的 NamespaceStore 资源。NamespaceStore 必须使用 RWX(ReadWriteMany)持久性卷声明(PVC)支持。

    full_permission

    指明是否应该允许完全权限。支持的值是 truefalse。默认值为 false

    new_buckets_path

    创建与新 bucket 对应的目录的文件系统路径。该路径位于 NamespaceStore 文件系统 PVC 中,其中创建新目录充当新创建的对象存储桶类的文件系统映射。

    nsfs_account_config

    指示该帐户是否用于 NamespaceStore 文件系统的必需字段。

    nsfs_only

    指明帐户是否仅用于 NamespaceStore 文件系统。支持的值是 true 或 false。默认值为 false。如果设为 'true',则会限制您访问其他类型的存储桶。

    uid

    MCG 帐户要映射到的文件系统 ID,用于访问和管理文件系统中的数据

    gid

    MCG 帐户要映射到的文件系统的组 ID,用于访问和管理文件系统中的数据

    MCG 系统使用帐户配置及其 S3 凭证发送响应:

    # NooBaaAccount spec:
    allow_bucket_creation: true
    Allowed_buckets:
      full_permission: true
      permission_list: []
    default_resource: noobaa-default-namespace-store
    Nsfs_account_config:
      gid: 10001
      new_buckets_path: /
      nsfs_only: true
      uid: 10001
    INFO[0006] ✅ Exists: Secret "noobaa-account-testaccount"
    Connection info:
      AWS_ACCESS_KEY_ID      : <aws-access-key-id>
      AWS_SECRET_ACCESS_KEY  : <aws-secret-access-key>

    您可以使用以下命令列出所有基于自定义资源定义(CRD)的帐户:

    $ noobaa account list
    NAME          ALLOWED_BUCKETS   DEFAULT_RESOURCE               PHASE   AGE
    testaccount   [*]               noobaa-default-backing-store   Ready   1m17s

    如果您对特定帐户感兴趣,您可以直接读取其自定义资源定义(CRD):

    $ oc get noobaaaccount/testaccount -o yaml
    spec:
      allow_bucket_creation: true
      allowed_buckets:
        full_permission: true
        permission_list: []
      default_resource: noobaa-default-namespace-store
      nsfs_account_config:
        gid: 10001
        new_buckets_path: /
        nsfs_only: true
        uid: 10001

4.4.3. 从 openshift-storage 命名空间中访问旧的应用程序数据

当使用 Multicloud Object Gateway(MCG)NamespaceStore 文件系统(NSFS)功能时,您需要具有数据位于 openshift-storage 命名空间中的 PVC。几乎在所有情形中,您需要访问的数据不在 openshift-storage 命名空间中,而是位于传统应用程序使用的命名空间中。

要访问存储在另一个命名空间中的数据,您需要在 openshift-storage 命名空间中创建一个指向传统应用使用的同一 CephFS 卷的 PVC。

流程

  1. 使用 scc 显示应用程序命名空间:

    $ oc get ns <application_namespace> -o yaml | grep scc
    <application_namespace>

    指定应用程序命名空间的名称。

    例如:

    $ oc get ns testnamespace -o yaml | grep scc
    
    openshift.io/sa.scc.mcs: s0:c26,c5
    openshift.io/sa.scc.supplemental-groups: 1000660000/10000
    openshift.io/sa.scc.uid-range: 1000660000/10000
  2. 进入应用程序命名空间:

    $ oc project <application_namespace>

    例如:

    $ oc project testnamespace
  3. 确保 ReadWriteMany(RWX) PVC 挂载到您要使用 MCG NSFS 功能从 noobaa S3 端点使用的 pod 上:

    $ oc get pvc
    
    NAME                                               STATUS VOLUME
    CAPACITY ACCESS MODES STORAGECLASS              AGE
    cephfs-write-workload-generator-no-cache-pv-claim  Bound  pvc-aa58fb91-c3d2-475b-bbee-68452a613e1a
    10Gi     RWX          ocs-storagecluster-cephfs 12s
    $ oc get pod
    
    NAME                                                READY   STATUS              RESTARTS   AGE
    cephfs-write-workload-generator-no-cache-1-cv892    1/1     Running             0          11s
  4. 检查 pod 中的持久性卷(PV)的挂载点。

    1. 从 pod 获取 PV 的卷名称:

      $ oc get pods <pod_name> -o jsonpath='{.spec.volumes[]}'
      <pod_name>

      指定 pod 的名称。

      例如:

      $ oc get pods cephfs-write-workload-generator-no-cache-1-cv892 -o jsonpath='{.spec.volumes[]}'
      
      {"name":"app-persistent-storage","persistentVolumeClaim":{"claimName":"cephfs-write-workload-generator-no-cache-pv-claim"}}

      在本例中,PVC 的卷名称为 cephfs-write-workload-generator-no-cache-pv-claim

    2. 列出 pod 中的所有挂载,并检查您在上一步中标识的卷的挂载点:

      $ oc get pods <pod_name> -o jsonpath='{.spec.containers[].volumeMounts}'

      例如:

      $ oc get pods cephfs-write-workload-generator-no-cache-1-cv892 -o jsonpath='{.spec.containers[].volumeMounts}'
      
      [{"mountPath":"/mnt/pv","name":"app-persistent-storage"},{"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount","name":"kube-api-access-8tnc5","readOnly":true}]
  5. 确认 pod 中的 RWX PV 的挂载点:

    $ oc exec -it <pod_name> -- df <mount_path>
    <mount_path>

    指定您在上一步中标识的挂载点的路径。

    例如:

    $ oc exec -it cephfs-write-workload-generator-no-cache-1-cv892 -- df /mnt/pv
    
    main
    Filesystem
    1K-blocks Used Available  Use%  Mounted on
    172.30.202.87:6789,172.30.120.254:6789,172.30.77.247:6789:/volumes/csi/csi-vol-cc416d9e-dbf3-11ec-b286-0a580a810213/edcfe4d5-bdcb-4b8e-8824-8a03ad94d67c
    10485760  0    10485760   0%    /mnt/pv
  6. 确保 UID 和 SELinux 标签与旧命名空间使用的标签相同:

    $ oc exec -it <pod_name> -- ls -latrZ <mount_path>

    例如:

    $ oc exec -it cephfs-write-workload-generator-no-cache-1-cv892 -- ls -latrZ /mnt/pv/
    
    total 567
    drwxrwxrwx. 3 root       root system_u:object_r:container_file_t:s0:c26,c5      2 May 25 06:35 .
    -rw-r--r--. 1 1000660000 root system_u:object_r:container_file_t:s0:c26,c5 580138 May 25 06:35 fs_write_cephfs-write-workload-generator-no-cache-1-cv892-data.log
    drwxrwxrwx. 3 root       root system_u:object_r:container_file_t:s0:c26,c5     30 May 25 06:35 ..
  7. 获取您要从 openshift-storage 命名空间访问的旧应用程序 RWX PV 的信息:

    $ oc get pv | grep <pv_name>
    <pv_name>

    指定 PV 的名称。

    例如:

    $ oc get pv | grep pvc-aa58fb91-c3d2-475b-bbee-68452a613e1a
    
    pvc-aa58fb91-c3d2-475b-bbee-68452a613e1a   10Gi       RWX            Delete           Bound    testnamespace/cephfs-write-workload-generator-no-cache-pv-claim   ocs-storagecluster-cephfs              47s
  8. 确保来自 openshift-storage 命名空间中的 PVC 可以被访问,以便一个或多个 noobaa-endpoint pod 可以访问 PVC。

    1. volumeAttributes 找到 subvolumePathvolumeHandle 的值。您可以从传统应用程序 PV 的 YAML 描述中获取这些值:

      $ oc get pv <pv_name> -o yaml

      例如:

      $ oc get pv pvc-aa58fb91-c3d2-475b-bbee-68452a613e1a -o yaml
      
      apiVersion: v1
      kind: PersistentVolume
      metadata:
        annotations:
          pv.kubernetes.io/provisioned-by: openshift-storage.cephfs.csi.ceph.com
        creationTimestamp: "2022-05-25T06:27:49Z"
        finalizers:
        - kubernetes.io/pv-protection
        name: pvc-aa58fb91-c3d2-475b-bbee-68452a613e1a
        resourceVersion: "177458"
        uid: 683fa87b-5192-4ccf-af2f-68c6bcf8f500
      spec:
        accessModes:
        - ReadWriteMany
        capacity:
          storage: 10Gi
        claimRef:
          apiVersion: v1
          kind: PersistentVolumeClaim
          name: cephfs-write-workload-generator-no-cache-pv-claim
          namespace: testnamespace
          resourceVersion: "177453"
          uid: aa58fb91-c3d2-475b-bbee-68452a613e1a
        csi:
          controllerExpandSecretRef:
            name: rook-csi-cephfs-provisioner
            namespace: openshift-storage
          driver: openshift-storage.cephfs.csi.ceph.com
          nodeStageSecretRef:
            name: rook-csi-cephfs-node
            namespace: openshift-storage
          volumeAttributes:
            clusterID: openshift-storage
            fsName: ocs-storagecluster-cephfilesystem
            storage.kubernetes.io/csiProvisionerIdentity: 1653458225664-8081-openshift-storage.cephfs.csi.ceph.com
            subvolumeName: csi-vol-cc416d9e-dbf3-11ec-b286-0a580a810213
            subvolumePath: /volumes/csi/csi-vol-cc416d9e-dbf3-11ec-b286-0a580a810213/edcfe4d5-bdcb-4b8e-8824-8a03ad94d67c
          volumeHandle: 0001-0011-openshift-storage-0000000000000001-cc416d9e-dbf3-11ec-b286-0a580a810213
        persistentVolumeReclaimPolicy: Delete
        storageClassName: ocs-storagecluster-cephfs
        volumeMode: Filesystem
      status:
        phase: Bound
    2. 使用您在上一步中确定的 subvolumePathvolumeHandle 值在 openshift-storage 命名空间中创建一个新的 PV 和 PVC 对象,指向与旧应用程序 PV 相同的 CephFS 卷:

      YAML 文件示例

      $ cat << EOF >> pv-openshift-storage.yaml
      apiVersion: v1
      kind: PersistentVolume
      metadata:
        name: cephfs-pv-legacy-openshift-storage
      spec:
        storageClassName: ""
        accessModes:
        - ReadWriteMany
        capacity:
          storage: 10Gi     1
        csi:
          driver: openshift-storage.cephfs.csi.ceph.com
          nodeStageSecretRef:
            name: rook-csi-cephfs-node
            namespace: openshift-storage
          volumeAttributes:
          # Volume Attributes can be copied from the Source testnamespace PV
            "clusterID": "openshift-storage"
            "fsName": "ocs-storagecluster-cephfilesystem"
            "staticVolume": "true"
          # rootpath is the subvolumePath: you copied from the Source testnamespace PV
            "rootPath": /volumes/csi/csi-vol-cc416d9e-dbf3-11ec-b286-0a580a810213/edcfe4d5-bdcb-4b8e-8824-8a03ad94d67c
          volumeHandle: 0001-0011-openshift-storage-0000000000000001-cc416d9e-dbf3-11ec-b286-0a580a810213-clone   2
        persistentVolumeReclaimPolicy: Retain
        volumeMode: Filesystem
      ---
      apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: cephfs-pvc-legacy
        namespace: openshift-storage
      spec:
        storageClassName: ""
        accessModes:
        - ReadWriteMany
        resources:
          requests:
            storage: 10Gi     3
        volumeMode: Filesystem
        # volumeName should be same as PV name
        volumeName: cephfs-pv-legacy-openshift-storage
      EOF
      1
      openshift-storage 命名空间中创建的 PV 的存储容量必须与原始 PV 相同。
      2
      您在 openshift-storage 中创建的目标 PV 的卷处理需要与原始应用程序 PV 不同,例如,在卷句柄末尾添加 -clone
      3
      openshift-storage 命名空间中创建的 PVC 的存储容量必须与原始 PVC 相同。
    3. 使用上一步中指定的 YAML 文件,在 openshift-storage 命名空间中创建 PV 和 PVC:

      $ oc create -f <YAML_file>
      <YAML_file>

      指定 YAML 文件的名称。

      例如:

      $ oc create -f pv-openshift-storage.yaml
      
      persistentvolume/cephfs-pv-legacy-openshift-storage created
      persistentvolumeclaim/cephfs-pvc-legacy created
    4. 确保 PVC 在 openshift-storage 命名空间中可用:

      $ oc get pvc -n openshift-storage
      
      NAME                                  STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS                  AGE
      cephfs-pvc-legacy                     Bound    cephfs-pv-legacy-openshift-storage         10Gi       RWX                                          14s
    5. 进入 openshift-storage 项目:

      $ oc project openshift-storage
      
      Now using project "openshift-storage" on server "https://api.cluster-5f6ng.5f6ng.sandbox65.opentlc.com:6443".
    6. 创建 NSFS 命名空间存储:

      $ noobaa namespacestore create nsfs <nsfs_namespacestore> --pvc-name='<cephfs_pvc_name>' --fs-backend='CEPH_FS'
      <nsfs_namespacestore>
      指定 NSFS 命名空间存储的名称。
      <cephfs_pvc_name>

      openshift-storage 命名空间中指定 CephFS PVC 的名称。

      例如:

      $ noobaa namespacestore create nsfs legacy-namespace --pvc-name='cephfs-pvc-legacy' --fs-backend='CEPH_FS'
    7. 确保 noobaa-endpoint pod 重启,并在 NSFS 命名空间存储中成功挂载 PVC,例如 /nsfs/legacy-namespace 挂载点:

      $ oc exec -it <noobaa_endpoint_pod_name> -- df -h /nsfs/<nsfs_namespacestore>
      <noobaa_endpoint_pod_name>

      指定 noobaa-endpoint pod 的名称。

      例如:

      $ oc exec -it noobaa-endpoint-5875f467f5-546c6 -- df -h /nsfs/legacy-namespace
      
      Filesystem                                                                                                                                                Size  Used Avail Use% Mounted on
      172.30.202.87:6789,172.30.120.254:6789,172.30.77.247:6789:/volumes/csi/csi-vol-cc416d9e-dbf3-11ec-b286-0a580a810213/edcfe4d5-bdcb-4b8e-8824-8a03ad94d67c   10G     0   10G   0% /nsfs/legacy-namespace
    8. 创建一个 MCG 用户帐户:

      $ noobaa account create <user_account> --full_permission --allow_bucket_create=true --new_buckets_path='/' --nsfs_only=true --nsfs_account_config=true --gid <gid_number> --uid <uid_number> --default_resource='legacy-namespace'
      <user_account>
      指定 MCG 用户帐户的名称。
      <gid_number>
      指定 GID 号。
      <uid_number>

      指定 UID 号。

      重要

      使用与传统应用的相同 UIDGID。您可以从前面的输出中找到它。

      例如:

      $ noobaa account create leguser --full_permission --allow_bucket_create=true --new_buckets_path='/' --nsfs_only=true --nsfs_account_config=true --gid 0 --uid 1000660000 --default_resource='legacy-namespace'
    9. 创建一个 MCG 存储桶。

      1. 在传统应用 pod 的 CephFS PV 和 PVC 的 NSFS 共享中为 S3 创建一个专用文件夹:

        $ oc exec -it <pod_name> -- mkdir <mount_path>/nsfs

        例如:

        $ oc exec -it cephfs-write-workload-generator-no-cache-1-cv892 -- mkdir /mnt/pv/nsfs
      2. 使用 nsfs/ 路径创建 MCG 存储桶:

        $ noobaa api bucket_api create_bucket '{
          "name": "<bucket_name>",
          "namespace":{
            "write_resource": { "resource": "<nsfs_namespacestore>", "path": "nsfs/" },
            "read_resources": [ { "resource": "<nsfs_namespacestore>", "path": "nsfs/" }]
          }
        }'

        例如:

        $ noobaa api bucket_api create_bucket '{
          "name": "legacy-bucket",
          "namespace":{
            "write_resource": { "resource": "legacy-namespace", "path": "nsfs/" },
            "read_resources": [ { "resource": "legacy-namespace", "path": "nsfs/" }]
          }
        }'
    10. 检查位于传统应用程序和 openshift-storage 命名空间中的 PVC 中的文件夹的 SELinux 标签:

      $ oc exec -it <noobaa_endpoint_pod_name> -n openshift-storage -- ls -ltraZ /nsfs/<nsfs_namespacstore>

      例如:

      $ oc exec -it noobaa-endpoint-5875f467f5-546c6 -n openshift-storage -- ls -ltraZ /nsfs/legacy-namespace
      
      total 567
      drwxrwxrwx. 3 root       root system_u:object_r:container_file_t:s0:c0,c26      2 May 25 06:35 .
      -rw-r--r--. 1 1000660000 root system_u:object_r:container_file_t:s0:c0,c26 580138 May 25 06:35 fs_write_cephfs-write-workload-generator-no-cache-1-cv892-data.log
      drwxrwxrwx. 3 root       root system_u:object_r:container_file_t:s0:c0,c26     30 May 25 06:35 ..
      $ oc exec -it <pod_name> -- ls -latrZ <mount_path>

      例如:

      $ oc exec -it cephfs-write-workload-generator-no-cache-1-cv892 -- ls -latrZ /mnt/pv/
      
      total 567
      drwxrwxrwx. 3 root       root system_u:object_r:container_file_t:s0:c26,c5      2 May 25 06:35 .
      -rw-r--r--. 1 1000660000 root system_u:object_r:container_file_t:s0:c26,c5 580138 May 25 06:35 fs_write_cephfs-write-workload-generator-no-cache-1-cv892-data.log
      drwxrwxrwx. 3 root       root system_u:object_r:container_file_t:s0:c26,c5     30 May 25 06:35 ..

      在这些示例中,您可以看到 SELinux 标签不是不是导致权限被拒绝或访问问题的结果。

  9. 确保传统应用程序和 openshift-storage pod 在文件中使用相同的 SELinux 标签。

    您可以使用以下方法之一进行此操作:

  10. 删除 NSFS 命名空间存储:

    1. 删除 MCG 存储桶:

      $ noobaa bucket delete <bucket_name>

      例如:

      $ noobaa bucket delete legacy-bucket
    2. 删除 MCG 用户帐户:

      $ noobaa account delete <user_account>

      例如:

      $ noobaa account delete leguser
    3. 删除 NSFS 命名空间存储:

      $ noobaa namespacestore delete <nsfs_namespacestore>

      例如:

      $ noobaa namespacestore delete legacy-namespace
  11. 删除 PV 和 PVC:

    重要

    在删除 PV 和 PVC 前,请确保 PV 配置了保留策略。

    $ oc delete pv <cephfs_pv_name>
    $ oc delete pvc <cephfs_pvc_name>
    <cephfs_pv_name>
    指定传统应用的 CephFS PV 名称。
    <cephfs_pvc_name>

    指定传统应用的 CephFS PVC 名称。

    例如:

    $ oc delete pv cephfs-pv-legacy-openshift-storage
    $ oc delete pvc cephfs-pvc-legacy

4.4.3.1. 更改传统应用程序项目中的默认 SELinux 标签,使其与 openshift-storage 项目中的默认 SELinux 标签匹配

  1. 使用 sa.scc.mcs 显示当前的 openshift-storage 命名空间:

    $ oc get ns openshift-storage -o yaml | grep sa.scc.mcs
    
    openshift.io/sa.scc.mcs: s0:c26,c0
  2. 编辑传统应用程序命名空间,并使用 openshift-storage 命名空间的 sa.scc.mcs 中的值修改 sa.scc.mcs

    $ oc edit ns <appplication_namespace>

    例如:

    $ oc edit ns testnamespace
    $ oc get ns <application_namespace> -o yaml | grep sa.scc.mcs

    例如:

    $ oc get ns testnamespace -o yaml | grep sa.scc.mcs
    
    openshift.io/sa.scc.mcs: s0:c26,c0
  3. 重启旧的应用容器集。重新标记所有文件,现在 SELinux 标签与 openshift-storage 部署相匹配。

4.4.3.2. 仅修改具有挂载传统应用程序 PVC 的 pod 的部署配置的 SELinux 标签

  1. 使用 MustRunAsseLinuxOptions 选项创建一个新的 scc,使用 openshift-storage 项目使用的 Multi Category Security(MCS):

    YAML 文件示例:

    $ cat << EOF >> scc.yaml
    allowHostDirVolumePlugin: false
    allowHostIPC: false
    allowHostNetwork: false
    allowHostPID: false
    allowHostPorts: false
    allowPrivilegeEscalation: true
    allowPrivilegedContainer: false
    allowedCapabilities: null
    apiVersion: security.openshift.io/v1
    defaultAddCapabilities: null
    fsGroup:
      type: MustRunAs
    groups:
    - system:authenticated
    kind: SecurityContextConstraints
    metadata:
      annotations:
      name: restricted-pvselinux
    priority: null
    readOnlyRootFilesystem: false
    requiredDropCapabilities:
    - KILL
    - MKNOD
    - SETUID
    - SETGID
    runAsUser:
      type: MustRunAsRange
    seLinuxContext:
      seLinuxOptions:
        level: s0:c26,c0
      type: MustRunAs
    supplementalGroups:
      type: RunAsAny
    users: []
    volumes:
    - configMap
    - downwardAPI
    - emptyDir
    - persistentVolumeClaim
    - projected
    - secret
    EOF
    $ oc create -f scc.yaml
  2. 为部署创建一个服务帐户,并将其添加到新创建的 scc 中。

    1. 创建服务帐户:

      $ oc create serviceaccount <service_account_name>
      <service_account_name>`

      指定服务帐户的名称。

      例如:

      $ oc create serviceaccount testnamespacesa
    2. 将服务帐户添加到新创建的 scc 中:

      $ oc adm policy add-scc-to-user restricted-pvselinux -z <service_account_name>

      例如:

      $ oc adm policy add-scc-to-user restricted-pvselinux -z testnamespacesa
  3. 对传统应用程序部署进行补丁,使其使用新创建的服务帐户。这可让您在部署中指定 SELinux 标签:

    $ oc patch dc/<pod_name> '{"spec":{"template":{"spec":{"serviceAccountName": "<service_account_name>"}}}}'

    例如:

    $ oc patch dc/cephfs-write-workload-generator-no-cache --patch '{"spec":{"template":{"spec":{"serviceAccountName": "testnamespacesa"}}}}'
  4. 编辑部署,以指定要在部署配置的 SELinux 标签中使用的安全上下文:

    $ oc edit dc <pod_name> -n <application_namespace>

    添加以下行:

    spec:
     template:
        metadata:
          securityContext:
            seLinuxOptions:
              Level: <security_context_value>
    <security_context_value>

    当您执行命令以在 NSFS 共享内为 S3 创建专用文件夹时,可以在 legacy 应用 Pod 的 CephFS PV 和 PVC 上创建一个专用文件夹时,即可找到这个值。

    例如:

    $ oc edit dc cephfs-write-workload-generator-no-cache -n testnamespace
    spec:
     template:
        metadata:
          securityContext:
            seLinuxOptions:
              level: s0:c26,c0
  5. 确保正确在部署配置中的 SELinux 标签中使用安全上下文:

    $ oc get dc <pod_name> -n <application_namespace> -o yaml | grep -A 2 securityContext

    例如"

    $ oc get dc cephfs-write-workload-generator-no-cache -n testnamespace -o yaml | grep -A 2 securityContext
    
          securityContext:
            seLinuxOptions:
              level: s0:c26,c0

    传统应用程序重启并开始使用与 openshift-storage 命名空间相同的 SELinux 标签。

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.