Kubernetes v1.36: Unremovable Admission Policies for Enhanced Security

| 5 min read
Kubernetes has come a long way, but managing security policies across a multitude of clusters has often felt like navigating a particularly frustrating maze. Until now, the admission policies were contingent on being created and managed through API objects, which presents a clear dilemma: until those policies are firmly established, your clusters are left vulnerable. During the critical bootstrap phase, when the API server is just becoming operational, there's a glaring gap. It's during this window that a privileged user could easily sidestep your security intent by deleting those policies before they even take effect. This all changes with the introduction of **manifest-based admission control** in Kubernetes v1.36. This alpha feature allows users to set up admission webhooks and policies stored as files on disk, which are loaded by the API server right at startup. This ensures that your policies are active even before the first request hits the server, creating a more secure starting point for cluster operations.

Bridging the Security Gap

Traditionally, Kubernetes' method of policy enforcement heavily relies on the API. You'd typically create various configurations like *ValidatingAdmissionPolicy* objects, which the admission controller would then utilize. This might suffice when the system is running smoothly, but it fails to address some pressing concerns, particularly during cluster bootstrapping or recovery scenarios where significant time could pass before policies are fully enforced. Moreover, consider the limitations imposed by self-protection mechanisms. Admission webhooks and policies cannot apply to their own configuration items, such as the *ValidatingWebhookConfiguration*. Kubernetes intentionally bypasses invoking webhooks on these types to prevent circular dependencies, leaving a wide-open door for a privileged user to eliminate essential admission controls without any checks in place. This is the crux of the problem that the Kubernetes SIG API Machinery aimed to resolve: a method to ensure that certain admission policies remain perpetually enforced, without the possibility of erasure.

Implementation Mechanism

To set up this new system, you simply include a **staticManifestsDir** entry in your existing *AdmissionConfiguration* file, which you've likely been passing to the API server using the `--admission-control-config-file` flag. Just indicate a directory where your policy YAML files reside, and the API server will load these definitions before it begins processing requests. Below is a concise example of how this looks in practice. The manifest files adhere to the standard Kubernetes resource formats but come with a specific guideline: names must conclude with the suffix `.static.k8s.io`. This stipulation helps avoid naming conflicts with other API-based configurations and simplifies the debugging process when examining metrics or audit logs. Consider a policy that blocks the use of privileged containers outside of the *kube-system* namespace: ```yaml apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingAdmissionPolicy metadata: name: "deny-privileged.static.k8s.io" annotations: kubernetes.io/description: "Deny launching privileged pods, anywhere this policy is applied" spec: failurePolicy: Fail matchConstraints: resourceRules: - apiGroups: [""] apiVersions: ["v1"] operations: ["CREATE", "UPDATE"] resources: ["pods"] validations: - expression: >- !variables.allContainers.exists(c, has(c.securityContext) && has(c.securityContext.privileged) && c.securityContext.privileged == true) message: "Privileged containers are not allowed." ``` This policy expressly disallows privileged containers, providing a clear directive for compliance and security posture.

Enhancing Protection Measures

The standout benefit of this shift to manifest-based policies is the newfound ability to regulate operations on the admission configuration resources themselves. Under traditional API-based mechanisms, webhooks and policies cannot be applied to their own configuration types, clearly designed to prevent the potential chaos of being locked out of the API. However, with the new model, you’re free to modify files stored on disk without worrying about the API chain. If an erroneous policy blocks legitimate operations, all you need to do is correct the file, and the API server will detect the change, eliminating the looming threat of circular dependencies. This flexibility enables you to craft manifest-based policies that specifically guard against the deletion of critical API-based admission policies. For platform teams overseeing shared Kubernetes clusters, this feature brings a much-needed sense of security. Now, there's assurance that foundational security measures cannot be wiped out by an admin—accidentally or otherwise—fostering a stronger overall security posture for the environments they manage. Consider a manifest that prohibits modifications or deletions of admission resources labeled with `platform.example.com/protected: "true"`. This capability effectively cements your security framework, providing a safeguard that was previously elusive.

Final Thoughts: Embracing a New Era of Security in Kubernetes

The shift toward manifest-based admission control represents more than just a technical enhancement; it’s a fundamental change in how Kubernetes approaches security management. By ensuring that certain admission resources can’t be altered or removed through the API, the platform is reinforcing the integrity of its security postures. For teams already grappling with managing access in dynamic cloud-native environments, this transition could alleviate many concerns regarding accidental or malicious changes to critical configurations. Here’s the thing: while manifest files provide a solid foundation for defining policies, they come with intentional constraints that might trip up the less experienced user. It’s designed to be self-sufficient, eschewing any dependencies on cluster states at startup, which is a neat concept but also one that could lead to confusion if you’re used to a more interconnected setup. Not being able to reference external APIs can be a roadblock for complex configurations; however, the simplification might actually be a blessing in disguise, pushing users toward cleaner, more maintainable setups. You'll want to consider this before rolling out policies across multiple API server instances. Each server operates in isolation, meaning you need meticulous file management to avoid drift between them. The system’s ability to monitor changes in real-time without downtime is a plus, allowing teams to adapt quickly and safely when circumstances change. Just make sure to test thoroughly—should you encounter an invalid manifest, your entire API server won’t boot. That’s a wake-up call to prioritize validation in your setup. If you're ready to experiment with these features in Kubernetes v1.36, the steps are straightforward, but don't underestimate the importance of configuring your environment correctly. From enabling the right feature gates to structuring your static manifests appropriately, every detail matters in this brave new world of admission control. As this feature continues to develop, it promises an exciting avenue for enhancing Kubernetes governance. If you're involved in this space, keep an eye on the progress, share your insights with the community, and don’t hesitate to engage during the SIG meetings or through channels on Kubernetes Slack. Your contributions could very well shape the evolution of security within the platform. Stay engaged, and let’s navigate this transformation together.