Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EKS Best practices policies #57

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions config/samples/policies/check-amazon-inspector.yaml
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
27 changes: 27 additions & 0 deletions config/samples/policies/check-immutable-tags-ecr.yaml
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 config/samples/policies/check-instance-profile-access.yaml
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"

28 changes: 28 additions & 0 deletions config/samples/policies/check-public-dns.yaml
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"
29 changes: 29 additions & 0 deletions config/samples/policies/check-vpc-flow-logs.yaml
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