7.7.2. Pod への SELinux プロファイルの適用
Pod を作成して、作成したプロファイルの 1 つを適用します。
SELinux プロファイルの場合、namespace にラベルを付けて、特権 ワークロードを許可する必要があります。
手順
次のコマンドを実行して、
scc.podSecurityLabelSync=falseラベルをnginx-deploynamespace に適用します。$ oc label ns nginx-deploy security.openshift.io/scc.podSecurityLabelSync=false次のコマンドを実行して、
privilegedラベルをnginx-deploynamespace に適用します。$ oc label ns nginx-deploy --overwrite=true pod-security.kubernetes.io/enforce=privileged次のコマンドを実行して、SELinux プロファイルの使用文字列を取得します。
$ oc get selinuxprofile.security-profiles-operator.x-k8s.io/nginx-secure -ojsonpath='{.status.usage}'出力例
nginx-secure.processワークロードマニフェストの出力文字列を
.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: trueをSElinuxProfileに追加します。apiVersion: security-profiles-operator.x-k8s.io/v1alpha2 kind: SelinuxProfile metadata: name: nginx-secure spec: permissive: true