Skip to main content
7 min read·1,234 words

Cluster Setup and Hardening

Required knowledge for the CKS certification.

Last reviewed: — verified against Kubernetes 1.36.

Securing a Kubernetes cluster begins with a hardened configuration across its core components. This page is the head reference for the two highest-weighted domains of the CKS exam — Cluster Setup (15%) and Cluster Hardening (15%) — covering the API server, etcd, network, nodes, pods, RBAC, secrets, and configuration validation. Each linked article maps to a concrete attack surface, with mitigation guidance and tooling examples.

Following these practices reduces the risk of compromise, supports defense-in-depth, and helps meet compliance frameworks such as the CIS Kubernetes Benchmark.


Why Cluster Hardening Matters

The Kubernetes control plane is the single highest-value target in any cluster. A compromised API server, kubelet, or etcd instance gives an attacker cluster-wide privileges that no workload-level control can recover from. The articles below cover the controls that bound that blast radius:

  • API server flags that close anonymous-auth and weak authentication paths
  • etcd encryption-at-rest with KMS v2
  • Default-deny NetworkPolicy and CNI selection
  • Pod Security Admission and admission-time policy enforcement
  • Identity-aware RBAC scoped to the smallest possible verb × resource × namespace
  • Secret storage that does not depend on plaintext base64 in etcd

Treat each of the eight sections below as a checklist when bootstrapping a cluster or auditing an existing one.


Hardening Domains at a Glance

Each subsection on this page maps to a well-defined attack surface. The table below summarises the primary control and where to read more.

DomainPrimary RiskKey ControlReference
API Server SecurityAnonymous or weak authentication, missing admission control--anonymous-auth=false, OIDC, admission webhooksAPI Server Mitigation
Control Plane Securityetcd compromise leaks every SecretKMS v2 encryption, mTLS, restricted etcd peersetcd Security
Network SecurityLateral movement, ingress hijackingDefault-deny NetworkPolicy, CNI with policy supportNetwork Policies
Node SecurityKubelet API exposure, host compromiseRestricted kubelet authn/authz, hardened OSKubelet Security
Pod SecurityPrivileged escapes, host mountsPod Security Admission restricted, seccomp, AppArmorPod Security Standards
RBAC and IdentityOver-broad ServiceAccounts and bindingsLeast-privilege RBAC, disable token automountInsecure RBAC Mitigation
Secrets ManagementPlaintext Secrets in Git or etcdKMS v2, external secret stores, encrypted Git storesSecrets Mitigation
Configuration ValidationMisconfigured manifests reaching productionPre-merge linting, admission policyKubescape

CIS Benchmarks

Use CIS Benchmarks to validate your cluster's security posture:


API Server Security

Harden the Kubernetes API server to reduce exposure and control access:


Control Plane Security

Protect the cluster's core components and maintain data integrity:


Network Security

Control traffic flow, minimize exposure, and secure ingress/egress:

CNI for Network Policy: Cilium vs Calico

AspectCiliumCalico
Data planeeBPF (kernel-level)iptables, eBPF (optional), or VPP
NetworkPolicy supportNative + CiliumNetworkPolicy (L3/L4/L7)Native + GlobalNetworkPolicy
L7 policyHTTP, gRPC, Kafka, DNS-awareDNS-aware via Calico Cloud / Enterprise
Identity modelCilium identities (label-based)Endpoints + selectors
ObservabilityHubble (built-in)Calico flow logs (Enterprise)
Service meshCilium Service Mesh (sidecarless)Integrates with Istio / Linkerd
Best fiteBPF-first stacks, L7-aware policy, Hubble visibilityMature operations, mixed bare-metal / cloud, simpler model

Read more: Cilium · Calico · Network Policies


Node Security

Secure the infrastructure running your workloads:


Pod Security

Enforce strict security boundaries within workloads:

Pod Admission: Pod Security Admission vs External Policy Engine

