文档首页> 华为云UCS> 用户指南> 策略中心> 使用策略定义库> k8spspallowprivilegeescalationcontainer
更新时间:2024-01-05 GMT+08:00
分享

k8spspallowprivilegeescalationcontainer

基本信息

  • 策略类型:安全
  • 推荐级别:L3
  • 生效资源类型:Pod
  • 参数:

    exemptImages:字符串数组

作用

约束PodSecurityPolicy中的“allowPrivilegeEscalation”字段为false。

策略实例示例

以下策略实例展示了策略定义生效的资源类型。

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sPSPAllowPrivilegeEscalationContainer
metadata:
  name: psp-allow-privilege-escalation-container
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]

符合策略实例的资源定义

示例中allowPrivilegeEscalation的值为false,符合策略实例。

apiVersion: v1
kind: Pod
metadata:
  name: nginx-privilege-escalation-allowed
  labels:
    app: nginx-privilege-escalation
spec:
  containers:
  - name: nginx
    image: nginx
    securityContext:
      allowPrivilegeEscalation: false

不符合策略实例的资源定义

示例中allowPrivilegeEscalation的值不为false,不符合策略实例。

apiVersion: v1
kind: Pod
metadata:
  name: nginx-privilege-escalation-disallowed
  labels:
    app: nginx-privilege-escalation
spec:
  containers:
  - name: nginx
    image: nginx
    securityContext:
      allowPrivilegeEscalation: true
分享:

    相关文档

    相关产品