すべてのプロダクト
Search
ドキュメントセンター

Container Service for Kubernetes:コンテナセキュリティポリシールールライブラリの概要

最終更新日:Jun 24, 2026

コンプライアンス、インフラ、K8s-general、PSP、FinOps の 5 つの組み込みカテゴリにある 54 の事前定義された Gatekeeper ポリシーに対して、Pod のデプロイメントと更新リクエストを検証します。

ポリシーカテゴリ

カテゴリ 説明
コンプライアンス Alibaba Cloud Kubernetes Security Hardening などのコンプライアンス標準に基づくポリシーです。
インフラ クラウドインフラストラクチャリソースを保護するポリシーです。
K8s-general ACK クラスター内の機密性の高いリソース構成を制限および標準化し、クラスター内のアプリケーションセキュリティを強化するポリシーです。
PSP Kubernetes の Pod セキュリティポリシー (PSP) を置き換え、レガシーな ACK ポリシー管理と同等のセキュリティ制約を提供するポリシーです。

事前定義されたセキュリティポリシー

5 つのカテゴリには 54 の事前定義されたポリシーが含まれています。

カテゴリ ポリシー 説明 重要度
コンプライアンス ACKNoEnvVarSecrets Pod の環境変数で secretKeyRef を使用して Secret を参照することをブロックします。 中
コンプライアンス ACKPodsRequireSecurityContext 指定された名前空間の Pod に securityContext を含めることを要求します。 低
コンプライアンス ACKRestrictNamespaces 指定された名前空間で、指定されたリソースタイプのデプロイメントをブロックします。 低
コンプライアンス ACKRestrictRoleBindings 指定された名前空間の RoleBinding が、指定されたロールまたはクラスターロールのみをバインドするように制限します。 高
コンプライアンス ACKNamespacesDeleteProtection 指定された名前空間の削除を防止します。 中
コンプライアンス ACKServicesDeleteProtection 指定された名前空間の Service インスタンスの削除を防止します。 中
インフラ ACKBlockProcessNamespaceSharing 指定された名前空間の Pod が shareProcessNamespace を使用することをブロックします。 高
インフラ ACKEmptyDirHasSizeLimit emptyDir ボリュームをマウントする際に sizeLimit を要求します。 低
インフラ ACKLocalStorageRequireSafeToEvict hostPath または emptyDir ボリュームをマウントする Pod に cluster-autoscaler.kubernetes.io/safe-to-evict: "true" アノテーションを要求します。 低
インフラ ACKOSSStorageLocationConstraint 指定された名前空間の Pod にマウントできる OSS バケットのリージョンを制御します。 低
インフラ ACKPVSizeConstraint クラスター内の永続ボリューム (PV) の最大ディスク容量を設定します。 中
インフラ ACKPVCConstraint 永続ボリューム要求 (PVC) をデプロイできる名前空間を制限し、PV の最大ディスク容量を設定します。 中
インフラ ACKBlockVolumeTypes 指定された名前空間の Pod が指定されたボリュームタイプを使用することをブロックします。 中
K8s-general ACKAllowedRepos 指定された名前空間の Pod が、指定されたイメージリポジトリからのみイメージをプルするように制限します。 高
K8s-general ACKBlockAutoinjectServiceEnv Pod に enableServiceLinks: false を要求し、Service の IP アドレスが Pod の環境変数に注入されるのを防ぎます。 低
K8s-general ACKBlockAutomountToken Pod に automountServiceAccountToken: false を要求し、サービスアカウントトークンの自動マウントを防ぎます。 高
K8s-general ACKBlockEphemeralContainer 指定された名前空間の Pod がエフェメラルコンテナを起動することをブロックします。 中
K8s-general ACKBlockLoadBalancer 指定された名前空間で LoadBalancer Service がデプロイされることをブロックします。 高
K8s-general ACKBlockNodePort 指定された名前空間で NodePort Service がデプロイされることをブロックします。 高
K8s-general ACKContainerLimits 指定された名前空間の Pod 内のすべてのコンテナにリソースの limits を要求します。 低
K8s-general ACKExternalIPs 指定された名前空間の Service が、ポリシーにリストされている外部 IP アドレスのみを使用するように制限します。 高
K8s-general ACKImageDigests 指定された名前空間の Pod が、指定されたフォーマットのダイジェストを持つイメージを使用することを要求します。 低
K8s-general ACKRequiredLabels 指定された名前空間の Pod が、ポリシーに一致するラベルを持つことを要求します。 低
K8s-general ACKRequiredProbes 指定された名前空間の Pod が、指定されたタイプの readiness プローブと liveness プローブを持つことを要求します。 中
K8s-general ACKCheckNginxPath Ingress リソースの spec.rules[].http.paths[].path にある高リスクの値をブロックします。1.2.1 より前の Ingress-nginx バージョンで有効にします。 高
K8s-general ACKCheckNginxAnnotation Ingress リソースの metadata.annotations にある高リスクの値をブロックします。1.2.1 より前の Ingress-nginx バージョンで有効にします。 高
K8s-general ACKBlockInternetLoadBalancer インターネットに面した LoadBalancer Service の作成をブロックします。 高
K8s-general RatifyVerification Ratify を使用して、指定された名前空間の Pod のイメージ署名またはセキュリティメタデータ (ソフトウェア部品表 (SBOM) など) を検証します。 高
PSP ACKPSPAllowPrivilegeEscalationContainer 指定された名前空間の Pod に allowPrivilegeEscalation 設定を含めることを要求します。 中
PSP ACKPSPAllowedUsers 指定された名前空間の Pod に user、group、supplementalGroups、および fsGroup 設定を含めることを要求します。 中
PSP ACKPSPAppArmor 指定された名前空間の Pod に AppArmor 設定を含めることを要求します。 低
PSP ACKPSPCapabilities 指定された名前空間の Pod に Linux 機能設定を含めることを要求します。 高
PSP ACKPSPFSGroup 指定された名前空間の Pod が、ポリシーに準拠した fsGroup 設定を使用することを要求します。 中
PSP ACKPSPFlexVolumes 指定された名前空間の Pod が、ポリシーにリストされている FlexVolume ドライバーのみを使用するように制限します。 中
PSP ACKPSPForbiddenSysctls 指定された名前空間の Pod が指定された sysctl を使用することをブロックします。 高
PSP ACKPSPHostFilesystem 指定された名前空間の Pod にマウントされた hostPath ボリュームに条件を適用します。 高
PSP ACKPSPHostNamespace 指定された名前空間の Pod がホストの名前空間を共有することをブロックします。 高
PSP ACKPSPHostNetworkingPorts 指定された名前空間の Pod がホストネットワークと指定されたポートを使用できるかどうかを制御します。 高
PSP ACKPSPPrivilegedContainer 指定された名前空間の Pod が特権コンテナを実行することをブロックします。 高
PSP ACKPSPProcMount 指定された名前空間の Pod が、ポリシーで指定された Proc Mount タイプを使用することを要求します。 低
PSP ACKPSPReadOnlyRootFilesystem 指定された名前空間の Pod が読み取り専用のルートファイルシステムで実行されることを要求します。 中
PSP ACKPSPSELinuxV2 指定された名前空間の Pod を、ポリシーにリストされている SELinux オプションに制限します。 低
PSP ACKPSPSeccomp 指定された名前空間の Pod が指定された seccomp プロファイルを使用することを要求します。 低
PSP ACKPSPVolumeTypes 指定された名前空間の Pod が、指定されたタイプのボリュームのみをマウントするように制限します。 中

