7.18.2.2. 在 Red Hat Enterprise Linux CoreOS(RHCOS)8 中为 hostpath 置备程序配置 SELinux


在创建 HostPathProvisioner 自定义资源前,您必须配置 SELinux。要在 Red Hat Enterprise Linux CoreOS(RHCOS)8 worker 上配置 SELinux,您必须 在每个节点上创建一个 MachineConfig 对象。

先决条件

  • 在每个节点上为 hostpath 置备程序创建的持久性卷(PV)创建后端目录。

    重要

    后备目录不能位于文件系统的根目录中,因为 / 分区在 RHCOS 上是只读的。例如,您可以使用 /var/<directory_name>,但不能使用 /<directory_name>

流程

  1. 创建 MachineConfig 文件。例如:

    $ touch machineconfig.yaml
  2. 编辑该文件,确保包含希望 hostpath 置备程序在其中创建 PV 的目录。例如:

    apiVersion: machineconfiguration.openshift.io/v1
    kind: MachineConfig
    metadata:
      name: 50-set-selinux-for-hostpath-provisioner
      labels:
        machineconfiguration.openshift.io/role: worker
    spec:
      config:
        ignition:
          version: 3.2.0
        systemd:
          units:
            - contents: |
                [Unit]
                Description=Set SELinux chcon for hostpath provisioner
                Before=kubelet.service
    
                [Service]
                ExecStart=/usr/bin/chcon -Rt container_file_t <backing_directory_path> 1
    
                [Install]
                WantedBy=multi-user.target
              enabled: true
              name: hostpath-provisioner.service
    1
    指定希望置备程序在其中创建 PV 的后备目录。该目录不得位于文件系统的根目录(/)中。
  3. 创建 MachineConfig 对象:

    $ oc create -f machineconfig.yaml -n <namespace>
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.