k8spspcapabilities
基本信息
作用
限制PodSecurityPolicy中的“allowedCapabilities”和“requiredDropCapabilities”字段。
策略实例示例
以下策略实例展示了策略定义生效的资源类型,parameters中定义了allowedCapabilities和requiredDropCapabilities的列表。
apiVersion: constraints.gatekeeper.sh/v1beta1 kind: K8sPSPCapabilities metadata: name: capabilities-demo spec: match: kinds: - apiGroups: [""] kinds: ["Pod"] namespaces: - "default" parameters: allowedCapabilities: ["something"] requiredDropCapabilities: ["must_drop"]
符合策略实例的资源定义
示例capabilities中的各项参数符合策略实例。
apiVersion: v1 kind: Pod metadata: name: opa-allowed labels: owner: me.agilebank.demo spec: containers: - name: opa image: openpolicyagent/opa:0.9.2 args: - "run" - "--server" - "--addr=localhost:8080" securityContext: capabilities: add: ["something"] drop: ["must_drop", "another_one"] resources: limits: cpu: "100m" memory: "30Mi"
不符合策略实例的资源定义
示例capabilities中的参数不符合策略实例。
apiVersion: v1 kind: Pod metadata: name: opa-disallowed labels: owner: me.agilebank.demo spec: containers: - name: opa image: openpolicyagent/opa:0.9.2 args: - "run" - "--server" - "--addr=localhost:8080" securityContext: capabilities: add: ["disallowedcapability"] resources: limits: cpu: "100m" memory: "30Mi"