コンプライアンス

ACKNoEnvVarSecrets

Pod の環境変数で secretKeyRef を使用して Secret を参照することをブロックします。

重要度:中

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKNoEnvVarSecrets
metadata:
  name: no-env-var-secrets
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces: ["test-gatekeeper"]

許可される例 — ボリュームとしてマウントされた Secret:

apiVersion: v1
kind: Pod
metadata:
  name: mypod
  namespace: test-gatekeeper
spec:
  containers:
  - name: mypod
    image: redis
    volumeMounts:
    - name: foo
      mountPath: "/etc/foo"
  volumes:
  - name: foo
    secret:
      secretName: mysecret
      items:
      - key: username
        path: my-group/my-username

許可されない例 — 環境変数で secretKeyRef を介して参照される Secret:

apiVersion: v1
kind: Pod
metadata:
  name: bad
  namespace: test-gatekeeper
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container
    volumeMounts:
    - mountPath: /cache
      name: cache-volume
  volumes:
  - name: cache-volume
    emptyDir: {}

ACKPodsRequireSecurityContext

指定された名前空間の Pod に securityContext を含めることを要求します。

重要度:低

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPodsRequireSecurityContext
metadata:
  name: pods-require-security-context
  annotations:
    description: "Requires that Pods must have a `securityContext` defined."
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces: ["test-gatekeeper"]

許可される例 — Pod レベルの securityContext が存在する:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: test
  namespace: test-gatekeeper
spec:
  securityContext:
    runAsNonRoot: false
  containers:
  - image: test
    name: test
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Never
status: {}

許可されない例 — securityContext が Pod ではなくコンテナにのみ存在する:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test

ACKRestrictNamespaces

指定された名前空間で、指定されたリソースタイプのデプロイメントをブロックします。

重要度:低

パラメーター:

パラメーター タイプ 説明
restrictedNamespaces 配列 一致したリソースタイプをデプロイできない名前空間。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKRestrictNamespaces
metadata:
  name: restrict-default-namespace
  annotations:
    description: "Restricts resources from using the restricted namespace."
spec:
  match:
    kinds:
      - apiGroups: ['']
        kinds: ['Pod']
  parameters:
    restrictedNamespaces:
      - "test-gatekeeper"

許可される例 — 制限されていない名前空間の Pod:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: test
  namespace: non-test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Never
status: {}

許可されない例 — 制限された名前空間の Pod:

apiVersion: v1
kind: Pod
metadata:
  name: bad
  namespace: test-gatekeeper
spec:
  containers:
  - name: mycontainer
    image: redis
  restartPolicy: Never

ACKRestrictRoleBindings

指定された名前空間の RoleBinding が、指定されたロールまたはクラスターロールのみをバインドするように制限します。

重要度:高

パラメーター:

パラメーター タイプ 説明
restrictedRole オブジェクト バインドできないクラスターロールまたはロール。
allowedSubjects 配列 バインディングの受信を許可されたサブジェクト。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKRestrictRoleBindings
metadata:
  name: restrict-clusteradmin-rolebindings
  annotations:
    description: "Restricts use of sensitive role in specific rolebinding."
spec:
  match:
    kinds:
      - apiGroups: ["rbac.authorization.k8s.io"]
        kinds: ["RoleBinding"]
  parameters:
    restrictedRole:
      apiGroup: "rbac.authorization.k8s.io"
      kind: "ClusterRole"
      name: "cluster-admin"
    allowedSubjects:
      - apiGroup: "rbac.authorization.k8s.io"
        kind: "Group"
        name: "system:masters"

許可される例 — バインディングが許可されたサブジェクトを使用している:

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: good-2
  namespace: test-gatekeeper
subjects:
  - kind: Group
    name: 'system:masters'
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io

許可されない例 — バインディングが allowedSubjects にないサブジェクトを使用している:

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: bad-1
  namespace: test-gatekeeper
subjects:
  - kind: ServiceAccount
    name: policy-template-controller
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io

ACKNamespacesDeleteProtection

指定された名前空間の削除を防止します。

重要度:中

バージョン 3.10.0.130-g0e79597d-aliyun 以降の Gatekeeper が必要です。

パラメーター:

パラメーター タイプ 説明
protectionNamespaces 配列 削除できない名前空間の名前。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKNamespacesDeleteProtection
metadata:
  name: namespace-delete-protection
spec:
  match:
    kinds:
      - apiGroups: ['']
        kinds: ['Namespace']
  parameters:
    protectionNamespaces:
      - test-gatekeeper

許可される例 — 保護リストにない名前空間:

apiVersion: v1
kind: Namespace
metadata:
  name: will-delete

不許可 — 保護リスト内の名前空間:

apiVersion: v1
kind: Namespace
metadata:
  name: test-gatekeeper

ACKServicesDeleteProtection

指定された名前空間の Service インスタンスの削除を防止します。

重要度:中

パラメーター:

パラメーター タイプ 説明
protectionServices 配列 削除できない Service インスタンスの名前。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKServicesDeleteProtection
metadata:
  name: service-delete-protection
  annotations:
    description: "Protect to delete specific service."
spec:
  enforcementAction: deny
  match:
    kinds:
      - apiGroups: ['']
        kinds: ['Service']
    namespaces: ["test-gatekeeper"]
  parameters:
    protectionServices:
      - test-svc

