-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EKS Best practices policies (#57)
- Loading branch information
Showing
5 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: check-amazon-inspector | ||
annotations: | ||
policies.kyverno.io/title: Check Amazon Inspector for EC2 and ECR | ||
policies.kyverno.io/category: EKS Best Practices | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/subject: Cluster | ||
policies.kyverno.io/description: >- | ||
Amazon Inspector is not enabled on both EC2 and ECR | ||
spec: | ||
validationFailureAction: audit | ||
background: true | ||
rules: | ||
- name: check-amazon-inspector | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- AWSAdapterConfig | ||
validate: | ||
message: "Amazon Inspector must be enabled on EC2 and ECR" | ||
pattern: | ||
status: | ||
accountData: | ||
inspectorEnabledEC2: true | ||
inspectorEnabledECR: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: check-immutable-tags-ecr | ||
annotations: | ||
policies.kyverno.io/title: Check Immutable Tags for ECR | ||
policies.kyverno.io/category: EKS Best Practices | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/subject: Cluster | ||
policies.kyverno.io/description: >- | ||
Immutable tags are not enabled on all ECR repositories. | ||
spec: | ||
validationFailureAction: audit | ||
background: true | ||
rules: | ||
- name: check-immutable-tag | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- AWSAdapterConfig | ||
validate: | ||
message: "The `imageTagMutable` field must set to true on all ECR repositories." | ||
foreach: | ||
- list: "request.object.status.ecrRepositories[]" | ||
pattern: | ||
imageTagMutable: true |
29 changes: 29 additions & 0 deletions
29
config/samples/policies/check-instance-profile-access.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: check-instance-profile-access | ||
annotations: | ||
policies.kyverno.io/title: Check Access to Instance Profile | ||
policies.kyverno.io/category: EKS Best Practices | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/subject: Cluster | ||
policies.kyverno.io/description: >- | ||
Restrict access to the instance profile assigned to nodes | ||
spec: | ||
validationFailureAction: audit | ||
background: true | ||
rules: | ||
- name: check-instance-profile-access | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- AWSAdapterConfig | ||
validate: | ||
message: "Restrict access to the instance profile assigned to nodes" | ||
foreach: | ||
- list: "request.object.status.eksCluster.compute.reservations[]" | ||
pattern: | ||
instances: | ||
- httpPutResponseHopLimit: "!2" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: check-public-dns | ||
annotations: | ||
policies.kyverno.io/title: Check Public DNSName | ||
policies.kyverno.io/category: EKS Best Practices | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/subject: Cluster | ||
policies.kyverno.io/description: >- | ||
Deploy workers onto private subnets. If a public DNSName exists, then it means the worker is deployed on a public subnet | ||
spec: | ||
validationFailureAction: audit | ||
background: true | ||
rules: | ||
- name: check-public-dns | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- AWSAdapterConfig | ||
validate: | ||
message: "Deploy workers onto private subnets. If a public DNSName exists, then it means the worker is deployed on a public subnet." | ||
foreach: | ||
- list: "request.object.status.eksCluster.compute.reservations[]" | ||
pattern: | ||
instances: | ||
- X(publicDnsName): "null" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: check-vpc-flow-logs | ||
annotations: | ||
policies.kyverno.io/title: Check VPC Flow Logs | ||
policies.kyverno.io/category: EKS Best Practices | ||
policies.kyverno.io/severity: medium | ||
policies.kyverno.io/subject: Cluster | ||
policies.kyverno.io/description: >- | ||
VPC Flow logs are not enabled. | ||
spec: | ||
validationFailureAction: audit | ||
background: true | ||
rules: | ||
- name: check-vpc-flow-logs | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- AWSAdapterConfig | ||
validate: | ||
message: "Flow logs must be enabled for the VPC" | ||
pattern: | ||
status: | ||
eksCluster: | ||
networking: | ||
vpc: | ||
flowLogsEnabled: true |