7.7.2.2. ProfileBindings を使用してワークロードをプロファイルにバインドする
ProfileBinding リソースを使用して、セキュリティープロファイルをコンテナーの SecurityContext にバインドできます。
手順
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: SelinuxProfile1 name: profile2 image: quay.io/security-profiles-operator/test-nginx-unprivileged:1.213 次のコマンドを実行して、namespace に
enable-binding=trueのラベルを付けます。$ oc label ns my-namespace spo.x-k8s.io/enable-binding=truetest-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.21Pod を作成します。
$ oc create -f test-pod.yaml注記Pod がすでに存在する場合、Pod を再作成しなければバインディングは適切に機能しません。
検証
次のコマンドを実行して、Pod が
ProfileBindingを継承していることを確認します。$ oc get pod test-pod -o jsonpath='{.spec.containers[*].securityContext.seLinuxOptions.type}'出力例
profile.process