|
| 1 | +--- |
| 2 | +title: "Cloud Native Security and Kubernetes" |
| 3 | +linkTitle: "Cloud Native Security" |
| 4 | +weight: 10 |
| 5 | + |
| 6 | +# The section index lists this explicitly |
| 7 | +hide_summary: true |
| 8 | + |
| 9 | +description: > |
| 10 | + Concepts for keeping your cloud-native workload secure. |
| 11 | +--- |
| 12 | + |
| 13 | +Kubernetes is based on a cloud-native architecture, and draws on advice from the |
| 14 | +{{< glossary_tooltip text="CNCF" term_id="cncf" >}} about good practice for |
| 15 | +cloud native information security. |
| 16 | + |
| 17 | +Read on through this page for an overview of how Kubernetes is designed to |
| 18 | +help you deploy a secure cloud native platform. |
| 19 | + |
| 20 | +## Cloud native information security |
| 21 | + |
| 22 | +{{< comment >}} |
| 23 | +There are localized versions available of this whitepaper; if you can link to one of those |
| 24 | +when localizing, that's even better. |
| 25 | +{{< /comment >}} |
| 26 | + |
| 27 | +The CNCF [white paper](https://github.com/cncf/tag-security/tree/main/security-whitepaper) |
| 28 | +on cloud native security defines security controls and practices that are |
| 29 | +appropriate to different _lifecycle phases_. |
| 30 | + |
| 31 | +## _Develop_ lifecycle phase {#lifecycle-phase-develop} |
| 32 | + |
| 33 | +- Ensure the integrity of development environments. |
| 34 | +- Design applications following good practice for information security, |
| 35 | + appropriate for your context. |
| 36 | +- Consider end user security as part of solution design. |
| 37 | + |
| 38 | +To achieve this, you can: |
| 39 | + |
| 40 | +1. Adopt an architecture, such as [zero trust](https://glossary.cncf.io/zero-trust-architecture/), |
| 41 | + that minimizes attack surfaces, even for internal threats. |
| 42 | +1. Define a code review process that considers security concerns. |
| 43 | +1. Build a _threat model_ of your system or application that identifies |
| 44 | + trust boundaries. Use that to model to identify risks and to help find |
| 45 | + ways to treat those risks. |
| 46 | +1. Incorporate advanced security automation, such as _fuzzing_ and |
| 47 | + [security chaos engineering](https://glossary.cncf.io/security-chaos-engineering/), |
| 48 | + where it's justified. |
| 49 | + |
| 50 | +## _Distribute_ lifecycle phase {#lifecycle-phase-distribute} |
| 51 | + |
| 52 | +- Ensure the security of the supply chain for container images you execute. |
| 53 | +- Ensure the security of the supply chain for the cluster and other components |
| 54 | + that execute your application. An example of another component might be an |
| 55 | + external database that your cloud-native application uses for persistence. |
| 56 | + |
| 57 | +To achieve this, you can: |
| 58 | + |
| 59 | +1. Scan container images and other artifacts for known vulnerabilities. |
| 60 | +1. Ensure that software distribution uses encryption in transit, with |
| 61 | + a chain of trust for the software source. |
| 62 | +1. Adopt and follow processes to update dependencies when updates are |
| 63 | + available, especially in response to security announcements. |
| 64 | +1. Use validation mechanisms such as digital certificates for supply |
| 65 | + chain assurance. |
| 66 | +1. Subscribe to feeds and other mechanisms to alert you to security |
| 67 | + risks. |
| 68 | +1. Restrict access to artifacts. Place container images in a |
| 69 | + [private registry](/docs/concepts/containers/images/#using-a-private-registry) |
| 70 | + that only allows authorized clients to pull images. |
| 71 | + |
| 72 | +## _Deploy_ lifecycle phase {#lifecycle-phase-deploy} |
| 73 | + |
| 74 | +Ensure appropriate restrictions on what can be deployed, who can deploy it, |
| 75 | +and where it can be deployed to. |
| 76 | +You can enforce measures from the _distribute_ phase, such as verifying the |
| 77 | +cryptographic identity of container image artifacts. |
| 78 | + |
| 79 | +When you deploy Kubernetes, you also set the foundation for your |
| 80 | +applications' runtime environment: a Kubernetes cluster (or |
| 81 | +multiple clusters). |
| 82 | +That IT infrastructure must provide the security guarantees that higher |
| 83 | +layers expect. |
| 84 | + |
| 85 | +## _Runtime_ lifecycle phase {#lifecycle-phase-runtime} |
| 86 | + |
| 87 | +The Runtime phase comprises three critical areas: [compute](#protection-runtime-compute), |
| 88 | +[access](#protection-runtime-access), and [storage](#protection-runtime-storage). |
| 89 | + |
| 90 | + |
| 91 | +### Runtime protection: access {#protection-runtime-access} |
| 92 | + |
| 93 | +The Kubernetes API is what makes your cluster work. Protecting this API is key |
| 94 | +to providing effective cluster security. |
| 95 | + |
| 96 | +Other pages in the Kubernetes documentation have more detail about how to set up |
| 97 | +specific aspects of access control. The [security checklist](/docs/concepts/security/security-checklist/) |
| 98 | +has a set of suggested basic checks for your cluster. |
| 99 | + |
| 100 | +Beyond that, securing your cluster means implementing effective |
| 101 | +[authentication](/docs/concepts/security/controlling-access/#authentication) and |
| 102 | +[authorization](/docs/concepts/security/controlling-access/#authorization) for API access. Use [ServiceAccounts](/docs/concepts/security/service-accounts/) to |
| 103 | +provide and manage security identities for workloads and cluster |
| 104 | +components. |
| 105 | + |
| 106 | +Kubernetes uses TLS to protect API traffic; make sure to deploy the cluster using |
| 107 | +TLS (including for traffic between nodes and the control plane), and protect the |
| 108 | +encryption keys. If you use Kubernetes' own API for |
| 109 | +[CertificateSigningRequests](/docs/reference/access-authn-authz/certificate-signing-requests/#certificate-signing-requests), |
| 110 | +pay special attention to restricting misuse there. |
| 111 | + |
| 112 | +### Runtime protection: compute {#protection-runtime-compute} |
| 113 | + |
| 114 | +{{< glossary_tooltip text="Containers" term_id="container" >}} provide two |
| 115 | +things: isolation between different applications, and a mechanism to combine |
| 116 | +those isolated applications to run on the same host computer. Those two |
| 117 | +aspects, isolation and aggregation, mean that runtime security involves |
| 118 | +trade-offs and finding an appropriate balance. |
| 119 | + |
| 120 | +Kubernetes relies on a {{< glossary_tooltip text="container runtime" term_id="container-runtime" >}} |
| 121 | +to actually set up and run containers. The Kubernetes project does |
| 122 | +not recommend a specific container runtime and you should make sure that |
| 123 | +the runtime(s) that you choose meet your information security needs. |
| 124 | + |
| 125 | +To protect your compute at runtime, you can: |
| 126 | + |
| 127 | +1. Enforce [Pod security standards](/docs/concepts/security/pod-security-standards/) |
| 128 | + for applications, to help ensure they run with only the necessary privileges. |
| 129 | +1. Run a specialized operating system on your nodes that is designed specifically |
| 130 | + for running containerized workloads. This is typically based on a read-only |
| 131 | + operating system (_immutable image_) that provides only the services |
| 132 | + essential for running containers. |
| 133 | + |
| 134 | + Container-specific operating systems help to isolate system components and |
| 135 | + present a reduced attack surface in case of a container escape. |
| 136 | +1. Define [ResourceQuotas](/docs/concepts/policy/resource-quotas/) to |
| 137 | + fairly allocate shared resources, and use |
| 138 | + mechanisms such as [LimitRanges](/docs/concepts/policy/limit-range/) |
| 139 | + to ensure that Pods specify their resource requirements. |
| 140 | +1. Partition workloads across different nodes. |
| 141 | + Use [node isolation](/docs/concepts/scheduling-eviction/assign-pod-node/#node-isolation-restriction) |
| 142 | + mechanisms, either from Kubernetes itself or from the ecosystem, to ensure that |
| 143 | + Pods with different trust contexts are run on separate sets of nodes. |
| 144 | +1. Use a {{< glossary_tooltip text="container runtime" term_id="container-runtime" >}} |
| 145 | + that provides security restrictions. |
| 146 | +1. On Linux nodes, use a Linux security module such as [AppArmor](/docs/tutorials/security/apparmor/) (beta) |
| 147 | + or [seccomp](/docs/tutorials/security/seccomp/). |
| 148 | + |
| 149 | +### Runtime protection: storage {#protection-runtime-storage} |
| 150 | + |
| 151 | +To protect storage for your cluster and the applications that run there, you can: |
| 152 | + |
| 153 | +1. Integrate your cluster with an external storage plugin that provides encryption at |
| 154 | + rest for volumes. |
| 155 | +1. Enable [encryption at rest](/docs/tasks/administer-cluster/encrypt-data/) for |
| 156 | + API objects. |
| 157 | +1. Protect data durability using backups. Verify that you can restore these, whenever you need to. |
| 158 | +1. Authenticate connections between cluster nodes and any network storage they rely |
| 159 | + upon. |
| 160 | +1. Implement data encryption within your own application. |
| 161 | + |
| 162 | +For encryption keys, generating these within specialized hardware provides |
| 163 | +the best protection against disclosure risks. A _hardware security module_ |
| 164 | +can let you perform cryptographic operations without allowing the security |
| 165 | +key to be copied elsewhere. |
| 166 | + |
| 167 | +### Networking and security |
| 168 | + |
| 169 | +You should also consider network security measures, such as |
| 170 | +[NetworkPolicy](/docs/concepts/services-networking/network-policies/) or a |
| 171 | +[service mesh](https://glossary.cncf.io/service-mesh/). |
| 172 | +Some network plugins for Kubernetes provide encryption for your |
| 173 | +cluster network, using technologies such as a virtual |
| 174 | +private network (VPN) overlay. |
| 175 | +By design, Kubernetes lets you use your own networking plugin for your |
| 176 | +cluster (if you use managed Kubernetes, the person or organization |
| 177 | +managing your cluster may have chosen a network plugin for you). |
| 178 | + |
| 179 | +The network plugin you choose and the way you integrate it can have a |
| 180 | +strong impact on the security of information in transit. |
| 181 | + |
| 182 | +### Observability and runtime security |
| 183 | + |
| 184 | +Kubernetes lets you extend your cluster with extra tooling. You can set up third |
| 185 | +party solutions to help you monitor or troubleshoot your applications and the |
| 186 | +clusters they are running. You also get some basic observability features built |
| 187 | +in to Kubernetes itself. Your code running in containers can generate logs, |
| 188 | +publish metrics or provide other observability data; at deploy time, you need to |
| 189 | +make sure your cluster provides an appropriate level of protection there. |
| 190 | + |
| 191 | +If you set up a metrics dashboard or something similar, review the chain of components |
| 192 | +that populate data into that dashboard, as well as the dashboard itself. Make sure |
| 193 | +that the whole chain is designed with enough resilience and enough integrity protection |
| 194 | +that you can rely on it even during an incident where your cluster might be degraded. |
| 195 | + |
| 196 | +Where appropriate, deploy security measures below the level of Kubernetes |
| 197 | +itself, such as cryptographically measured boot, or authenticated distribution |
| 198 | +of time (which helps ensure the fidelity of logs and audit records). |
| 199 | + |
| 200 | +For a high assurance environment, deploy cryptographic protections to ensure that |
| 201 | +logs are both tamper-proof and confidential. |
| 202 | + |
| 203 | +## {{% heading "whatsnext" %}} |
| 204 | + |
| 205 | +### Cloud native security {#further-reading-cloud-native} |
| 206 | + |
| 207 | +* CNCF [white paper](https://github.com/cncf/tag-security/tree/main/security-whitepaper) |
| 208 | + on cloud native security. |
| 209 | +* CNCF [white paper](https://github.com/cncf/tag-security/blob/f80844baaea22a358f5b20dca52cd6f72a32b066/supply-chain-security/supply-chain-security-paper/CNCF_SSCP_v1.pdf) |
| 210 | + on good practices for securing a software supply chain. |
| 211 | +* [Fixing the Kubernetes clusterf\*\*k: Understanding security from the kernel up](https://archive.fosdem.org/2020/schedule/event/kubernetes/) (FOSDEM 2020) |
| 212 | +* [Kubernetes Security Best Practices](https://www.youtube.com/watch?v=wqsUfvRyYpw) (Kubernetes Forum Seoul 2019) |
| 213 | +* [Towards Measured Boot Out of the Box](https://www.youtube.com/watch?v=EzSkU3Oecuw) (Linux Security Summit 2016) |
| 214 | + |
| 215 | +### Kubernetes and information security {#further-reading-k8s} |
| 216 | + |
| 217 | +* [Kubernetes security](/docs/concepts/security/) |
| 218 | +* [Securing your cluster](/docs/tasks/administer-cluster/securing-a-cluster/) |
| 219 | +* [Data encryption in transit](/docs/tasks/tls/managing-tls-in-a-cluster/) for the control plane |
| 220 | +* [Data encryption at rest](/docs/tasks/administer-cluster/encrypt-data/) |
| 221 | +* [Secrets in Kubernetes](/docs/concepts/configuration/secret/) |
| 222 | +* [Controlling Access to the Kubernetes API](/docs/concepts/security/controlling-access) |
| 223 | +* [Network policies](/docs/concepts/services-networking/network-policies/) for Pods |
| 224 | +* [Pod security standards](/docs/concepts/security/pod-security-standards/) |
| 225 | +* [RuntimeClasses](/docs/concepts/containers/runtime-class) |
| 226 | + |
0 commit comments