許可 — 保護リストにないサービス:

apiVersion: v1
kind: Service
metadata:
  name: good
  namespace: test-gatekeeper

許可されない例 — 保護リストにある Service:

apiVersion: v1
kind: Service
metadata:
  name: test-svc

インフラ

ACKBlockProcessNamespaceSharing

指定された名前空間の Pod が shareProcessNamespace を使用することをブロックします。

重要度:高

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockProcessNamespaceSharing
metadata:
  name: block-share-process-namespace
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces: ["test-gatekeeper"]

許可される例 — shareProcessNamespace が設定されていない:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: test-3
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Never
status: {}

許可されない例 — Pod に shareProcessNamespace: true が設定されている:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad
  namespace: test-gatekeeper
spec:
  shareProcessNamespace: true
  containers:
  - image: test
    name: test
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Never
status: {}

ACKEmptyDirHasSizeLimit

emptyDir ボリュームをマウントする際に sizeLimit を要求します。

重要度:低

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKEmptyDirHasSizeLimit
metadata:
  name: empty-dir-has-sizelimit
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces: ["test-gatekeeper"]

許可される例 — emptyDir ボリュームに sizeLimit がある:

apiVersion: v1
kind: Pod
metadata:
  name: test-1
  namespace: test-gatekeeper
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container
    volumeMounts:
    - mountPath: /cache
      name: cache-volume
  volumes:
  - name: cache-volume
    emptyDir:
      sizeLimit: "10Mi"

許可されない例 — emptyDir ボリュームに sizeLimit がない:

apiVersion: v1
kind: Pod
metadata:
  name: bad
  namespace: test-gatekeeper
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container
    volumeMounts:
    - mountPath: /cache
      name: cache-volume
  volumes:
  - name: cache-volume
    emptyDir: {}

ACKLocalStorageRequireSafeToEvict

指定された名前空間の Pod に cluster-autoscaler.kubernetes.io/safe-to-evict: "true" アノテーションを要求します。Cluster Autoscaler はデフォルトで hostPath または emptyDir ボリュームを持つ Pod をスキップします。このアノテーションにより、スケーリング中のエビクションが可能になります。

重要度:低

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKLocalStorageRequireSafeToEvict
metadata:
  name: local-storage-require-safe-to-evict
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces: ["test-gatekeeper"]

許可される例 — Pod に safe-to-evict アノテーションがある:

apiVersion: v1
kind: Pod
metadata:
  name: test-1
  namespace: test-gatekeeper
  annotations:
    'cluster-autoscaler.kubernetes.io/safe-to-evict': 'true'
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container
    volumeMounts:
    - mountPath: /test-pd
      name: test-volume
  volumes:
  - name: test-volume
    hostPath:
      path: /data
      type: Directory

許可されない例 — Pod がボリュームをマウントしているが、アノテーションがない:

apiVersion: v1
kind: Pod
metadata:
  name: bad
  namespace: test-gatekeeper
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container
    volumeMounts:
    - mountPath: /cache
      name: cache-volume
  volumes:
  - name: cache-volume
    emptyDir: {}

ACKOSSStorageLocationConstraint

指定された名前空間の Pod にマウントできる OSS バケットのリージョンを制御します。

重要度:低

パラメーター:

