The tool kubeaudit is a command line tool and a Go package to audit Kubernetes clusters for various different security concerns.
Kubeaudit can detect if it is running within a container in a cluster. If so, it will try to audit all Kubernetes resources in that cluster:
This tool also has the argument autofix to automatically fix detected issues.
Popeye is a utility that scans live Kubernetes cluster and reports potential issues with deployed resources and configurations. It sanitizes your cluster based on what's deployed and not what's sitting on disk. By scanning your cluster, it detects misconfigurations and helps you to ensure that best practices are in place, thus preventing future headaches. It aims at reducing the cognitive _over_load one faces when operating a Kubernetes cluster in the wild. Furthermore, if your cluster employs a metric-server, it reports potential resources over/under allocations and attempts to warn you should your cluster run out of capacity.
KICS finds security vulnerabilities, compliance issues, and infrastructure misconfigurations in the following Infrastructure as Code solutions: Terraform, Kubernetes, Docker, AWS CloudFormation, Ansible, Helm, Microsoft ARM, and OpenAPI 3.0 specifications
Checkov is a static code analysis tool for infrastructure-as-code.
It's very important to protect the access to the Kubernetes Api Server as a malicious actor with enough privileges could be able to abuse it and damage in a lot of way the environment.
It's important to secure both the access (whitelist origins to access the API Server and deny any other connection) and the authentication (following the principle of leastprivilege). And definitely neverallowanonymousrequests.
Common Request process:
User or K8s ServiceAccount –> Authentication –> Authorization –> Admission Control.
Avoid Anonymous access.
NodeRestriction; No access from specific nodes to the API.
Basically prevents kubelets from adding/removing/updating labels with a node-restriction.kubernetes.io/ prefix. This label prefix is reserved for administrators to label their Node objects for workload isolation purposes, and kubelets will not be allowed to modify labels with that prefix.
And also, allows kubelets to add/remove/update these labels and label prefixes.
Ensure with labels the secure workload isolation.
Avoid specific pods from API access.
Avoid ApiServer exposure to the internet.
Avoid unauthorized access RBAC.
ApiServer port with firewall and IP whitelisting.
By default root user will be used when a Pod is started if no other user is specified. You can run your application inside a more secure context using a template similar to the following one: