Getty Images/iStockphoto
With the increase in container and container orchestrator adoption from enterprises to medium- and small-scale businesses, the requirement to protect any critical or sensitive infrastructure that runs container workloads has also increased.
As Kubernetes is the most popular container and container orchestration tool, let's discuss security best practices organizations should adopt to secure their Kubernetes clusters.
The most basic and neglected security best practice is to keep Kubernetes environments up to date. Take advantage of new updates and version releases of security features and bug fixes. In addition, use the latest stable version in the test environment before deploying to the production cluster.
Kubernetes APIs serve as the primary access point for a Kubernetes cluster. Admins or service accounts can access APIs through the command-line utilitykubectl,REST API calls or other client SDKs.
The Kubernetes API server, also known as kube-apiserver, hosts the APIs and forms the core of a Kubernetes cluster. The server grants access and ensures a cluster is up and running.
As a best practice, all API calls in the cluster must useTransport Layer Security, which is encrypted. Adopt an API authentication mechanism for the API servers as per the access requirements.
Common authentication methods include simple certificates or a bearer token. Large-scale, enterprise-level clusters should integrate with third-partyOpenID Connect providers or Lightweight Directory Access Protocol servers to segregate users into specific groups and control access. Refer to the official Kubernetesdocumentation for an overview on how to authenticate users and for authentication strategies.
Role-basedaccess control (RBAC) is an access control mechanism that enables users and applications to perform specific actions based on the least-privilege model and enforce required permissions only. This might seem time-consuming -- it does require additional work to set up -- but it's impossible to secure large-scale Kubernetes clusters that run production workloads withoutimplementing RBAC policies.
The following are some Kubernetes RBAC best practices administrators should follow:
The kubelet is an agent that runs on each node of the cluster. It interacts with users through a set of APIs that control the pods running on the nodes and performs specific operations. Unauthorized access to the kubelet gives attackers access to the APIs and can compromise node or cluster security.
Take the following steps to reduce this attack surface and prevent unauthorized access to the APIs through the kubelet:
To harden the node security that the pods run on, start with the following:
Configuration standards and benchmarks. Configure the host correctly as per the security recommendations. Validate clusters againstCenter for Internet Security benchmarks tied to specific Kubernetes releases.
Admin access minimization. Reduce the attack surface area by reducing the administrative access on Kubernetes nodes.
Node isolation and restrictions. Run specific pods on certain nodes or group of nodes. This ensures the pods run on nodes with specific isolation and security configurations.
To control which nodes a pod can access, add labels to node objects to enable pods to target specific nodes:
kubectl label nodes <node name> <label key>=<label value>
Once the node label is applied, add anodeSelector to the pod deployments so the pod deploys to the selected node, like in the following YAML file:
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: staging
spec:
containers:
- name: nginx-staging
image: nginx
Namespacesisolate sensitive workloads from nonsensitive ones. Even though managing multiple namespaces can be complex, it makes it easier to implement security controls likenetwork policies on sensitive workloads to control the traffic flow to and from pods.
Enable audit logs for Kubernetes clusters, and monitor them for malicious activity and suspicious API calls. Kubernetes can keep granular records of actions performed in the cluster. Audit logs detect potential security issues in almost real time. For example, an attacker trying to brute force a password might generate authentication and authorization related logs. If they are repetitive, it could be a security issue.
Audit logs are disabled by default; to enable them, use the Kubernetesaudit policy, which enables admins to define one of the four audit levels:
Follow the steps below to enable audit logs on Kubernetes clusters:
apiVersion: audit.k8s.io/v1
kind: Policy
rules:
- level: Metadata
resources:
- group: ""
resources: ["pods/log", "pods/status"]
- level: RequestResponse
resources:
- group: ""
resources: ["pods"]
Step-by-step guide to working with Crossplane and Kubernetes
Boost cluster security with Kubernetes vulnerability scanning
A principal engineer says Postman's Spec Hub will help the company shift to a spec-first API development process for its ...
AWS Kiro, a project developed by a 'small, opinionated team within AWS,' prioritizes spec-driven development in the workflows of ...
Docker is expanding the Docker Compose spec to accommodate AI agents in an effort to bring AI development closer to existing ...
An ADR is only as good as the record quality. Follow these best practices to establish a dependable ADR creation and maintenance ...
At some point, all developers must decide whether to refactor code or rewrite it. Base this choice on factors such as ...
API proxies and gateways help APIs talk to applications, but it can be tricky to understand vendor language around different ...
AI is transforming PaaS with automation and cost-efficient features, but will it eventually replace cloud platforms? Industry ...
Even though Q-Day might be several years away, enterprises should develop a strategic plan to prepare for the future. Experts ...
Businesses can find security vulnerabilities when they push their workloads to the edge. Discover the pitfalls of cloud edge ...
Compare Datadog vs. New Relic capabilities including alerts, log management, incident management and more. Learn which tool is ...
Many organizations struggle to manage their vast collection of AWS accounts, but Control Tower can help. The service automates ...
There are several important variables within the Amazon EKS pricing model. Dig into the numbers to ensure you deploy the service ...
Software teams must understand the important distinction between acceptance criteria and definition of done and how to use them ...
Choosing a Java framework is not about which one is best, it's about accepting their tradeoffs of stability, flexibility and ...
Is vibe coding a bad idea for enterprises? AI can produce results faster than manual coding, but its benefits eventually unravel ...
Data center migrations can be complex. Follow this best practices guide to better understand the migration process and tools to ...
Meta and Google tout aggressive AI infrastructure investments focused on data center builds and power.
Due to rapid AI hardware advancement, companies release advanced products yearly to keep up with the competition. The new ...