Kubernetes security 3/4 - DevOps engineers perspective
Vishwas N.
Re-Inventing AI Acceleration for Enterprise | Training to be a Frugal Architect | Big Believer in "Product Ecosystem Fit" | Intrapreneur - Startup Swiss Army Knife(someone gave me this title)
How Can Your Kubernetes (K8s) Deployment Be Best Secure?
Due to its complexity, Kubernetes requires a lot of configuration and administration. You must address critical architectural flaws and platform dependencies by following security best practices if you want to make Kubernetes workloads secure, especially in a production environment.
1. Enable Role-Based Access Control in Kubernetes (RBAC)
You may specify who has access to the Kubernetes API and what rights they have with the aid of RBAC. On Kubernetes 1.6 and later, RBAC is often turned on by default (later on some hosted Kubernetes providers). When you implement RBAC, you must also disable the old Attribute Based Access Control since Kubernetes mixes authorization controllers (ABAC).
Choose namespace-specific rights over cluster-wide permissions when using RBAC. Don't give cluster administrators access, not even while troubleshooting. It is safest to permit access only when essential for your particular circumstance.
2. Make Use of Third-Party Authentication for the API Server
Integration with a third-party authentication service provider for Kubernetes is advised (e.g. GitHub). This guarantees that the Kube-apiserver does not alter when users are added or removed and adds extra security features like multi-factor authentication. Make sure users are not managed at the API server level, if at all feasible. OAuth 2.0 connections like Dex are also an option.
3. Use a firewall, TLS, and encryption to protect etcd
etcd is a sensitive resource and a prime target for attackers since it keeps the cluster's state and its secrets. Unauthorized users who obtain access to etcd can take control of the whole cluster. Because bad people can use read access to increase their rights, it is also risky.
Use the following configuration parameters to set up TLS for etcd for client-server communication:
Use the following configuration choices to set up TLS for etcd for server-to-server communication:
Use come Practices to define your needs on the cluster
For etcd secrets, enable encryption at rest:
Although it is not enabled by default, encryption is essential for protecting etcd. By supplying the parameter -encryption-provider-config to the Kube-apiserver process, you may activate it. You must declare your secret keys and choose a provider to handle encryption within the setup. For further information, consult the documentation.
4. Isolate the nodes of Kubernetes
Nodes for Kubernetes must be on a different network and shouldn't be directly accessible from open networks. Even better, stay away from direct connections to the main corporate network.
Only if control and data traffic in Kubernetes is segregated is this feasible. If not, both pass over the same pipe and unrestricted access to the control plane follows unrestricted access to the data plane. Nodes should ideally be set up with ingress controllers that are configured to only permit connections from the master node on the designated port through a network access control list (ACL).
5. Track Network Activity to Control Communications
Cluster networks are typically heavily utilized by containerized applications. To understand how your application interacts and spot unusual communications, monitor live network traffic and contrast it with the traffic permitted by Kubernetes network policy.
领英推荐
In addition, you may spot network rules that aren't being used by cluster workloads by comparing active traffic to authorized traffic. By eliminating unnecessary connections to lessen the attack surface, this information may be leveraged to improve the approved network policy even further.
6. Employ Process Whitelisting
The use of process whitelisting to identify unexpectedly running processes is highly effective. To start, keep track of all processes that are active when the program behaves normally over some time. Use this list as your whitelist moving forward to control future application behavior.
Runtime analysis at the process level is challenging. Several commercial security tools can evaluate and spot irregularities in processes operating across clusters.
7. Switch Audit Logging on.
Ensure that audit logging is enabled, and that you are keeping an eye out for any strange or undesirable API requests, particularly failed authentications. A "Forbidden" status notice appears next to certain log entries. Failure to approve might indicate that a hacker is attempting to utilize credentials that have been stolen.
The -audit-policy-file switch may be used to enable audit logging and specify precisely which events should be reported when files are sent to Kube-apiserver. There are four different logging levels you may choose from: None, Metadata only, Request (which logs both requests and responses but not metadata), and RequestResponse (which logs all three). See the documentation for an illustration of an audit policy file.
Managed Kubernetes providers can set up notifications for permission failures and give access to this data via their UI.
8. Maintain Kubernetes Version Consistency
Always use the most recent version of Kubernetes. Here is a collection of known Kubernetes vulnerabilities along with a severity rating.
Always prepare to update to the most recent version of Kubernetes. If you use a hosted Kubernetes provider, see if your supplier supports automated updates. Upgrading Kubernetes might be a challenging procedure.
9. Secure Kubelet
To launch pods and report metrics for nodes and pods, the kubelet—an agent that runs on every node—interacts with the container runtime. You can start and terminate pods and carry out other activities using the APIs that each kubelet in the cluster exposes. The cluster as a whole might be compromised if an unauthorized user obtains access to this API (on any node) and can run code there.
You may use the following configuration parameters to lock the kubelet and lessen the attack surface:
With —anonymous-auth=false, prevent anonymous access so that unauthenticated requests will return an error. The API server must authenticate itself to the kubelet to accomplish this. The flags -kubelet-client certificate and —kubelet-client-key can be added to change this.
With KSPM (Kubernetes Security Posture Management) and sophisticated agentless Kubernetes Runtime Protection, manage the complexities of Kubernetes security.
To accomplish policy-driven, full-lifecycle protection and compliance for K8s applications, Tools today offers Kubernetes-native capabilities:
Senior Manager- Cloud Engineering at BMO Bank of Montreal
2 年Thanks for sharing it Vishwas N., reshared!