AspectPod Security Admission (built-in)Kyverno / OPA Gatekeeper
DistributionIn-tree, ships with the API serverAdd-on (Helm chart, controllers)
ConfigurationNamespace labels (pod-security.kubernetes.io/...)CRDs (ClusterPolicy, ConstraintTemplate)
ScopePod spec onlyAny Kubernetes resource
Profilesprivileged, baseline, restrictedArbitrary policy logic (YAML / Rego / CEL)
MutationNoneYes (Kyverno, Gatekeeper assigners)
Best fitBaseline guardrail with zero ops costCustom policy, mutation, image verification

Most production clusters run both — PSA provides the always-on baseline, and a policy engine layers on the rules PSA cannot express. See the head-term Kyverno vs Gatekeeper comparison for a deeper engine-level breakdown.


RBAC and Identity

Use identity-aware access controls to enforce least privilege:


Secrets Management

Protect sensitive credentials and reduce the blast radius of compromise:

Encrypted-at-rest Git Workflow: Sealed Secrets vs Mozilla SOPS

AspectSealed SecretsMozilla SOPS
MaintainerBitnamiMozilla / CNCF community
Encrypted formatCustom SealedSecret CRDStandard Secret (or any YAML / JSON)
Decryption pointIn-cluster controller using a cluster keyLocally or in CI via KMS / age / PGP
Key rotationController-managed; resealing requiredDrop-in re-encrypt with new KMS key
Multi-cluster portabilityPer-cluster key, requires resealingSame encrypted file works across clusters
External KMS supportNo (uses controller's RSA key)Yes (AWS KMS, GCP KMS, Azure Key Vault, age, PGP)
Best fitSingle-cluster GitOps with one teamMulti-cluster, multi-team, KMS-backed workflows

Configuration Validation

Validate YAML manifests and infrastructure code for misconfigurations before deployment:


Try It: Live YAML Security Analyzer

Test a workload against the controls above before applying it. The analyzer reports privileged containers, host namespaces, missing securityContext, automounted SA tokens, and other admission-blockers.


Version-Specific Notes (Kubernetes 1.36)

The following cluster-hardening features are GA and should be the default expectation when bootstrapping a new cluster:

  • Pod Security Admission — GA since 1.25. Replaces PodSecurityPolicy with restricted, baseline, and privileged profiles configured via namespace labels.
  • KMS v2 encryption providers — GA since 1.29. Replaces KMS v1 for at-rest Secret encryption with much higher throughput and key-rotation support.
  • Validating Admission Policy — GA since 1.30. CEL-based admission policies live in the API server, eliminating the need to run a webhook for many baseline policies.
  • --anonymous-auth-config — GA in 1.33. Restricts anonymous requests to specific endpoints (e.g., /healthz) instead of accepting them globally.
  • Sidecar containers — GA since 1.33. Init containers with restartPolicy: Always are the supported pattern for security sidecars (proxies, secret rotators, log shippers).
  • User namespaces (hostUsers: false) — GA in 1.33. Maps in-pod root to an unprivileged UID on the host, dramatically reducing escape impact.

Removed APIs to know about:

  • PodSecurityPolicy — Removed in 1.25. Migrate to PSA + Kyverno / Gatekeeper.
  • extensions/v1beta1 Ingress — Removed in 1.22. Use networking.k8s.io/v1.

Always check the Kubernetes deprecation guide before upgrading.


Hardening Principles for Cluster Setup

Secure by Default

Use distributions and tools that ship with restricted defaults: PSA restricted namespaces for new workloads, default-deny NetworkPolicy in every namespace, encryption at rest enabled before any Secret is created.

Least Privilege

Bind the smallest possible verb × resource × namespace to every ServiceAccount and human user. Disable automountServiceAccountToken on workloads that do not call the API server.

Defense in Depth

Pair admission controls (PSA, policy engines) with runtime detection (Falco, Tetragon) and a hardened control plane (mTLS everywhere, audit logging). One bypassed control should not lead to compromise.

Continuous Verification

Re-run kube-bench and your configuration validator on every cluster change. Treat drift between Git and the cluster as a security event, not an operational one.


Conclusion

Cluster setup and hardening is the foundation of Kubernetes security and the highest-leverage place to invest. Addressing the risks in each layer — from API access to pod isolation — gives you a baseline that the rest of the stack can build on. The articles in this section provide actionable guidance to harden your cluster and protect against the attack vectors catalogued elsewhere on the site.