パラメーター タイプ 説明
mode 文字列 allowlist (デフォルト) は許可リストモードを有効にします。その他の値はブロックリストモードを有効にします。
regions 配列 許可リストまたはブロックリストに含めるリージョン ID。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKOSSStorageLocationConstraint
metadata:
  name: restrict-oss-location
  annotations:
    description: "Restricts location of oss storage in cluster."
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["PersistentVolume", "Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    mode: "allowlist"
    regions:
      - "cn-beijing"

許可 — OSS バケットは許可されたリージョン (cn-beijing) にあります:

apiVersion: v1
kind: Pod
metadata:
  name: pod-oss-csi-good
  namespace: test-gatekeeper
spec:
  containers:
    - name: test
      image: test
  volumes:
    - name: test
      csi:
        driver: ossplugin.csi.alibabacloud.com
        volumeAttributes:
          bucket: "oss"
          url: "oss-cn-beijing.aliyuncs.com"
          otherOpts: "-o max_stat_cache_size=0 -o allow_other"
          path: "/"

許可されない例 — OSS バケットが許可リストにないリージョン (cn-hangzhou) にある:

apiVersion: v1
kind: Pod
metadata:
  name: pod-oss-csi
  namespace: test-gatekeeper
spec:
  containers:
    - name: test
      image: test
  volumes:
    - name: test
      csi:
        driver: ossplugin.csi.alibabacloud.com
        volumeHandle: pv-oss
        nodePublishSecretRef:
          name: oss-secret
          namespace: default
        volumeAttributes:
          bucket: "oss"
          url: "oss-cn-hangzhou.aliyuncs.com"
          otherOpts: "-o max_stat_cache_size=0 -o allow_other"
          path: "/"

ACKPVSizeConstraint

クラスター内の永続ボリューム (PV) の最大ディスク容量を設定します。

重要度:中

パラメーター:

パラメーター タイプ 説明
maxSize 文字列 PV の最大ディスク容量。デフォルト:50Gi。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPVSizeConstraint
metadata:
  name: limit-pv-size
  annotations:
    description: "Limit the pv storage capacity size within a specified maximum amount."
spec:
  enforcementAction: deny
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["PersistentVolume"]
  parameters:
    maxSize: "50Gi"

許可される例 — PV が 50 GiB の制限内で 25 GiB を要求する:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-oss-csi
  labels:
    alicloud-pvname: pv-oss
spec:
  capacity:
    storage: 25Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  csi:
    driver: ossplugin.csi.alibabacloud.com
    volumeHandle: pv-oss
    nodePublishSecretRef:
      name: oss-secret
      namespace: default
    volumeAttributes:
      bucket: "oss"
      url: "oss-cn-beijing.aliyuncs.com"
      otherOpts: "-o max_stat_cache_size=0 -o allow_other"
      path: "/"

許可されない例 — PV が 500 GiB を要求し、制限を超えている:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-oss-csi-bad
  labels:
    alicloud-pvname: pv-oss
spec:
  capacity:
    storage: 500Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  csi:
    driver: ossplugin.csi.alibabacloud.com
    volumeHandle: pv-oss
    nodePublishSecretRef:
      name: oss-secret
      namespace: default
    volumeAttributes:
      bucket: "oss"
      url: "oss-cn-beijing.aliyuncs.com"
      otherOpts: "-o max_stat_cache_size=0 -o allow_other"
      path: "/"

ACKPVCConstraint

永続ボリューム要求 (PVC) をデプロイできる名前空間を制限し、PV の最大ディスク容量を設定します。

重要度:中

パラメーター:

パラメーター タイプ 説明
maxSize 文字列 PV の最大ディスク容量。デフォルト:50Gi。
allowNamespaces 配列 PVC をデプロイできる名前空間。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPVCConstraint
metadata:
  name: limit-pvc-size-and-ns
  annotations:
    description: "Limit the maximum pvc storage capacity size and the namespace whitelists that can be deployed."
spec:
  enforcementAction: deny
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["PersistentVolumeClaim"]
  parameters:
    maxSize: "50Gi"
    allowNamespaces:
      - "test-gatekeeper"

許可される例 — 許可された名前空間で、サイズ制限内の PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: disk-pvc
  namespace: test-gatekeeper
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi

許可されない例 — PVC がサイズ制限を超えている、または allowNamespaces にない名前空間にある:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: bad-disk-pvc
  namespace: test-gatekeeper
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 200Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: bad-namespace-pvc
  namespace: test-gatekeeper-bad
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi

ACKBlockVolumeTypes

指定された名前空間の Pod が指定されたボリュームタイプを使用することをブロックします。

重要度:中

パラメーター:

パラメーター タイプ 説明
volumes 配列 Pod が使用を許可されていないボリュームタイプ。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockVolumeTypes
metadata:
  name: block-volume-types
spec:
  enforcementAction: deny
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces: ["test-gatekeeper"]
  parameters:
    volumes:
      - "gitRepo"

許可される例 — Pod が emptyDir ボリューム (ブロックされていない) を使用する:

apiVersion: v1
kind: Pod
metadata:
  name: use-empty-dir
  namespace: test-gatekeeper
spec:
  containers:
    - name: test
      image: test
  volumes:
  - name: emptydir-volume
    emptyDir: {}

許可されない例 — Pod が gitRepo ボリューム (ブロックされている) を使用する:

apiVersion: v1
kind: Pod
metadata:
  name: use-git-repo
  namespace: test-gatekeeper
spec:
  containers:
    - name: test
      image: test
  volumes:
  - name: git-volume
    gitRepo:
      repository: "git@***:***/my-git-repository.git"
      revision: "22f1d8406d464b0c08***"

K8s-general

ACKAllowedRepos

指定された名前空間の Pod が、指定されたイメージリポジトリからのみイメージをプルするように制限します。

重要度:高

パラメーター:

パラメーター タイプ 説明
repos 配列 Pod がイメージをプルすることを許可されているイメージリポジトリ。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKAllowedRepos
metadata:
  name: allowed-repos
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    repos:
      - "registry-vpc.cn-hangzhou.aliyuncs.com/acs/"
      - "registry.cn-hangzhou.aliyuncs.com/acs/"

許可される例 — 許可されたリポジトリからプルされたイメージ:

apiVersion: v1
kind: Pod
metadata:
  name: pod-01
  namespace: test-gatekeeper
spec:
  containers:
  - image: registry.cn-hangzhou.aliyuncs.com/acs/test-webserver
    name: test-container-1
  initContainers:
  - image: registry.cn-hangzhou.aliyuncs.com/acs/test-webserver
    name: test-container

許可されない例 — 許可リストにないリポジトリからプルされたイメージ:

apiVersion: v1
kind: Pod
metadata:
  name: bad-1
  namespace: test-gatekeeper
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container

ACKBlockAutoinjectServiceEnv

指定された名前空間の Pod に enableServiceLinks: false を要求し、Service の IP アドレスが Pod の環境変数に注入されるのを防ぎます。

重要度:低

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockAutoinjectServiceEnv
metadata:
  name: block-auto-inject-service-env
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"

許可される例 — enableServiceLinks: false が設定されている:

apiVersion: v1
kind: Pod
metadata:
  name: pod-0
  namespace: test-gatekeeper
spec:
  enableServiceLinks: false
  containers:
  - image: openpolicyagent/test-webserver:1.0
    name: test-container

許可されない例 — enableServiceLinks が設定されていない:

apiVersion: v1
kind: Pod
metadata:
  name: bad-1
  namespace: test-gatekeeper
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container

ACKBlockAutomountToken

指定された名前空間の Pod に automountServiceAccountToken: false を要求し、サービスアカウントトークンの自動マウントを防ぎます。

重要度:高

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockAutomountToken
metadata:
  name: block-auto-mount-service-account-token
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"

許可される例 — automountServiceAccountToken: false が設定されている:

apiVersion: v1
kind: Pod
metadata:
  name: pod-0
  namespace: test-gatekeeper
spec:
  automountServiceAccountToken: false
  containers:
  - image: openpolicyagent/test-webserver:v1.0
    name: test-container

許可されない例 — automountServiceAccountToken が false に設定されていない:

apiVersion: v1
kind: Pod
metadata:
  name: bad-1
  namespace: test-gatekeeper
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container

ACKBlockEphemeralContainer

指定された名前空間の Pod がエフェメラルコンテナを起動することをブロックします。

重要度:中

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockEphemeralContainer
metadata:
  name: block-ephemeral-container
spec:
  enforcementAction: deny
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"

許可される例 — エフェメラルコンテナがない:

apiVersion: v1
kind: Pod
metadata:
  name: good-1
  namespace: test-gatekeeper
spec:
  containers:
  - name: mycontainer
    image: redis

許可されない例 — Pod にエフェメラルコンテナが含まれている:

apiVersion: v1
kind: Pod
metadata:
  name: bad-1
  namespace: non-test-gatekeeper
spec:
  containers:
  - name: mycontainer
    image: redis
  ephemeralContainers:
    - name: test
      image: test

ACKBlockLoadBalancer

指定された名前空間で LoadBalancer Service がデプロイされることをブロックします。

重要度:高

パラメーター:

パラメーター タイプ 説明
restrictedNamespaces 配列 LoadBalancer Service をデプロイできない名前空間。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockLoadBalancer
metadata:
  name: block-load-balancer
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Service"]
    namespaces:
      - "test-gatekeeper"

許可される例 — LoadBalancer タイプのない Service:

apiVersion: v1
kind: Service
metadata:
  name: my-service-1
  namespace: test-gatekeeper
spec:
  selector:
    app: MyApp
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 9376

許可されない例 — タイプ LoadBalancer の Service:

apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: test-gatekeeper
spec:
  type: LoadBalancer
  selector:
    app: MyApp
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 9376

ACKBlockNodePort

指定された名前空間で NodePort Service がデプロイされることをブロックします。

重要度:高

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockNodePort
metadata:
  name: block-node-port
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Service"]
    namespaces:
      - "test-gatekeeper"

許可される例 — NodePort タイプのない Service:

apiVersion: v1
kind: Service
metadata:
  name: my-service-1
  namespace: test-gatekeeper
spec:
  selector:
    app: MyApp
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 9376

許可されない例 — タイプ NodePort の Service:

apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: test-gatekeeper
spec:
  type: NodePort
  selector:
    app: MyApp
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 9376

ACKContainerLimits

指定された名前空間の Pod 内のすべてのコンテナにリソースの limits を要求します。

重要度:低

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKContainerLimits
metadata:
  name: container-must-have-limits
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    cpu: "1000m"
    memory: "1Gi"

許可される例 — コンテナにリソース制限が設定されている:

apiVersion: v1
kind: Pod
metadata:
  name: pod-1
  namespace: test-gatekeeper
spec:
  containers:
  - image: registry.cn-hangzhou.aliyuncs.com/acs/signed   # 有効な署名付きのイメージ
    name: test-container

許可されない例 — コンテナの制限がポリシーの最大値を超えている:

apiVersion: v1
kind: Pod
metadata:
  name: pod-2
  namespace: non-test-gatekeeper
spec:
  containers:
  - image: openpolicyagent/test-webserver
    name: test-container
    resources:
      limits:
        memory: "100Gi"
        cpu: "2000m"

ACKExternalIPs

指定された名前空間の Service が、ポリシーにリストされている外部 IP アドレスのみを使用するように制限します。

重要度:高

パラメーター:

パラメーター タイプ 説明
allowedIPs 配列 Service が使用を許可されている外部 IP アドレス。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKExternalIPs
metadata:
  name: external-ips
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Service"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    allowedIPs:
      - "192.168.0.5"

許可される例 — Service に外部 IP がない:

apiVersion: v1
kind: Service
metadata:
  name: my-service-3
  namespace: test-gatekeeper
spec:
  selector:
    app: MyApp
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 9376

許可されない例 — Service が allowedIPs にない外部 IP を使用している:

apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: test-gatekeeper
spec:
  selector:
    app: MyApp
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 9376
  externalIPs:
    - 80.11.XX.XX

ACKImageDigests

指定された名前空間の Pod が、指定されたフォーマットのダイジェストを持つイメージを使用することを要求します。

重要度:低

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKImageDigests
metadata:
  name: container-image-must-have-digest
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"

許可される例 — イメージ参照にダイジェストが含まれている:

apiVersion: v1
kind: Pod
metadata:
  name: pod-0
  namespace: test-gatekeeper
spec:
  containers:
  - image: openpolicyagent/test-webserver@sha256:12e469267d21d66ac9dcae33a4d3d202ccb2591869270b95d0aad7516c7d075b
    name: test-container

許可されない例 — イメージ参照にダイジェストがない:

apiVersion: v1
kind: Pod
metadata:
  name: bad-1
  namespace: test-gatekeeper
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container
  initContainers:
  - image: k8s.gcr.io/test-webserver
    name: test-container2

ACKRequiredLabels

指定された名前空間の Pod が、ポリシーに一致するラベルを持つことを要求します。

重要度:低

パラメーター:

パラメーター タイプ 説明
allowedRegex 文字列 正規表現として表現される必須のラベル値。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKRequiredLabels
metadata:
  name: must-have-label-test
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    labels:
      - key: test
        allowedRegex: "^test.*$"

許可される例 — Pod に必須の正規表現に一致するラベルがある:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  name: test
  namespace: test-gatekeeper
  labels:
    'test': 'test_233'
spec:
  containers:
  - name: mycontainer
    image: redis

許可されない例 — ラベル値が必須の正規表現に一致しない:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  name: bad2
  namespace: test-gatekeeper
  labels:
    'test': '233'
spec:
  containers:
  - name: mycontainer
    image: redis

ACKRequiredProbes

指定された名前空間の Pod が、指定されたタイプの readiness プローブと liveness プローブを持つことを要求します。

重要度:中

パラメーター:

パラメーター タイプ 説明
probes 配列 必須のプローブタイプ。有効な値:readinessProbe、livenessProbe。
probeTypes 配列 必須のプローブ実装タイプ。有効な値:tcpSocket、httpGet、exec。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKRequiredProbes
metadata:
  name: must-have-probes
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    probes: ["readinessProbe", "livenessProbe"]
    probeTypes: ["tcpSocket", "httpGet", "exec"]

許可される例 — コンテナに readiness プローブと liveness プローブの両方がある:

apiVersion: v1
kind: Pod
metadata:
  name: p4
  namespace: test-gatekeeper
spec:
  containers:
  - name: liveness
    image: k8s.gcr.io/busybox
    readinessProbe:
      exec:
        command:
          - cat
          - /tmp/healthy
      initialDelaySeconds: 5
      periodSeconds: 5
    livenessProbe:
      exec:
        command:
          - cat
          - /tmp/healthy
      initialDelaySeconds: 5
      periodSeconds: 5

許可されない例 — コンテナにプローブがない:

apiVersion: v1
kind: Pod
metadata:
  name: p1
  namespace: test-gatekeeper
spec:
  containers:
  - name: liveness
    image: k8s.gcr.io/busybox

ACKCheckNginxPath

Ingress リソースの spec.rules[].http.paths[].path にある高リスクの値をブロックします。1.2.1 より前の Ingress-nginx バージョンで有効にします。

重要度:高

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKCheckNginxPath
metadata:
  name: block-nginx-path
spec:
  enforcementAction: deny
  match:
    kinds:
      - apiGroups: ["extensions", "networking.k8s.io"]
        kinds: ["Ingress"]
    namespaces:
      - "test-gatekeeper"

許可される例 — パスに安全な値が含まれている:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: good-paths
  namespace: test-gatekeeper
spec:
  rules:
    - host: cafe.example.com
      http:
        paths:
          - path: /tea
            pathType: Prefix
            backend:
              service:
                name: tea-svc
                port:
                  number: 80
          - path: /coffee
            pathType: Prefix
            backend:
              service:
                name: coffee-svc
                port:
                  number: 80

許可されない例 — パスに高リスクの値が含まれている:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: bad-path-secrets
  namespace: test-gatekeeper
spec:
  rules:
    - host: cafe.example.com
      http:
        paths:
          - path: /var/run/secrets
            pathType: Prefix
            backend:
              service:
                name: tea-svc
                port:
                  number: 80

ACKCheckNginxAnnotation

Ingress リソースの metadata.annotations にある高リスクの値をブロックします。1.2.1 より前の Ingress-nginx バージョンで有効にします。

重要度:高

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKCheckNginxAnnotation
metadata:
  name: block-nginx-annotation
spec:
  match:
    kinds:
      - apiGroups: ["extensions", "networking.k8s.io"]
        kinds: ["Ingress"]
    namespaces:
      - "test-gatekeeper"

許可される例 — アノテーションに安全な値が含まれている:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: good-annotations
  namespace: test-gatekeeper
  annotations:
    nginx.org/good: "value"
spec:
  rules:
    - host: cafe.example.com
      http:
        paths:
          - path: /tea
            pathType: Prefix
            backend:
              service:
                name: tea-svc
                port:
                  number: 80
          - path: /coffee
            pathType: Prefix
            backend:
              service:
                name: coffee-svc
                port:
                  number: 80

許可されない例 — アノテーションに高リスクの値が含まれている:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: var-run-secrets
  namespace: test-gatekeeper
  annotations:
    nginx.org/bad: "/var/run/secrets"
spec:
  rules:
    - host: cafe.example.com
      http:
        paths:
          - path: /tea
            pathType: Prefix
            backend:
              service:
                name: tea-svc
                port:
                  number: 80
          - path: /coffee
            pathType: Prefix
            backend:
              service:
                name: coffee-svc
                port:
                  number: 80

ACKBlockInternetLoadBalancer

インターネットに面した LoadBalancer Service の作成をブロックします。

重要度:高

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockInternetLoadBalancer
metadata:
  name: block-internet-load-balancer
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Service"]
    namespaces: ["test-gatekeeper"]

許可される例 — LoadBalancer Service がイントラネットアドレスタイプを使用している:

apiVersion: v1
kind: Service
metadata:
  name: my-service
  namespace: non-test-gatekeeper
  annotations:
    'service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type': 'intranet'
spec:
  selector:
    app: MyApp
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 9376
  type: LoadBalancer

許可されない例 — LoadBalancer Service がインターネットアドレスタイプを使用している:

apiVersion: v1
kind: Service
metadata:
  name: bad-service-2
  namespace: test-gatekeeper
  annotations:
    'service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type': 'internet'
spec:
  type: LoadBalancer
  selector:
    app: MyApp
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 9376

RatifyVerification

Ratify を使用して、指定された名前空間の Pod のイメージ署名またはセキュリティメタデータ (ソフトウェア部品表 (SBOM) など) を検証します。このポリシーを有効にする前に、クラスターの Marketplace から Ratify をインストールしてください。

重要度:高

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: RatifyVerification
metadata:
  name: ratify-constraint
spec:
  enforcementAction: deny
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces: ["default"]

許可 — イメージの署名は有効です:

apiVersion: v1
kind: Pod
metadata:
  name: pod-1
  namespace: test-gatekeeper
spec:
  containers:
  - image: registry.cn-hangzhou.aliyuncs.com/acs/signed   # Image with a valid signature
    name: test-container

許可されない例 — イメージに有効な署名がない:

apiVersion: v1
kind: Pod
metadata:
  name: bad-1
  namespace: test-gatekeeper
spec:
  containers:
  - image: registry.cn-hangzhou.aliyuncs.com/acs/unsigned   # Image without a valid signature
    name: test-container

PSP

これらのポリシーは、Kubernetes の Pod セキュリティポリシー (PSP) をそのまま置き換えることができます。

ACKPSPAllowPrivilegeEscalationContainer

指定された名前空間の Pod に allowPrivilegeEscalation 設定を含めることを要求します。

重要度:中

パラメーター:なし

例

制約:

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

許可される例 — すべてのコンテナに allowPrivilegeEscalation: false が設定されている:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    securityContext:
      allowPrivilegeEscalation: false
  initContainers:
    - image: test
      name: test2
      securityContext:
        allowPrivilegeEscalation: false

許可されない例 — allowPrivilegeEscalation が設定されていない:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test

ACKPSPAllowedUsers

指定された名前空間の Pod に user、group、supplementalGroups、および fsGroup 設定を含めることを要求します。

重要度:中

パラメーター:

パラメーター タイプ 説明
runAsUser オブジェクト Kubernetes PSP のセマンティクスに従ったユーザー構成。詳細については、「Pod セキュリティポリシー」をご参照ください。
runAsGroup オブジェクト Kubernetes PSP のセマンティクスに従ったグループ構成。詳細については、「Pod セキュリティポリシー」をご参照ください。
supplementalGroups オブジェクト Kubernetes PSP のセマンティクスに従った補助グループ構成。詳細については、「Pod セキュリティポリシー」をご参照ください。
fsGroup オブジェクト Kubernetes PSP のセマンティクスに従った fsGroup 構成。詳細については、「Pod セキュリティポリシー」をご参照ください。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPAllowedUsers
metadata:
  name: psp-pods-allowed-user-ranges
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    runAsUser:
      rule: MustRunAs # MustRunAsNonRoot # RunAsAny
      ranges:
        - min: 100
          max: 200
    runAsGroup:
      rule: MustRunAs # MayRunAs # RunAsAny
      ranges:
        - min: 100
          max: 200
    supplementalGroups:
      rule: MustRunAs # MayRunAs # RunAsAny
      ranges:
        - min: 100
          max: 200
    fsGroup:
      rule: MustRunAs # MayRunAs # RunAsAny
      ranges:
        - min: 100
          max: 200

許可される例 — すべてのユーザー/グループ設定が許可された範囲内にある:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good2
  namespace: test-gatekeeper
spec:
  securityContext:
    fsGroup: 150
    supplementalGroups:
      - 150
  containers:
  - image: test
    name: test
    securityContext:
      runAsUser: 150
      runAsGroup: 150

許可されない例 — ユーザー/グループ設定が欠落している:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test

ACKPSPAppArmor

指定された名前空間の Pod に AppArmor 設定を含めることを要求します。

重要度:低

パラメーター:

パラメーター タイプ 説明
allowedProfiles 配列 Pod が使用を許可されている AppArmor プロファイル。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPAppArmor
metadata:
  name: psp-apparmor
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    allowedProfiles:
      - runtime/default

許可される例 — すべてのコンテナに AppArmor アノテーションが存在する:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good
  namespace: test-gatekeeper
  annotations:
    'container.apparmor.security.beta.kubernetes.io/test': 'runtime/default'
    'container.apparmor.security.beta.kubernetes.io/test2': 'runtime/default'
spec:
  containers:
  - image: test
    name: test
  initContainers:
  - image: test
    name: test2

許可されない例 — AppArmor アノテーションがない:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test

ACKPSPCapabilities

指定された名前空間の Pod に Linux 機能設定を含めることを要求します。

重要度:高

パラメーター:

パラメーター タイプ 説明
allowedCapabilities 配列 コンテナが追加を許可されている Linux 機能。
requiredDropCapabilities 配列 コンテナがドロップしなければならない Linux 機能。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPCapabilities
metadata:
  name: psp-capabilities
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    allowedCapabilities: ["CHOWN"]
    requiredDropCapabilities: ["NET_ADMIN", "SYS_ADMIN", "NET_RAW"]

許可される例 — 許可された機能のみが追加され、必須の機能がドロップされている:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good-4
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    securityContext:
      capabilities:
        add:
          - CHOWN
        drop:
         - "NET_ADMIN"
         - "SYS_ADMIN"
         - "NET_RAW"

許可されない例 — 機能の構成がない:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad-1
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test

ACKPSPFlexVolumes

指定された名前空間の Pod が、ポリシーにリストされている FlexVolume ドライバーのみを使用するように制限します。

重要度:中

パラメーター:

パラメーター タイプ 説明
allowedFlexVolumes 配列 Pod が使用を許可されている FlexVolume ドライバー。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPFlexVolumes
metadata:
  name: psp-flexvolume-drivers
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod", "PersistentVolume"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    allowedFlexVolumes:
      - driver: "alicloud/disk"
      - driver: "alicloud/nas"
      - driver: "alicloud/oss"
      - driver: "alicloud/cpfs"

許可される例 — FlexVolume ドライバーが許可リストにある:

apiVersion: v1
kind: Pod
metadata:
  name: pv-nas
  namespace: test-gatekeeper
spec:
  containers:
    - name: test
      image: test
  volumes:
    - name: test
      flexVolume:
        driver: "alicloud/nas"

許可されない例 — FlexVolume ドライバーが許可リストにない:

apiVersion: v1
kind: Pod
metadata:
  name: pv-oss-flexvolume
  namespace: test-gatekeeper
spec:
  containers:
    - name: test
      image: test
  volumes:
    - name: test
      flexVolume:
        driver: "alicloud/ossxx"

ACKPSPForbiddenSysctls

指定された名前空間の Pod が指定された sysctl を使用することをブロックします。

重要度:高

パラメーター:

パラメーター タイプ 説明
forbiddenSysctls 配列 Pod が使用を許可されていない sysctl。* を使用してすべての sysctl をブロックします。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPForbiddenSysctls
metadata:
  name: psp-forbidden-sysctls
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    forbiddenSysctls:
      # - "*" # Use * to forbid all sysctls
      - "kernel.*"

許可される例 — sysctl がブロックリストにない:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good-2
  namespace: test-gatekeeper
spec:
  securityContext:
    sysctls:
      - name: 'net.ipv4.tcp_syncookies'
        value: "65536"
  containers:
  - image: test
    name: test

許可されない例 — sysctl がブロックリストのパターンに一致する:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad-1
  namespace: test-gatekeeper
spec:
  securityContext:
    sysctls:
      - name: 'kernel.shm_rmid_forced'
        value: '1024'
  containers:
  - image: test
    name: test

ACKPSPFSGroup

指定された名前空間の Pod が、ポリシーに準拠した fsGroup 設定を使用することを要求します。

重要度:中

パラメーター:

パラメーター タイプ 説明
rule 文字列 fsGroup ルール。有効な値:MustRunAs、MayRunAs、RunAsAny。詳細については、「ボリュームとファイルシステム」をご参照ください。
ranges オブジェクト 有効な fsGroup ID の範囲。min で最小値を、max で最大値を設定します。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPFSGroup
metadata:
  name: psp-fsgroup
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    rule: "MayRunAs" # "MustRunAs" or "RunAsAny"
    ranges:
      - min: 1
        max: 1000

許可される例 — fsGroup が許可された範囲内にある:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good
  namespace: test-gatekeeper
spec:
  securityContext:
    fsGroup: 100
  containers:
  - image: test
    name: test

許可されない例 — fsGroup 0 が許可された範囲外にある:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad-1
  namespace: non-test-gatekeeper
spec:
  securityContext:
    fsGroup: 0
  shareProcessNamespace: true
  containers:
  - image: test
    name: test

ACKPSPHostFilesystem

指定された名前空間の Pod にマウントされた hostPath ボリュームに条件を適用します。

重要度:高

パラメーター:

パラメーター タイプ 説明
allowedHostPaths オブジェクト Pod がマウントを許可されている hostPath ボリューム。
readOnly boolean ボリュームが読み取り専用としてマウントされなければならないかどうか。
pathPrefix 文字列 hostPath ボリュームが一致しなければならないパスプレフィックス。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPHostFilesystem
metadata:
  name: psp-host-filesystem
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    allowedHostPaths:
      - readOnly: true
        pathPrefix: "/foo"

許可される例 — hostPath ボリュームが許可されたプレフィックスを使用し、読み取り専用でマウントされている:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good1
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    securityContext:
      readOnlyRootFilesystem: true

許可されない例 — hostPath ボリュームが許可されたプレフィックスに一致しないパスを使用している:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
  volumes:
  - name: test-volume
    hostPath:
      path: /data
      type: File

ACKPSPHostNamespace

指定された名前空間の Pod がホストの名前空間を共有することをブロックします。

重要度:高

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPHostNamespace
metadata:
  name: psp-host-namespace
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"

許可される例 — Pod がホストの名前空間を共有していない:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Never
status: {}

許可されない例 — Pod がホストの PID 名前空間を共有している:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad
  namespace: test-gatekeeper
spec:
  hostPID: true
  containers:
  - image: test
    name: test
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Never
status: {}

ACKPSPHostNetworkingPorts

指定された名前空間の Pod がホストネットワークと指定されたポートを使用できるかどうかを制御します。

重要度:高

パラメーター:

パラメーター タイプ 説明
hostNetwork boolean Pod がホストネットワークを使用することを許可されているかどうか。
min integer 許可される最小のホストポート番号。
max integer 許可される最大のホストポート番号。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPHostNetworkingPorts
metadata:
  name: psp-host-network-ports
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    hostNetwork: true
    min: 80
    max: 9000

許可される例 — ホストポートが許可された範囲内にある:

apiVersion: v1
kind: Pod
metadata:
  name: good-2
  namespace: test-gatekeeper
spec:
  hostNetwork: true
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container
    ports:
      - hostPort: 80
        containerPort: 80
  initContainers:
    - image: k8s.gcr.io/test-webserver
      name: test-container2
      ports:
        - hostPort: 8080
          containerPort: 8080

許可されない例 — ホストポート 22 が許可された範囲外にある:

apiVersion: v1
kind: Pod
metadata:
  name: bad-1
  namespace: non-test-gatekeeper
spec:
  hostNetwork: true
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container
    ports:
      - hostPort: 22
        containerPort: 22

ACKPSPPrivilegedContainer

指定された名前空間の Pod が特権コンテナを実行することをブロックします。

重要度:高

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPPrivilegedContainer
metadata:
  name: psp-privileged-container
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"

許可される例 — 特権モードが設定されていない:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good1
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test

許可されない例 — コンテナに privileged: true が設定されている:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    securityContext:
      privileged: true
  dnsPolicy: ClusterFirst
  restartPolicy: Never

ACKPSPProcMount

指定された名前空間の Pod が、ポリシーで指定された Proc Mount タイプを使用することを要求します。

重要度:低

パラメーター:

パラメーター タイプ 説明
procMount 文字列 必須の Proc Mount タイプ。Default は /proc のマウントをブロックします。Unmasked はそれを許可します。詳細については、「AllowedProcMountTypes」をご参照ください。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPProcMount
metadata:
  name: psp-proc-mount
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    procMount: Default  # Default or Unmasked

許可される例 — procMount: Default がポリシーに一致する:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good1
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    securityContext:
      procMount: "Default"

許可されない例 — procMount: Unmasked がポリシーに一致しない:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad3
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    securityContext:
      procMount: "Unmasked"
  initContainers:
  - image: test
    name: test2

ACKPSPReadOnlyRootFilesystem

指定された名前空間の Pod が読み取り専用のルートファイルシステムで実行されることを要求します。

重要度:中

パラメーター:なし

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPReadOnlyRootFilesystem
metadata:
  name: psp-readonlyrootfilesystem
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"

許可される例 — readOnlyRootFilesystem: true が設定されている:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good1
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    securityContext:
      readOnlyRootFilesystem: true

許可されない例 — readOnlyRootFilesystem: false:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad2
  namespace: non-test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    securityContext:
      readOnlyRootFilesystem: false
  initContainers:
  - image: test
    name: test2

ACKPSPSELinuxV2

指定された名前空間の Pod を、ポリシーにリストされている SELinux オプションに制限します。

重要度:低

パラメーター:

パラメーター タイプ 説明
allowedSELinuxOptions オブジェクト Pod が使用を許可されている SELinux オプション。詳細については、「SELinuxOptions v1 core」をご参照ください。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPSELinuxV2
metadata:
  name: psp-selinux-v2
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    allowedSELinuxOptions:
      - level: s0:c123,c456
        role: object_r
        type: svirt_sandbox_file_t
        user: system_u

許可される例 — SELinux オプションが許可リストに一致する:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good
  namespace: test-gatekeeper
spec:
  securityContext:
    seLinuxOptions:
      level: "s0:c123,c456"
  containers:
  - image: test
    name: test

許可されない例 — SELinux レベルが許可リストにない:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    securityContext:
      seLinuxOptions:
        level: "s0:c123,c455"

ACKPSPSeccomp

指定された名前空間の Pod が指定された seccomp プロファイルを使用することを要求します。

重要度:低

パラメーター:

パラメーター タイプ 説明
allowedProfileTypes 配列 許可された seccomp プロファイルタイプ。
allowedProfiles 配列 許可された seccomp プロファイル名。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPSeccomp
metadata:
  name: psp-seccomp
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    allowedProfileTypes:
      # - Unconfined
      - RuntimeDefault
      - Localhost
    allowedProfiles:
      - runtime/default
      - docker/default
      - localhost/profiles/audit.json

許可される例 — seccomp プロファイルが許可されたタイプと名前に一致する:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: good
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
    securityContext:
      seccompProfile:
        type: Localhost
        localhostProfile: profiles/audit.json
  initContainers:
  - image: test
    name: test2
    securityContext:
      seccompProfile:
        type: Localhost
        localhostProfile: profiles/audit.json

許可されない例 — seccomp プロファイルが設定されていない:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test

ACKPSPVolumeTypes

指定された名前空間の Pod が、指定されたタイプのボリュームのみをマウントするように制限します。

重要度:中

パラメーター:

パラメーター タイプ 説明
volumes 配列 Pod が使用を許可されているボリュームタイプ。* を使用してすべてのボリュームタイプを許可します。

例

制約:

apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPVolumeTypes
metadata:
  name: psp-volume-types
spec:
  match:
    kinds:
      - apiGroups: [""]
        kinds: ["Pod"]
    namespaces:
      - "test-gatekeeper"
  parameters:
    volumes:
      # - "*" # Use * to allow all volume types
      - configMap
      # - emptyDir
      - projected
      - secret
      - downwardAPI
      - persistentVolumeClaim
      # - hostPath # Required for allowedHostPaths
      - flexVolume # Required for allowedFlexVolumes

許可される例 — Pod が FlexVolume ドライバー (許可リスト内) を使用する:

apiVersion: v1
kind: Pod
metadata:
  name: pv-oss
  namespace: test-gatekeeper
spec:
  containers:
    - name: test
      image: test
  volumes:
    - name: test
      flexVolume:
        driver: "alicloud/oss"

許可されない例 — Pod が hostPath ボリューム (許可リストにない) を使用する:

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: test
  name: bad-1
  namespace: test-gatekeeper
spec:
  containers:
  - image: test
    name: test
  volumes:
  - name: test-volume
    hostPath:
      path: /data