k8spsphostnamespace
基本信息
- 策略类型:安全
- 推荐级别:L3
- 生效资源类型:Pod
- 参数:无
作用
限制PodSecurityPolicy中的“hostPID”和“hostIPC”字段。
策略实例示例
以下策略实例展示了策略定义生效的资源类型。
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sPSPHostNamespace
metadata:
name: psp-host-namespace
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
符合策略实例的资源定义
示例中hostPID和hostIPC均为false,符合策略实例。
apiVersion: v1
kind: Pod
metadata:
name: nginx-host-namespace-allowed
labels:
app: nginx-host-namespace
spec:
hostPID: false
hostIPC: false
containers:
- name: nginx
image: nginx
不符合策略实例的资源定义
示例中hostPID和hostIPC均为true,不符合策略实例。
apiVersion: v1
kind: Pod
metadata:
name: nginx-host-namespace-disallowed
labels:
app: nginx-host-namespace
spec:
hostPID: true
hostIPC: true
containers:
- name: nginx
image: nginx