ACK ポリシー管理では、Pod のデプロイメントおよび更新要求に対してセキュリティ制約を適用する組み込みのルールライブラリを提供します。各ルールは、constraints.gatekeeper.sh/v1beta1 リソースとしてデプロイされる Gatekeeper 制約テンプレートです。本ページでは、重大度、パラメーター、設定例を含め、利用可能なすべてのポリシーをカテゴリ別に一覧表示します。
適用モード
各制約では、enforcementAction フィールドを使用して違反時の処理方法を制御します。
| モード | 動作 | 使用タイミング |
|---|---|---|
deny | 要求をブロックします。準拠していないリソースは作成・更新できません。 | 既存のワークロードに影響を与えないことが確認済みの場合に、本番環境で使用します。 |
warn | 要求を許可しますが、警告メッセージを返します。 | ポリシーを deny に切り替える前に、準拠状況を監査する場合に使用します。 |
ポリシーの適用前に準拠状況を監査するには、まず enforcementAction: warn を指定して制約をデプロイし、違反が検出されないことを確認したうえで、deny に切り替えます。
ポリシーカテゴリ
| カテゴリ | 説明 |
|---|---|
| コンプライアンス | Alibaba Cloud K8s 強化などのコンプライアンス基準に基づくセキュリティルールです。 |
| インフラ | クラウドインフラストラクチャリソースのセキュリティを保護するルールです。 |
| K8s-general | Kubernetes クラスター内で機密性の高いリソース構成を制約・標準化するルールです。 |
| PSP | Kubernetes Pod Security Policies (PSP) を置き換えるポリシーです。ACK ポリシー管理における元の PSP 機能と同等のセキュリティ制約を提供します。 |
| FinOps | コストガバナンスのためのポリシールールです。 |
ポリシールールライブラリ
コンプライアンス
| ポリシー | 説明 | 重大度 |
|---|---|---|
ACKNoEnvVarSecrets | secretKeyRef を使用して、アプリケーションポッドへのシークレットの環境変数マウントを制限します。 | 中間 |
ACKPodsRequireSecurityContext | Pod 内のすべてのコンテナに securityContext フィールドの設定を必須とします。 | 低 |
ACKRestrictNamespaces | クラスター内の指定された名前空間へのリソースデプロイメントを制限します。 | 低 |
ACKRestrictRoleBindings | 指定された名前空間内の RoleBinding が、指定された範囲の Role または ClusterRole のみを使用することを制限します。 | 高 |
ACKNamespacesDeleteProtection | 指定された名前空間の誤った削除を防止します。 | 中間 |
ACKServicesDeleteProtection | 名前空間内の Service インスタンスの誤った削除を防止します。 | 中間 |
ACKProtectBoundingPV | バインド状態にある永続ボリューム (PV) の削除を防止します。 | 高 |
ACKBlockNodeDelete | カスタムタグを持つノードの削除を防止します。 | 高 |
ACKResourceDeletionProtection | カスタムタグを持つリソース(Service、Namespace、Ingress を含む)の削除を防止します。 | 高 |
ACKProtectCoreDNS | kube-system 名前空間内の CoreDNS 関連リソースの削除を防止します。 | 高 |
ACKBlockCrdDeletion | 関連するカスタムリソース (CR) がまだ存在する CustomResourceDefinitions (CRD) の削除を防止します。 | 中間 |
インフラ
| ポリシー | 説明 | 重大度 |
|---|---|---|
ACKBlockProcessNamespaceSharing | クラスター内の指定された範囲でデプロイされるアプリケーションにおける shareProcessNamespace の使用を制限します。 | 高 |
ACKEmptyDirHasSizeLimit | emptyDir 型ボリュームが sizeLimit を指定することを必須とします。 | 低 |
ACKLocalStorageRequireSafeToEvict | 指定された範囲でデプロイされる Pod に "cluster-autoscaler.kubernetes.io/safe-to-evict": "true" アノテーションの設定を必須とします。 | 低 |
ACKOSSStorageLocationConstraint | 指定された名前空間でのデプロイメントを、指定されたリージョンの Alibaba Cloud Object Storage Service (OSS) 永続ボリューム (PV) のみで使用することに制限します。 | 低 |
ACKPVSizeConstraint | クラスター内で作成される PV インスタンスに対する最大ディスク容量の要求を制限します。 | 中間 |
ACKPVCConstraint | 永続ボリューム要求 (PVC) インスタンスのデプロイメントを、ホワイトリストに登録された名前空間に限定し、要求可能な最大ディスク容量を制限します。 | 中間 |
ACKBlockVolumeTypes | 使用可能なボリュームタイプを制限します。 | 中間 |
ASMSidecarInjectionEnforced | Pod に Alibaba Cloud Service Mesh (ASM) サイドカーの注入を必須とします。 | 高 |
K8s-general
| ポリシー | 説明 | 重大度 |
|---|---|---|
ACKAllowedRepos | 指定された範囲でデプロイされるアプリケーションポッドが、許可されたリポジトリからのみイメージをプルすることを必須とします。 | 高 |
ACKBlockAutoinjectServiceEnv | サービス環境変数の自動インジェクションを制限します。 | 低 |
ACKBlockAutomountToken | サービスアカウントトークンの自動マウントを制限します。 | 高 |
ACKBlockEphemeralContainer | エフェメラルコンテナの使用を制限します。 | 中間 |
ACKBlockLoadBalancer | LoadBalancer 型 Service の作成を制限します。 | 高 |
ACKBlockNodePort | NodePort 型 Service の作成を制限します。 | 高 |
ACKContainerLimits | コンテナがリソース使用制限を指定することを必須とします。 | 低 |
ACKExternalIPs | external IPs の使用を制限します。 | 高 |
ACKImageDigests | コンテナイメージがイメージダイジェスト形式で指定されることを必須とします。 | 低 |
ACKRequiredLabels | リソースが指定されたラベルを持つことを必須とします。 | 低 |
ACKRequiredProbes | コンテナが readiness プローブおよび liveness プローブの設定を持つことを必須とします。 | 中間 |
ACKCheckNginxPath | nginx Ingress の path 構成を検証します。 | 高 |
ACKCheckNginxAnnotation | nginx Ingress のアノテーション構成を検証します。 | 高 |
ACKBlockInternetLoadBalancer | インターネット向けロードバランサーの作成を制限します。 | 高 |
RatifyVerification | Ratify を使用したコンテナイメージの署名検証を必須とします。 | 高 |
PSP
| ポリシー | 説明 | 重大度 |
|---|---|---|
ACKPSPAllowedUsers | コンテナが実行されるユーザーおよびグループ ID を制限します。 | 中間 |
ACKPSPAllowPrivilegeEscalationContainer | コンテナにおける権限昇格を制限します。 | 中間 |
ACKPSPAppArmor | コンテナが使用する AppArmor プロファイルを制限します。 | 低 |
ACKPSPCapabilities | コンテナの Linux 権限を制限します。 | 高 |
ACKPSPFlexVolumes | FlexVolume ドライバーの使用を制限します。 | 中間 |
ACKPSPForbiddenSysctls | 指定された sysctls の使用を制限します。 | 高 |
ACKPSPFSGroup | 使用可能な補助グループを制限します。 | 中間 |
ACKPSPHostFilesystem | ホストファイルシステムパスの使用を制限します。 | 高 |
ACKPSPHostNamespace | ホスト名前空間の共有を制限します。 | 高 |
ACKPSPHostNetworkingPorts | ホストネットワークの使用およびポート範囲を制限します。 | 高 |
ACKPSPPrivilegedContainer | 特権付きコンテナの実行を制限します。 | 高 |
ACKPSPProcMount | 非デフォルトの proc mount タイプの使用を制限します。 | 低 |
ACKPSPReadOnlyRootFilesystem | コンテナが読み取り専用のルートファイルシステムを使用することを必須とします。 | 中間 |
ACKPSPSeccomp | seccomp プロファイルを制限します。 | 低 |
ACKPSPSELinuxV2 | SELinux ラベルを制限します。 | 低 |
ACKPSPVolumeTypes | 使用可能なボリュームタイプを制限します。 | 中間 |
FinOps
| ポリシー | 説明 | 重大度 |
|---|---|---|
ACKContainerRequests | コンテナがリソース要求を指定することを必須とします。 | 低 |
ACKContainerResourcesWhitelist | コンテナのリソース構成を事前定義されたホワイトリストに限定します。 | 低 |
ACKContainerResourcesRange | コンテナのリソース要求および使用制限を指定された範囲に制限します。 | 低 |
ACKRequiredNodeSelector | Pod が指定された nodeSelector を使用することを必須とします。 | 低 |
ACKWorkloadReplicasRange | ワークロードのレプリカ数範囲を制限します。 | 低 |
ACKRestrictALBCreation | Application Load Balancer (ALB) の作成を制限します。 | 低 |
コンプライアンス
ACKNoEnvVarSecrets
secretKeyRef を使用して、アプリケーションポッドへのシークレットの環境変数マウントを制限します。
重大度: 中間
パラメーター: なし
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKNoEnvVarSecrets
metadata:
name: no-env-var-secrets
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
namespaces: ["test-gatekeeper"]許可:
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禁止事項:
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"]許可:
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: {}禁止:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: test
name: bad
namespace: test-gatekeeper
spec:
containers:
- image: test
name: testACKRestrictNamespaces
クラスター内の指定された名前空間へのリソースデプロイメントを制限します。
重大度: 低
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
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"許可される例:
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: {}不許可な例:
apiVersion: v1
kind: Pod
metadata:
name: bad
namespace: test-gatekeeper
spec:
containers:
- name: mycontainer
image: redis
restartPolicy: NeverACKRestrictRoleBindings
指定された名前空間内の RoleBinding を、特定の Role または ClusterRole のセットに制限します。
重大度: 高
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
restrictedRole | オブジェクト | 制限される ClusterRole または Role です。 |
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禁止:
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.ioACKNamespacesDeleteProtection
指定された名前空間の誤った削除を防止します。protectionNamespaces パラメーターを使用して、保護対象の名前空間を設定します。
重大度: 中間
前提条件: Gatekeeper コンポーネント v3.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-gatekeeperACKServicesDeleteProtection
指定された名前空間内の Service インスタンスの誤った削除を防止します。protectionServices パラメーターを使用して、保護対象の 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不許可な例:
apiVersion: v1
kind: Service
metadata:
name: test-svcACKProtectBoundingPV
クラスター内で永続ボリューム要求 (PVC) にバインドされている永続ボリューム (PV) の削除を防止します。
重大度: 高
パラメーター: なし
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKProtectBoundingPV
metadata:
name: protect-pv-deletion
spec:
enforcementAction: deny
match:
kinds:
- apiGroups:
- ""
kinds:
- PersistentVolume許可済み:
apiVersion: v1
kind: PersistentVolume
metadata:
name: test-pv-bound-should-be-blocked
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 1Gi
persistentVolumeReclaimPolicy: Retain
storageClassName: manual-sc
hostPath:
path: /tmp/data
type: DirectoryOrCreate
status:
phase: Released不許可:
apiVersion: v1
kind: PersistentVolume
metadata:
name: test-pv-bound-should-be-blocked
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 1Gi
persistentVolumeReclaimPolicy: Retain
storageClassName: manual-sc
hostPath:
path: /tmp/data
type: DirectoryOrCreate
status:
phase: BoundACKBlockNodeDelete
クラスター内でカスタムタグを持つノードの削除を防止します。ノードが指定されたキーと値のペアのいずれかに一致する場合、そのノードは保護されます。複数のペアを定義できます。
重大度: 高
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
protectedLabels | 配列 | 保護対象のノードを識別するカスタムタグです。 |
protectedLabels.labelName | 文字列 | タグキーです。 |
protectedLabels.labelValue | 文字列 | タグ値です。 |
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockNodeDelete
metadata:
name: block-node-delete
spec:
enforcementAction: deny
match:
kinds:
- apiGroups: ["*"]
kinds: ["Node"]
parameters:
protectedLabels:
- labelName: policy.alibabacloud.vpc.com/node-delete-protection
labelValue: "true"
- labelName: policy.alibabacloud.com/node-delete-protection
labelValue: "true"許可済み:
apiVersion: v1
kind: Node
metadata:
name: cn-hangzhou-1禁止されています:
apiVersion: v1
kind: Node
metadata:
labels:
policy.alibabacloud.vpc.com/node-delete-protection: "true"
name: cn-hangzhou-1
---
apiVersion: v1
kind: Node
metadata:
labels:
policy.alibabacloud.vpc.com/node-delete-protection: "true"
name: cn-hangzhou-2
---
apiVersion: v1
kind: Node
metadata:
labels:
policy.alibabacloud.com/node-delete-protection: "true"
policy.alibabacloud.vpc.com/node-delete-protection: "true"
name: cn-hangzhou-3ACKResourceDeletionProtection
クラスター内でカスタムタグを持つリソースの削除を防止します。サポートされるリソースタイプ:Service、Namespace、Ingress、Deployment、StatefulSet、DaemonSet、Job、CronJob。リソースが指定されたキーと値のペアのいずれかに一致する場合、そのリソースは保護されます。複数のペアを定義できます。
重大度: 高
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
labels | 配列 | 保護対象のリソースを識別するカスタムタグです。 |
labels.labelName | 文字列 | タグキーです。 |
labels.labelValue | 文字列 | タグ値です。 |
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKResourceDeletionProtection
metadata:
name: resource-deletion-protection
annotations:
description: "Protect resources from being accidentally deleted."
spec:
enforcementAction: deny
match:
kinds:
- apiGroups:
- ""
kinds:
- Service
- Namespace
- apiGroups:
- extensions
- networking.k8s.io
kinds:
- Ingress
- apiGroups:
- apps
kinds:
- Deployment
- StatefulSet
- DaemonSet
- apiGroups:
- batch
kinds:
- Job
- CronJob
parameters:
labels:
- labelName: policy.alibabacloud.com/delete-protection
labelValue: "true"許可:
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
namespace: test-gatekeeper
spec:
replicas: 2
selector:
matchLabels:
app: test-app
template:
metadata:
labels:
app: test-app
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80禁止されています:
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
namespace: test-gatekeeper
labels:
policy.alibabacloud.com/delete-protection: "true"
spec:
replicas: 2
selector:
matchLabels:
app: test-app
template:
metadata:
labels:
app: test-app
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80ACKProtectCoreDNS
kube-system 名前空間内の CoreDNS 関連リソース(関連する Deployment、Service、ConfigMap を含む)の削除を防止します。
重大度: 高
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
min_replicas | int | CoreDNS Deployment に必要な最小レプリカ数です。 |
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKProtectCoreDNS
metadata:
name: coredns-protect-rule
spec:
enforcementAction: deny
match:
kinds:
- apiGroups: ["*"]
kinds: ["Deployment", "Service", "Scale", "ConfigMap"]
scope: "Namespaced"
namespaces: ["kube-system"]
parameters:
min_replicas: 2許可済み:
apiVersion: apps/v1
kind: Deployment
metadata:
name: coredns
namespace: kube-system
spec:
replicas: 3
selector:
matchLabels:
k8s-app: kube-dns
template:
metadata:
labels:
k8s-app: kube-dns
spec:
containers:
- name: coredns
image: registry-cn-hangzhou-vpc.ack.aliyuncs.com/acs/coredns:latest
imagePullPolicy: IfNotPresent不許可な例:
apiVersion: apps/v1
kind: Deployment
metadata:
name: coredns
namespace: kube-system
spec:
replicas: 1
selector:
matchLabels:
k8s-app: kube-dns
template:
metadata:
labels:
k8s-app: kube-dns
spec:
containers:
- name: coredns
image: registry-cn-hangzhou-vpc.ack.aliyuncs.com/acs/coredns:latest
imagePullPolicy: IfNotPresent
---
apiVersion: v1
data:
Corefile: ""
kind: ConfigMap
metadata:
name: coredns
namespace: kube-system
---
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
kubernetes.io/name: KubeDNS
name: kube-dns
namespace: kube-systemACKBlockCrdDeletion
関連するカスタムリソース (CR) がまだ存在する CustomResourceDefinitions (CRD) の削除を防止します。
重大度: 中間
パラメーター: なし
前提条件: このポリシーをデプロイする前に、「ack-policy-external-provider のインストールと構成」を行ってください。
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockCrdDeletion
metadata:
name: block-crd-deletion
spec:
enforcementAction: deny
match:
kinds:
- apiGroups:
- '*'
kinds:
- CustomResourceDefinitionインフラ
ACKBlockProcessNamespaceSharing
クラスター内の指定された範囲でデプロイされるアプリケーションにおける shareProcessNamespace の使用を制限します。
重大度: 高
パラメーター: なし
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockProcessNamespaceSharing
metadata:
name: block-share-process-namespace
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
namespaces: ["test-gatekeeper"]許可済み:
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: {}不許可な例:
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"]許可済み:
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"不許可な例:
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" アノテーションの設定を必須とします。オートスケーリング時、クラスターのオートスケーラーはこのアノテーションを持たない 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"]許可される例:
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不許可な例:
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
指定された名前空間でのデプロイメントを、指定されたリージョンの Alibaba Cloud Object Storage Service (OSS) 永続ボリューム (PV) のみで使用することに制限します。
重大度: 低
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
mode | 文字列 | ホワイトリスト機能の有効化設定です。デフォルト値 allowlist ではホワイトリストモードが有効になります。それ以外の値ではブラックリストモードが有効になります。 |
regions | 配列 | 許可される Alibaba Cloud リージョン 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"許可される例:
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: "/"不許可な例:
apiVersion: v1
kind: Pod
metadata:
name: pod-oss-csi
namespace: test-gatekeeper
spec:
containers:
- name: test
image: nginx:latest
volumes:
- name: test
csi:
driver: ossplugin.csi.alibabacloud.com
nodePublishSecretRef:
name: oss-secret
volumeAttributes:
bucket: "oss"
url: "oss-cn-hangzhou.aliyuncs.com"
otherOpts: "-o max_stat_cache_size=0 -o allow_other"
path: "/"ACKPVSizeConstraint
クラスター内で作成される PV インスタンスに対する最大ディスク容量の要求を制限します。
重大度: 中間
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
maxSize | 文字列 | PV インスタンスの最大ディスク容量です。デフォルト値:50 GiB。 |
制約:
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"許可済み:
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: "/"不許可な例:
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) インスタンスのデプロイメントを、ホワイトリストに登録された名前空間に限定し、要求可能な最大ディスク容量を制限します。
重大度: 中間
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
maxSize | 文字列 | PVC インスタンスの最大ディスク容量です。デフォルト値:50 GiB。 |
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"許可済み:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: disk-pvc
namespace: test-gatekeeper
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi不許可な例:
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: 20GiACKBlockVolumeTypes
クラスター内の指定された範囲でデプロイされる Pod に対して、指定されたボリュームマウントタイプの使用を禁止します。
重大度: 中間
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
volumes | 配列 | 禁止するボリュームマウントタイプです。 |
制約:
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"許可:
apiVersion: v1
kind: Pod
metadata:
name: use-empty-dir
namespace: test-gatekeeper
spec:
containers:
- name: test
image: test
volumes:
- name: emptydir-volume
emptyDir: {}不許可な例:
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***"ASMSidecarInjectionEnforced
Pod に Alibaba Cloud Service Mesh (ASM) サイドカーの注入を必須とします。
重大度: 高
パラメーター: なし
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ASMSidecarInjectionEnforced
metadata:
name: asm-sidecar-injectionen-forced
spec:
enforcementAction: deny
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
namespaces: ["test-gatekeeper"]許可:
apiVersion: v1
kind: Pod
metadata:
name: sidecar-injection
namespace: test-gatekeeper
spec:
containers:
- name: test
image: test
- name: istio-proxy
image: xxx/proxyv2:xxx不許可な例:
apiVersion: v1
kind: Pod
metadata:
name: sidecar-injection
namespace: test-gatekeeper
spec:
containers:
- name: test
image: testK8s-general
ACKAllowedRepos
指定された範囲でデプロイされるアプリケーションポッドが、許可されたリポジトリからのみイメージをプルすることを必須とします。
重大度: 高
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
repos | 配列 | 許可されるイメージリポジトリです。 |
制約:
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
initContainers:
- image: k8s.gcr.io/test-webserver
name: test-container-3ACKBlockAutoinjectServiceEnv
サービス IP アドレスが Pod の環境変数として公開されるのを防ぐために、アプリケーションが enableServiceLinks: false を設定することを必須とします。
重大度: 低
パラメーター: なし
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockAutoinjectServiceEnv
metadata:
name: block-auto-inject-service-env
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
namespaces:
- "test-gatekeeper"許可済み:
apiVersion: v1
kind: Pod
metadata:
name: pod-0
namespace: test-gatekeeper
spec:
enableServiceLinks: false
containers:
- image: openpolicyagent/test-webserver:1.0
name: test-container不許可:
apiVersion: v1
kind: Pod
metadata:
name: bad-1
namespace: test-gatekeeper
spec:
containers:
- image: k8s.gcr.io/test-webserver
name: test-containerACKBlockAutomountToken
サービスアカウントトークンの自動マウントを防ぐために、アプリケーションが 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"許可:
apiVersion: v1
kind: Pod
metadata:
name: pod-0
namespace: test-gatekeeper
spec:
automountServiceAccountToken: false
containers:
- image: openpolicyagent/test-webserver:v1.0
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-container2ACKBlockEphemeralContainer
指定された範囲内のアプリケーションポッドにおけるエフェメラルコンテナの起動を防止します。
重大度: 中間
パラメーター: なし
制約:
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: hello-pod
namespace: test-gatekeeper
spec:
containers:
- name: hello-pod
image: redis不許可な例:
既存の Pod にエフェメラルコンテナを起動します。
kubectl debug -it hello-pod -n test-gatekeeper --image=test --target=hello-pod予期される出力:
Error from server (Forbidden): admission webhook "validation.gatekeeper.sh" denied the request: [block-ephemeral-container-w5c6n] Creating ephemeral containers is disallowed, pod: hello-podACKBlockLoadBalancer
クラスター内の指定された範囲において、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"許可:
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禁止されています:
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: 9376ACKBlockNodePort
クラスター内の指定された範囲において、NodePort 型 Service を防止します。
重大度: 高
パラメーター: なし
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockNodePort
metadata:
name: block-node-port
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Service"]
namespaces:
- "test-gatekeeper"許可されるもの:
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禁止されています:
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: 9376ACKContainerLimits
指定された範囲内のアプリケーションポッドがリソース 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: openpolicyagent/test-webserver
name: test-container
resources:
limits:
memory: "100Mi"
cpu: "500m"不許可な例:
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 インスタンスが、ホワイトリストに登録された externalIPs のみを使用することを必須とします。
重大度: 高
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
allowedIPs | 配列 | 許可される externalIPs です。 |
制約:
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"許可済み:
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不許可な例:
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.XXACKImageDigests
指定された範囲でデプロイされるイメージが digest 形式を使用することを必須とします。
重大度: 低
パラメーター: なし
制約:
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: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
name: test-container
resources:
requests:
cpu: 10m
memory: 512Mi
limits:
cpu: "1"
memory: 1Gi不許可な例:
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-container2ACKRequiredLabels
Pod が特定のラベルを含み、ラベル値が定義されたフォーマットに一致することを検証します。各ラベル値の検証には正規表現を使用します。optional パラメーターにより、ラベルの必須性を制御できます。
重大度: 低
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
allowedRegex | 文字列 | ラベル値を検証するための正規表現です。 |
key | 文字列 | 検証対象のラベルキーです。 |
optional | bool | ラベルが任意であるかどうかを指定します。true の場合、ラベルが存在するときのみ検証されます。false の場合、ラベルは存在し、検証を通過する必要があります。 |
制約:
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.*$"
- key: env
allowedRegex: "^(dev|prod)$"
optional: true許可される:
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'
'env': 'invalid'
spec:
containers:
- name: mycontainer
image: redisACKRequiredProbes
指定された範囲でデプロイされる Pod が readinessProbe および livenessProbe の設定を持つことを必須とします。
重大度: 中間
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
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"]許可:
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/busyboxACKCheckNginxPath
Ingress インスタンスの spec.rules[].http.paths[].path フィールドにおける危険な構成を防止します。Ingress-nginx のバージョンが 1.2.1 より前の場合に、このポリシーを有効化してください。
重大度: 高
パラメーター: なし
制約:
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: 80ACKCheckNginxAnnotation
Ingress インスタンスの metadata.annotations フィールドにおける危険な構成を防止します。Ingress-nginx のバージョンが 1.2.1 より前の場合に、このポリシーを有効化してください。
重大度: 高
パラメーター: なし
制約:
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: 80ACKBlockInternetLoadBalancer
インターネット向け LoadBalancer Service の作成を防止します。
重大度: 高
パラメーター: なし
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKBlockInternetLoadBalancer
metadata:
name: block-internet-load-balancer
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Service"]
namespaces: ["test-gatekeeper"]許可:
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不許可:
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: 9376RatifyVerification
マーケットプレイスから Ratify コンポーネントをインストールした後、このポリシーを使用して、指定された範囲でデプロイされる Pod イメージのセキュリティメタデータ(署名や部品表 (BOM) など)を検証します。
重大度: 高
パラメーター: なし
制約:
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 # 有効な署名を持つイメージをデプロイします。
name: test-container不許可な例:
apiVersion: v1
kind: Pod
metadata:
name: bad-1
namespace: test-gatekeeper
spec:
containers:
- image: registry.cn-hangzhou.aliyuncs.com/acs/unsigned # Ratify 署名検証に失敗する無効なイメージをデプロイします。
name: test-containerPSP
ACKPSPAllowedUsers
指定された範囲でデプロイされる Pod が実行される user、group、supplementalGroups、および fsGroup を制限します。
重大度: 中間
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
runAsUser | オブジェクト | ユーザー構成です。ルールタイプおよび UID 範囲(最小/最大)をサポートします。「Users and groups」をご参照ください。 |
runAsGroup | オブジェクト | グループ構成です。ルールタイプおよび GID 範囲(最小/最大)をサポートします。「Users and groups」をご参照ください。 |
supplementalGroups | オブジェクト | SupplementalGroups 構成です。ルールタイプおよび GID 範囲(最小/最大)をサポートします。「Users and groups」をご参照ください。 |
fsGroup | オブジェクト | fsGroup 構成です。ルールタイプおよび GID 範囲(最小/最大)をサポートします。「Users and groups」をご参照ください。 |
制約:
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: testACKPSPAllowPrivilegeEscalationContainer
指定された範囲でデプロイされる 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"許可:
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不許可な例:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: test
name: bad
namespace: test-gatekeeper
spec:
containers:
- image: test
name: testACKPSPAppArmor
指定された範囲でデプロイされる Pod の AppArmor 構成を制限します。
重大度: 低
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
allowedProfiles | 配列 | 許可される 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許可済み:
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禁止されています:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: test
name: bad
namespace: test-gatekeeper
spec:
containers:
- image: test
name: testACKPSPCapabilities
指定された範囲でデプロイされる Pod の Linux 権限構成を制限します。
重大度: 高
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
allowedCapabilities | 配列 | 許可される Linux 権限です。 |
requiredDropCapabilities | 配列 | 必ずドロップしなければならない権限です。 |
制約:
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: testACKPSPFlexVolumes
指定された範囲でデプロイされる Pod の FlexVolume ドライバー構成を制限します。
重大度: 中間
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
allowedFlexVolumes | 配列 | 許可される 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"許可される例:
apiVersion: v1
kind: Pod
metadata:
name: pv-nas
namespace: test-gatekeeper
spec:
containers:
- name: test
image: test
volumes:
- name: test
flexVolume:
driver: "alicloud/nas"不許可な例:
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 が使用できる sysctls を制限します。
重大度: 高
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
forbiddenSysctls | 配列 | Pod で禁止される sysctls です。* を使用してすべての sysctls を禁止します。 |
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPForbiddenSysctls
metadata:
name: psp-forbidden-sysctls
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
namespaces:
- "test-gatekeeper"
parameters:
forbiddenSysctls:
# - "*" # * may be used to forbid all sysctls
- "kernel.*"許可される:
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不許可な例:
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: testACKPSPFSGroup
指定された範囲でデプロイされる Pod の fsGroup 構成を制限します。
重大度: 中間
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
rule | 文字列 | fsGroup ルールタイプです。サポートされる値:MustRunAs、MayRunAs、RunAsAny。「Volumes and file systems」をご参照ください。 |
ranges | オブジェクト | min(最小 fsGroup ID)および max(最大 fsGroup ID)を含みます。 |
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPFSGroup
metadata:
name: psp-fsgroup
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
namespaces:
- "test-gatekeeper"
parameters:
rule: "MayRunAs" #"MustRunAs" #"MayRunAs", "RunAsAny"
ranges:
- min: 1
max: 1000許可:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: test
name: good
namespace: test-gatekeeper
spec:
securityContext:
fsGroup: 100
containers:
- image: test
name: test禁止されています:
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: testACKPSPHostFilesystem
指定された範囲でデプロイされる Pod がマウントできるホストディレクトリパスを制限します。
重大度: 高
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
allowedHostPaths | オブジェクト | ホストパスのホワイトリスト構成です。 |
readOnly | ブール値 | パスが読み取り専用であるかどうかを示します。 |
pathPrefix | 文字列 | 許可されるパスプレフィックスです。 |
制約:
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"許可される:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: test
name: good1
namespace: test-gatekeeper
spec:
containers:
- image: test
name: test
securityContext:
readOnlyRootFilesystem: true禁止されています:
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: FileACKPSPHostNamespace
指定された範囲でデプロイされる Pod がホスト名前空間を共有できるかどうかを制限します。
重大度: 高
パラメーター: なし
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPHostNamespace
metadata:
name: psp-host-namespace
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
namespaces:
- "test-gatekeeper"許可される例:
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: {}不許可:
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 | ブール値 | Pod がホストネットワークを共有することを許可するかどうかを示します。 |
min | int | 許可される最小 hostPort です。 |
max | int | 許可される最大 hostPort です。 |
制約:
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不許可な例:
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: 22ACKPSPPrivilegedContainer
指定された範囲でデプロイされる 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不許可な例:
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: NeverACKPSPProcMount
指定された範囲でデプロイされる Pod に許可される proc mount タイプを制限します。サポートされる値:Default(/proc をマスク)および Unmasked(/proc をマスクしない)。詳細については、「AllowedProcMountTypes」をご参照ください。
重大度: 低
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
procMount | 文字列 | 許可される proc mount タイプ:Default または Unmasked。 |
制約:
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許可:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: test
name: good1
namespace: test-gatekeeper
spec:
containers:
- image: test
name: test
securityContext:
procMount: "Default"不許可な例:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: test
name: bad3
namespace: test-gatekeeper
spec:
hostUsers: false
containers:
- image: test
name: test
securityContext:
procMount: "Unmasked"
initContainers:
- image: test
name: test2ACKPSPReadOnlyRootFilesystem
指定された範囲でデプロイされる Pod が読み取り専用のルートファイルシステムを使用することを必須とします。
重大度: 中間
パラメーター: なし
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPReadOnlyRootFilesystem
metadata:
name: psp-readonlyrootfilesystem
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
securityContext:
readOnlyRootFilesystem: true不許可な例:
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: test2ACKPSPSeccomp
指定された範囲でデプロイされる 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許可済み:
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不許可な例:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: test
name: bad
namespace: test-gatekeeper
spec:
containers:
- image: test
name: testACKPSPSELinuxV2
指定された範囲でデプロイされる Pod が、allowedSELinuxOptions で指定された SELinux 構成を使用することを必須とします。パラメーターの詳細については、「SELinuxOptions v1 core」をご参照ください。
重大度: 低
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
allowedSELinuxOptions | オブジェクト | 許可される SELinux 構成です。 |
制約:
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許可される例:
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不許可な例:
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"ACKPSPVolumeTypes
指定された範囲でデプロイされる Pod が、指定されたボリュームマウントタイプのみを使用することを制限します。
重大度: 中間
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
volumes | 配列 | 許可されるボリュームマウントタイプです。* を使用してすべてのタイプを許可します。 |
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKPSPVolumeTypes
metadata:
name: psp-volume-types
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
namespaces:
- "test-gatekeeper"
parameters:
volumes:
# - "*" # * may be used to allow all volume types
- configMap
# - emptyDir
- projected
- secret
- downwardAPI
- persistentVolumeClaim
# - hostPath #required for allowedHostPaths
- flexVolume #required for allowedFlexVolumes許可:
apiVersion: v1
kind: Pod
metadata:
name: pv-oss
namespace: test-gatekeeper
spec:
containers:
- name: test
image: test
volumes:
- name: test
flexVolume:
driver: "alicloud/oss"不許可な例:
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: /dataFinOps
ACKContainerRequests
クラスター内の指定されたアプリケーションポッドがリソース requests を宣言することを必須とします。
重大度: 低
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
cpu | 文字列 | コンテナの最大 CPU requests 値です。 |
memory | 文字列 | コンテナの最大メモリ requests 値です。 |
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKContainerRequests
metadata:
name: container-must-have-requests
spec:
enforcementAction: deny
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: openpolicyagent/test-webserver
name: test-container
resources:
requests:
memory: "100Mi"
cpu: "500m"不許可な例:
apiVersion: v1
kind: Pod
metadata:
name: pod-0
namespace: test-gatekeeper
spec:
containers:
- image: openpolicyagent/test-webserver
name: test-containerACKContainerResourcesWhitelist
指定されたアプリケーションポッドの CPU およびメモリリソース構成が、事前定義されたオプションのリストから選択されることを必須とします。
重大度: 低
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
cpuRequests | 配列 | 許可される CPU requests 値です。空の配列 [] はすべての値を許可します。 |
cpuLimits | 配列 | 許可される CPU limits 値です。空の配列 [] はすべての値を許可します。 |
memoryRequests | 配列 | 許可されるメモリ requests 値です。空の配列 [] はすべての値を許可します。 |
memoryLimits | 配列 | 許可されるメモリ limits 値です。空の配列 [] はすべての値を許可します。 |
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKContainerResourcesWhitelist
metadata:
name: container-resources-whitelist
spec:
enforcementAction: deny
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
namespaces:
- "test-gatekeeper"
parameters:
cpuRequests:
- "100m"
- "500m"
- "1"
cpuLimits:
- "2"
- "4000m"
memoryRequests:
- "256Mi"
- "512Mi"
memoryLimits:
- "1Gi"
- "2048Mi"許可:
apiVersion: v1
kind: Pod
metadata:
name: pod-0
namespace: test-gatekeeper
spec:
containers:
- image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
name: test-container
resources:
requests:
cpu: 100m
memory: 512Mi
limits:
cpu: "2"
memory: 1Gi不許可な例:
apiVersion: v1
kind: Pod
metadata:
name: pod-0
namespace: test-gatekeeper
spec:
containers:
- image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
name: test-container
resources:
requests:
cpu: 10m
memory: 512Mi
limits:
cpu: "1"
memory: 1GiACKContainerResourcesRange
指定されたアプリケーションポッドのリソース構成を、指定された範囲に制限します。
重大度: 低
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
cpuRequests | オブジェクト | requests の min および max 値です。 |
cpuLimits | オブジェクト | limits の min および max 値です。 |
memoryRequests | オブジェクト | requests の min および max 値です。 |
memoryLimits | オブジェクト | limits の min および max 値です。 |
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKContainerResourcesRange
metadata:
name: container-resources-range
spec:
enforcementAction: deny
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
namespaces:
- "test-gatekeeper"
parameters:
cpuRequests:
min: "100m"
max: "1"
cpuLimits:
min: "500m"
max: "2"
memoryRequests:
min: "256Mi"
max: "512Mi"
memoryLimits:
min: "1Gi"
max: "2048Mi"許可:
apiVersion: v1
kind: Pod
metadata:
name: pod-0
namespace: test-gatekeeper
spec:
containers:
- image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
name: test-container
resources:
requests:
cpu: 100m
memory: 512Mi
limits:
cpu: "2"
memory: 2Gi不許可な例:
apiVersion: v1
kind: Pod
metadata:
name: pod-0
namespace: test-gatekeeper
spec:
containers:
- image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
name: test-container
resources:
requests:
cpu: 10m
memory: 5Mi
limits:
cpu: "3"
memory: 128MiACKRequiredNodeSelector
クラスター内の指定されたアプリケーションポッドが nodeSelector の設定を持つことを必須とします。
重大度: 低
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
nodeSelector | 配列 | key(ラベルキー)および allowedRegex(ラベル値の正規表現)を含みます。 |
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKRequiredNodeSelector
metadata:
name: must-have-nodeselector
spec:
enforcementAction: deny
match:
kinds:
- apiGroups: [""]
kinds: ["Pod"]
namespaces:
- "test-gatekeeper"
parameters:
nodeSelector:
- key: "node.alibabacloud.com/nodepool-id"
allowedRegex: "^np.*$"
- key: "kubernetes.io/os"
allowedRegex: "^linux$"許可:
apiVersion: v1
kind: Pod
metadata:
name: pod-0
namespace: test-gatekeeper
spec:
containers:
- image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
name: test-container
resources:
requests:
cpu: 100m
memory: 512Mi
limits:
cpu: "2"
memory: 1Gi
nodeSelector:
node.alibabacloud.com/nodepool-id: npd37f0e64410c41328a6282dbe5d35cae
kubernetes.io/os: linux不許可な例:
apiVersion: v1
kind: Pod
metadata:
name: pod-0
namespace: test-gatekeeper
spec:
containers:
- image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
name: test-container
resources:
requests:
cpu: 100m
memory: 512Mi
limits:
cpu: "2"
memory: 1Gi
nodeSelector:
node.alibabacloud.com/nodepool-id: npd37f0e64410c41328a6282dbe5d35cae
kubernetes.io/os: windowsACKWorkloadReplicasRange
ワークロードのレプリカ数範囲を制限します。
重大度: 低
パラメーター:
| パラメーター | 型 | 説明 |
|---|---|---|
minReplicas | int | 最小レプリカ数です。 |
maxReplicas | int | 最大レプリカ数です。 |
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKWorkloadReplicasRange
metadata:
name: replica-limiter
spec:
enforcementAction: deny
match:
kinds:
- apiGroups: ["*"]
kinds: ["Deployment", "StatefulSet", "ReplicaSet", "Scale"]
namespaces:
- "test-gatekeeper"
parameters:
minReplicas: 2
maxReplicas: 3許可済み:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment-basic
namespace: test-gatekeeper
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
ports:
- containerPort: 80
resources:
limits:
cpu: "500m"不許可な例:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment-basic-0
namespace: test-gatekeeper
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
ports:
- containerPort: 80
resources:
limits:
cpu: "500m"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment-basic-1
namespace: test-gatekeeper
labels:
app: nginx
spec:
replicas: 4
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: anolis-registry.cn-zhangjiakou.cr.aliyuncs.com/openanolis/nginx:1.14.1-8.6
ports:
- containerPort: 80
resources:
limits:
cpu: "500m"ACKRestrictALBCreation
既存の Application Load Balancer (ALB) インスタンスの再利用を強制し、AlbConfig を介した新しい ALB インスタンスの作成を禁止します。
重大度: 低
パラメーター: なし
制約:
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: ACKRestrictALBCreation
metadata:
name: restrict-alb-creation
spec:
enforcementAction: deny
match:
kinds:
- apiGroups: ["alibabacloud.com"]
kinds: ["AlbConfig"]許可済み:
apiVersion: alibabacloud.com/v1
kind: AlbConfig
metadata:
name: reuse-alb
spec:
config:
id: 'abcdefghijklmnopqrstuvwxyz'
forceOverride: false
listenerForceOverride: false不許可な例:
apiVersion: alibabacloud.com/v1
kind: AlbConfig
metadata:
name: alb
spec:
config:
name: alb
addressType: Internet
zoneMappings:
- vSwitchId: vsw-uf6ccg2a9g71hx8go**** # クラスターが存在する VPC 内の異なるゾーンにある少なくとも 2 つの vSwitch の vSwitch ID に置き換えてください。
allocationId: eip-asdfas**** # EIP ID に置き換えてください。デフォルトオプションは、パブリック IP アドレスを自動的に割り当てることです。
- vSwitchId: vsw-uf6nun9tql5t8nh15**** # クラスターが存在する VPC 内の異なるゾーンにある少なくとも 2 つの vSwitch の vSwitch ID に置き換えてください。
allocationId: eip-dpfmss**** # EIP ID に置き換えてください。
listeners:
- port: 80
protocol: HTTP