$ oc delete namespace stackrox
安装 Red Hat Advanced Cluster Security for Kubernetes 时,它会创建:
如果选择操作员安装方法,则会创建一个名为 `rhacs-operator` 的命名空间,用于安装操作员。
一个名为 `stackrox` 的命名空间,或者您创建 Central 和 SecuredCluster 自定义资源的另一个命名空间。
所有组件的 `PodSecurityPolicy` 和 Kubernetes 基于角色的访问控制 (RBAC) 对象。
命名空间上的附加标签,用于生成的网络策略。
如果不存在,则创建一个应用程序自定义资源定义 (CRD)。
卸载 Red Hat Advanced Cluster Security for Kubernetes 涉及删除所有这些项目。
您可以使用 OpenShift Container Platform 或 Kubernetes 命令行界面删除 Red Hat Advanced Cluster Security for Kubernetes 创建的命名空间。
删除 `stackrox` 命名空间
在 OpenShift Container Platform 上
$ oc delete namespace stackrox
在 Kubernetes 上
$ kubectl delete namespace stackrox
如果您在不同的命名空间中安装了 RHACS,请在 `delete` 命令中使用该命名空间的名称。 |
您可以使用 OpenShift Container Platform 或 Kubernetes 命令行界面 (CLI) 删除 Red Hat Advanced Cluster Security for Kubernetes (RHACS) 创建的全局资源。
要使用 OpenShift Container Platform CLI 删除全局资源,请执行以下步骤:
检索所有与 StackRox 相关的集群角色、集群角色绑定、角色、角色绑定和 PSP,然后运行以下命令将其删除:
$ oc get clusterrole,clusterrolebinding,role,rolebinding,psp -o name | grep stackrox | xargs oc delete --wait
在 RHACS 4.4 及更高版本中,您可能会收到 |
运行以下命令删除标有app.kubernetes.io/name=stackrox
的自定义安全上下文约束 (SCC):
$ oc delete scc -l "app.kubernetes.io/name=stackrox"
在 RHACS 4.4 及更高版本中,您可能会收到 |
运行以下命令删除名为stackrox
的ValidatingWebhookConfiguration
对象:
$ oc delete ValidatingWebhookConfiguration stackrox
要使用 Kubernetes CLI 删除全局资源,请执行以下步骤:
检索所有与 StackRox 相关的集群角色、集群角色绑定、角色、角色绑定和 PSP,然后运行以下命令将其删除:
$ kubectl get clusterrole,clusterrolebinding,role,rolebinding,psp -o name | grep stackrox | xargs kubectl delete --wait
在 RHACS 4.4 及更高版本中,您可能会收到 |
运行以下命令删除名为stackrox
的ValidatingWebhookConfiguration
对象:
$ kubectl delete ValidatingWebhookConfiguration stackrox
您可以使用 OpenShift Container Platform 或 Kubernetes 命令行界面删除 Red Hat Advanced Cluster Security for Kubernetes 创建的标签和注释。
删除标签和注释
在 OpenShift Container Platform 上
$ for namespace in $(oc get ns | tail -n +2 | awk '{print $1}'); do oc label namespace $namespace namespace.metadata.stackrox.io/id-; oc label namespace $namespace namespace.metadata.stackrox.io/name-; oc annotate namespace $namespace modified-by.stackrox.io/namespace-label-patcher-; done
在 Kubernetes 上
$ for namespace in $(kubectl get ns | tail -n +2 | awk '{print $1}'); do kubectl label namespace $namespace namespace.metadata.stackrox.io/id-; kubectl label namespace $namespace namespace.metadata.stackrox.io/name-; kubectl annotate namespace $namespace modified-by.stackrox.io/namespace-label-patcher-; done