7.7.2. Pod への SELinux プロファイルの適用


Pod を作成して、作成したプロファイルの 1 つを適用します。

SELinux プロファイルの場合、namespace にラベルを付けて、特権 ワークロードを許可する必要があります。

手順

  1. 次のコマンドを実行して、scc.podSecurityLabelSync=false ラベルを nginx-deploy namespace に適用します。

    $ oc label ns nginx-deploy security.openshift.io/scc.podSecurityLabelSync=false
  2. 次のコマンドを実行して、privileged ラベルを nginx-deploy namespace に適用します。

    $ oc label ns nginx-deploy --overwrite=true pod-security.kubernetes.io/enforce=privileged
  3. 次のコマンドを実行して、SELinux プロファイルの使用文字列を取得します。

    $ oc get selinuxprofile.security-profiles-operator.x-k8s.io/nginx-secure -ojsonpath='{.status.usage}'

    出力例

    nginx-secure.process

  4. ワークロードマニフェストの出力文字列を .spec.containers[].securityContext.seLinuxOptions 属性に適用します。

    apiVersion: v1
    kind: Pod
    metadata:
      name: nginx-secure
      namespace: nginx-deploy
    spec:
      securityContext:
        runAsNonRoot: true
        seccompProfile:
          type: RuntimeDefault
      containers:
        - image: nginxinc/nginx-unprivileged:1.21
          name: nginx
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: [ALL]
            seLinuxOptions:
              # NOTE: This uses an appropriate SELinux type
              type: nginx-secure.process
    重要

    ワークロードを作成する前に、SELinux type が存在している必要があります。

7.7.2.1. SELinux ログポリシーの適用

ポリシー違反または AVC 拒否をログに記録するには、SElinuxProfile プロファイルを permissive に設定します。

重要

この手順では、ロギングポリシーを定義します。施行ポリシーを設定しません。

手順

  • permissive: trueSElinuxProfile に追加します。

    apiVersion: security-profiles-operator.x-k8s.io/v1alpha2
    kind: SelinuxProfile
    metadata:
      name: nginx-secure
    spec:
      permissive: true
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

Red Hat ドキュメントについて

Legal Notice

Theme

© 2026 Red Hat
トップに戻る