Implementation Recommendations
(Back)
The following are general recommendations for securing containers and Kubernetes.
4.1 Host Recommendations
The following are recommendations for securing the host:
-
Run docker engine with flags per CIS Docker Community Edition Benchmark and NIST Special Publication 800-190.
-
Check for compliance by running tools like docker-bench against the host. Recommended flags and settings can also be found in the Security Controls Mapping to Docker and Kubernetes document available on GCpedia.
-
While the benchmarks are the primary reference, consider these additional security best practices:
Best Practice | Description |
---|---|
Container Runtime Security |
AppArmor or SELinux on your containers for additional protection. |
Software Supply Chain Security |
|
Network Security |
|
Least Privilege |
|
Monitoring and Logging |
|
By embracing established security benchmarks and implementing best practices, you can significantly enhance the security posture of your containerized applications and Kubernetes deployments.
4.2 Image Builds
Containers are comprised of layered images specified in a Dockerfile
, which includes a base OS, libraries, and dependencies. Since vulnerabilities can be introduced at each layer of the image, containers should be as minimal as possible, with all components from trusted sources (provenance).
This starts by using trusted and optimized images with no (major) CVE vulnerabilities; and using only trusted versions and registries (trusted dependencies, signed images, secure and trusted registries). For some builds (i.e. FROM golang
), consider a multi-stage build to reduce size, unnecessary libraries, and vulnerabilities.
Organizations should evolve established processes to better fit containerized application build and deployment.
A sample of specific image build considerations include:
Consideration | Description |
---|---|
Hardening |
|
Patching Base OS |
|
Container-specific Host OS | |
Labels, Tags, (Not LATEST) |
|
Cryptographic Signing |
|
Best Practices |
Dockerfile best practices (such as specifying commands in the same line to reduce layers in image) |
4.3 Container Deployment Security
Container deployment can introduce security risks if not properly managed. To mitigate these risks, organizations should consider the following best practices:
Best Practice | Description |
---|---|
Use a Container Registry |
|
Use Cryptographically Signed Images |
|
Use CI/CD Pipelines |
|
Use Secrets Management Tools |
|
Use Monitoring and Logging Tools |
|
4.4 Orchestration - Kubernetes
Kubernetes is a popular container orchestration tool that automates the deployment, scaling, and management of containerized applications. Kubernetes provides a rich set of features for securing containerized applications.
The benefits of Kubernetes include:
Benefit | Description |
---|---|
Scalability | Can scale applications horizontally and vertically to meet demand. |
High Availability | Can automatically restart failed containers and reschedule them on healthy nodes. |
Resource Management | Can manage resources like CPU and memory to ensure that applications run efficiently. |
Service Discovery | Provides a built-in service discovery mechanism that allows applications to communicate with each other. |
Load Balancing | Can distribute incoming traffic across multiple instances of an application to ensure high availability. |
Rolling Updates | Can perform rolling updates of applications to minimize downtime. |
Monitoring and Logging | Provides built-in monitoring and logging capabilities to track the performance and security of applications. |
Security | Provides a rich set of security features to protect containerized applications. |
Portability | Cloud-agnostic and can run on any cloud provider or on-premises infrastructure. |
Although Kubernetes provides many benefits, it also introduces new security challenges. The configuration and management of Clusters require careful attention to ensure that they are secure.
Note: Where possible, it is recommended to use a managed Kubernetes service from a cloud provider, as they often provide additional security features and manage the underlying infrastructure for you. This eliminates the need to manage the Control plane and ensures that the cluster is always up to date with the latest security patches.
When managing your own Cluster, it is important to follow best practices for securing the cluster. Specific flags for hardening Can be found in the CIS Kubernetes Benchmark. Open source tools to verify configuration and compliance to CIS Benchmark include and kube-bench and kubsec.io.
Regardless of style (Managed or self-managed), high-level recommendations and best practices for securing Kubernetes include:
Best Practice | Description |
---|---|
TLS Everywhere |
|
Identity, Authorization, and Authentication |
|
TLS Everywhere |
|
Kubernetes Secrets |
Open Authorization (OAuth) tokens and Secure Shell (SSH) keys -- are encrypted and made available to each Pod only when they are required for a particular task. |
Logging and Telemetry |
|
Networking |
|
Further details can be found in kubernetes.io, and NIST Special Publication 800-190 Application Container Security Guide.
Page details
- Date modified: