7.4. 启用安全配置集 Operator
在使用 Security Profiles Operator 之前,您必须确保在集群中部署 Operator。
7.4.1. 安装 Security Profiles Operator
先决条件
-
您必须具有
admin
权限。
流程
- 在 OpenShift Container Platform Web 控制台中导航至 Operators → OperatorHub。
- 搜索 Security Profiles Operator,然后点 Install。
-
保留安装模式和命名空间的默认选择,以确保将 Operator 安装到
openshift-security-profiles
命名空间中。 - 点 Install。
验证
确认安装成功:
- 进入到 Operators → Installed Operators 页面。
-
检查 Security Profiles Operator 是否在
openshift-security-profiles
命名空间中安装,其状态是否为Succeeded
。
如果 Operator 没有成功安装:
-
导航到 Operators → Installed Operators 页面,并检查
Status
列中是否有任何错误或故障。 -
进入到 Workloads → Pods 页面,检查
openshift-security-profiles
项目中报告问题的 pod 的日志。
7.4.2. 使用 CLI 安装 Security Profiles Operator
先决条件
-
您必须具有
admin
权限。
流程
定义一个
Namespace
对象:namespace-object.yaml
示例apiVersion: v1 kind: Namespace metadata: name: openshift-security-profiles labels: openshift.io/cluster-monitoring: "true"
创建
Namespace
对象:$ oc create -f namespace-object.yaml
定义一个
OperatorGroup
对象:operator-group-object.yaml
示例apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: security-profiles-operator namespace: openshift-security-profiles
创建
OperatorGroup
对象:$ oc create -f operator-group-object.yaml
定义一个
Subscription
对象:subscription-object.yaml
示例apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: security-profiles-operator-sub namespace: openshift-security-profiles spec: channel: release-alpha-rhel-8 installPlanApproval: Automatic name: security-profiles-operator source: redhat-operators sourceNamespace: openshift-marketplace
创建
Subscription
对象:$ oc create -f subscription-object.yaml
如果要设置全局调度程序功能并启用 defaultNodeSelector
,您必须手动创建命名空间并更新 openshift-security-profiles
命名空间的注解,或安装 Security Profiles Operator 的命名空间,使用 openshift.io/node-selector: ""
。这会删除默认节点选择器并防止部署失败。
验证
通过检查以下 CSV 文件来验证安装是否成功:
$ oc get csv -n openshift-security-profiles
运行以下命令,验证 Security Profiles Operator 是否正常工作:
$ oc get deploy -n openshift-security-profiles
7.4.3. 配置日志记录详细程度
Security Profiles Operator 支持默认日志记录详细程度 0
,以及更加详细的 1
。
流程
要启用增强的日志详细程度,请运行以下命令来修补
spod
配置并调整值:$ oc -n openshift-security-profiles patch spod \ spod --type=merge -p '{"spec":{"verbosity":1}}'
输出示例
securityprofilesoperatordaemon.security-profiles-operator.x-k8s.io/spod patched