7.7.2.2. ProfileBindings を使用してワークロードをプロファイルにバインドする


ProfileBinding リソースを使用して、セキュリティープロファイルをコンテナーの SecurityContext にバインドできます。

手順

  1. quay.io/security-profiles-operator/test-nginx-unprivileged:1.21 イメージを使用する Pod をサンプルの SelinuxProfile プロファイルにバインドするには、Pod と SelinuxProfile オブジェクトと同じ namespace に ProfileBinding オブジェクトを作成します。

    apiVersion: security-profiles-operator.x-k8s.io/v1alpha1
    kind: ProfileBinding
    metadata:
      namespace: my-namespace
      name: nginx-binding
    spec:
      profileRef:
        kind: SelinuxProfile 
    1
    
        name: profile 
    2
    
      image: quay.io/security-profiles-operator/test-nginx-unprivileged:1.21 
    3
    1
    kind: 変数はプロファイルの種類を参照します。
    2
    name: 変数は、プロファイルの名前を参照します。
    3
    イメージ属性にワイルドカードを使用する (image: "*") と、デフォルトのセキュリティープロファイルを有効にすることができます。
    重要

    image: "*" ワイルドカード属性を使用すると、すべての新しい Pod が、指定された namespace 内のデフォルトのセキュリティープロファイルにバインドされます。

  2. 次のコマンドを実行して、namespace に enable-binding=true のラベルを付けます。

    $ oc label ns my-namespace spo.x-k8s.io/enable-binding=true
  3. test-pod.yaml という名前の Pod を定義します。

    apiVersion: v1
    kind: Pod
    metadata:
      name: test-pod
    spec:
      containers:
      - name: test-container
        image: quay.io/security-profiles-operator/test-nginx-unprivileged:1.21
  4. Pod を作成します。

    $ oc create -f test-pod.yaml
    注記

    Pod がすでに存在する場合、Pod を再作成しなければバインディングは適切に機能しません。

検証

  • 次のコマンドを実行して、Pod が ProfileBinding を継承していることを確認します。

    $ oc get pod test-pod -o jsonpath='{.spec.containers[*].securityContext.seLinuxOptions.type}'

    出力例

    profile.process

Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

会社概要

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

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

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

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

Legal Notice

Theme

© 2026 Red Hat
トップに戻る